我在我的Web应用程序中使用spring security,现在我想要列出所有登录我程序的用户.
我怎样才能访问该列表?它们不是已经存在于spring框架内的某个地方吗?像SecurityContextHolder或SecurityContextRepository?
我希望每个请求都能收到一些信息,所以我认为不是每个请求都有一个函数,而是单独从请求中获取这些信息,最好有一个过滤器.
因此,每个请求都应通过该过滤器,并获得我想要的.
问题是:如何编写自定义过滤器?
假设它不像任何预定义的弹簧安全过滤器,它是全新的.
我在这里看到了这个问题:使用Mac OS X加载rgl包时出错,但没有提到安装错误,这是我的情况.我无法rgl使用以下命令安装软件包R:
source("http://bioconductor.org/biocLite.R")
biocLite("rgl")
Run Code Online (Sandbox Code Playgroud)
显示以下错误:
source("http://bioconductor.org/biocLite.R")
biocLite("rgl")
Run Code Online (Sandbox Code Playgroud)
我检查了这个地址/Library/Frameworks/R.framework/Versions/3.2/Resources/library,没有rgl文件夹,所以我不能删除aglrgl.so(或rgl.so),这是上述问题的答案.你能帮我解决这个安装问题吗?谢谢.
我需要找到那些登录我们的应用程序的用户.
我们正在使用Spring Security,必须有办法找出用户的IP.
我认为这些信息存储在他们的会话中.在Spring Security中,当前会话存储在SessionRegistry中.从这个类我可以有经过身份验证的用户列表和一些会话信息.(使用getAllPrincipals,getAllSessions和getSessionInformation)
的问题是,我怎么能有机会获得当前用户的IP地址?考虑我们必须仅为已知区域提供服务.
该SessionInformation没有太大的帮助,因为它并不包含太多的信息.
我创建了一个页面,要求用户填写一些表单字段,当他提交时,表单将被发送到Restful方法,您可以在下面看到:
@POST
@Path("addUser")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public void addUser(@FormParam("username") String username,
@FormParam("password") String password,
@FormParam("id") String id,
@FormParam("group_name") String groupName,
@FormParam("authority_name") String authorityName,
@FormParam("authority_id") String authorityId
)
{
//Something will be done here
}
Run Code Online (Sandbox Code Playgroud)
如何在此函数结束时将用户重定向到(比方说)index.jsp?
当我使用命令java ExceptionTest运行一些java程序时,有时会省略异常并且看起来像
Exception in thread "main" java.lang.NoClassDefFoundError: aa/bb/DD
at SOMEWHERE(unknown source)
Caused by: java.lang.ClassNotFoundException: aaa.bbb.CC
at SOMEWHER(unknown source)
... 13 more
Run Code Online (Sandbox Code Playgroud)
在这种情况下,我想看到另外13个例外.是否有选项可以查看所有异常日志?
我想知道我是否正确地注释这些类,因为我是注释的新手:
Country.java
@Component
public class Country {
private int countryId;
private String countryName;
private String countryCode;
/**
* No args constructor
*/
public Country() {
}
/**
* @param countryId
* @param countryName
* @param countryCode
*/
public Country(int countryId, String countryName, String countryCode) {
this.countryId = countryId;
this.countryName = countryName;
this.countryCode = countryCode;
}
//getters and setters
}
Run Code Online (Sandbox Code Playgroud)
CountryDAO.java
@Repository
public interface CountryDAO {
public List<Country> getCountryList();
public void saveCountry(Country country);
public void updateCountry(Country country);
}
Run Code Online (Sandbox Code Playgroud)
JdbcCountryDAO.java
@Component
public …Run Code Online (Sandbox Code Playgroud) 我正在使用spring security,我必须同时使用filter-chain和namespace.命名空间工作正常,但似乎过滤链没有!
这是我的配置.首先,命名空间:
<sec:global-method-security secured-annotations="enabled" />
<sec:http pattern="/app/login.jsp*" security="none" />
<sec:http pattern="/admin/login.jsp*" security="none" />
<sec:http pattern="/app/*.png" security="none" />
<sec:http pattern="/admin/*.png" security="none" />
<sec:http pattern="/app/**" authentication-manager-ref="authenticationManager"
access-decision-manager-ref="accessDecisionManager">
<sec:intercept-url pattern="/app/**" access="ROLE_USER" />
<sec:access-denied-handler error-page="/app/login.jsp?aer=" />
<sec:form-login login-processing-url="/app/j_spring_security_check"
always-use-default-target="true" default-target-url="/app/index.html"
login-page='/app/login.jsp' authentication-failure-url='/app/login.jsp?login_error' />
<sec:logout logout-url="/app/j_spring_security_logout"
invalidate-session="true" logout-success-url="/app/login.jsp" />
</sec:http>
<sec:http pattern="/admin/**" authentication-manager-ref="authenticationManager"
access-decision-manager-ref="accessDecisionManager">
<sec:intercept-url pattern="/admin/**" access="ROLE_ADMIN" />
<sec:access-denied-handler error-page="/admin/login.jsp?aer=" />
<sec:form-login login-processing-url="/admin/j_spring_security_check"
always-use-default-target="true" default-target-url="/admin/index.html"
login-page='/admin/login.jsp' authentication-failure-url='/admin/login.jsp?login_error' />
<sec:logout logout-url="/admin/j_spring_security_logout"
invalidate-session="true" logout-success-url="/admin/login.jsp" />
</sec:http>
Run Code Online (Sandbox Code Playgroud)
这很好用.但是我还需要一个过滤器链来检查其他请求.(这些请求是动态创建的,我们必须以这种方式控制它们)
这是我的过滤器链:
<bean id="springSecurityFilterChain" class="org.springframework.security.web.FilterChainProxy">
<security:filter-chain-map path-type="ant">
<sec:filter-chain pattern="/css/**" filters="none" …Run Code Online (Sandbox Code Playgroud) 有没有办法在使用hibernate.hbm2ddl.auto属性创建表时创建视图.我使用注释类型来定义表及其字段.是否有任何属性可用于通过休眠创建视图?
假设我在我的程序中生成了几个数字.我想让用户可以选择一次打印所有内容.我不想为每个页面显示打印对话框.因此,我只显示一次,仅显示第一个数字.这是我到目前为止提出的解决方案:
figHandles = get(0, 'Children');
for currFig = 1:length(figHandles)
if(currFig == 1)
printdlg(figHandles(currFig)); % Shows the print dialog for the first figure
else
print(figHandles(currFig)); % Does not show the print dialog and uses the latest printer selection
end
end
Run Code Online (Sandbox Code Playgroud)
但问题是,如果用户取消第一个数字的打印,我无法抓住它并取消其他打印.我该怎么做?