是什么让敏捷成为比shiro更好的选择?
我现在正试图在灵活和shiro之间做出一个新的grails项目,我很好奇是什么让敏捷成为更好的选择.
我正在构建一个grails的社区网站(使用Apache Shiro进行安全和身份验证系统),我想实现"谁在线?"这一功能.
这个URL http://cksource.com/forums/viewonline.php(如果您没有访问此Url,请参阅下面的快照)给出了我想要实现的示例.
我怎么能以最简单的方式做到这一点?Grails或Java中是否存在任何现有解决方案?
谢谢.
快照:Who的快照在线页面http://www.freeimagehosting.net/uploads/th.2de8468a86.png或在此处查看:http://www.freeimagehosting.net/image.php?2de8468a86.png
我使用Shiro注释来检查这样的授权:
@RequiresPermissions("addresses:list")
public ModelAndView getCarrierListPage() {
return new ModelAndView("addressList", "viewData", viewData);
}
Run Code Online (Sandbox Code Playgroud)
我的问题是:如果用户没有注释所需的权限,则抛出异常.如果发生异常,我宁愿将用户重定向到其他URL.我怎么做?
这是我的shiro过滤器配置:
<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
<property name="securityManager" ref="securityManager"/>
<property name="loginUrl" value="/showLoginPage"/>
<property name="filterChainDefinitions">
</property>
</bean>
Run Code Online (Sandbox Code Playgroud) 我在申请认证时使用shiro.我使用散列密码和盐,我将它们存储在我的数据库中,如下所示:
private User createUserWithHashedPassword(String inName, String inFirstName, String inLastName, String inPassword){
ByteSource salt = randomNumberGenerator.nextBytes(32);
byte[] byteTabSalt = salt.getBytes();
String strSalt = byteArrayToHexString(byteTabSalt);
String hashedPasswordBase64 = new Sha256Hash(inPassword, salt, 1024).toBase64();
return new User(inName,inFirstName,inLastName,hashedPasswordBase64,strSalt);
}
Run Code Online (Sandbox Code Playgroud)
我在我的数据库中使用String存储salt.现在在我的领域我想从数据库中获取我的数据,我使用了一个transactionnal服务.但是我的salt是一个Strong,所以我希望它以静态方法转回ByteSource类型:
ByteSource byteSourceSalt = Util.bytes(salt); //where the salt is a String
Run Code Online (Sandbox Code Playgroud)
但是当我创建我的SaltedAuthenticationInfo时,它不会授权.
我认为我的问题来自我的转换方法:
private String byteArrayToHexString(byte[] bArray){
StringBuffer buffer = new StringBuffer();
for(byte b : bArray) {
buffer.append(Integer.toHexString(b));
buffer.append(" ");
}
return buffer.toString().toUpperCase();
}
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助.
我在配置Apache Shiro以禁用对除/ js和/ resources之外的所有页面的匿名访问时遇到问题,因为这会在用户登录之前中断站点设计和布局.
我当前的shiro-context.xml文件包含以下部分:
/**=authc
/js/** =anon
/resources/** =anon
Run Code Online (Sandbox Code Playgroud)
这将需要对所有页面进行身份验证并将用户重定向到/ login页面,但正如我之前所说,它将破坏对资源文件的访问.就好像没有拿起第二行和第三行指示它允许匿名访问.
难道我做错了什么?我是否可以使用/ secure /之类的路径为所有安全页面添加前缀,并允许匿名访问该文件夹上方的所有内容?
我的独立应用程序使用Shiro进行安全管理.我遇到了过期会话的问题.如果用户会话过期,当我尝试将用户重新登录时,我会收到以下异常.有人可以帮忙吗?
org.apache.shiro.session.UnknownSessionException: There is no session with id [d32af383-5f26-463f-a2f0-58a0e82c7890] at org.apache.shiro.session.mgt.eis.AbstractSessionDAO.readSession(AbstractSessionDAO.java:170) at org.apache.shiro.session.mgt.DefaultSessionManager.retrieveSessionFromDataSource(DefaultSessionManager.java:236) at org.apache.shiro.session.mgt.DefaultSessionManager.retrieveSession(DefaultSessionManager.java:222) at org.apache.shiro.session.mgt.AbstractValidatingSessionManager.doGetSession(AbstractValidatingSessionManager.java:118) at org.apache.shiro.session.mgt.AbstractNativeSessionManager.lookupSession(AbstractNativeSessionManager.java:105) at org.apache.shiro.session.mgt.AbstractNativeSessionManager.lookupRequiredSession(AbstractNativeSessionManager.java:109) at org.apache.shiro.session.mgt.AbstractNativeSessionManager.stop(AbstractNativeSessionManager.java:238) at org.apache.shiro.session.mgt.DelegatingSession.stop(DelegatingSession.java:127) at org.apache.shiro.session.ProxiedSession.stop(ProxiedSession.java:107) at org.apache.shiro.subject.support.DelegatingSubject$StoppingAwareProxiedSession.stop(DelegatingSubject.java:419) at org.apache.shiro.session.ProxiedSession.stop(ProxiedSession.java:107) at org.apache.shiro.subject.support.DelegatingSubject$StoppingAwareProxiedSession.stop(DelegatingSubject.java:419)
我用spring配置shiro
<bean id="securityManager" class="org.apache.shiro.mgt.DefaultSecurityManager">
<property name="realm" ref="myRealm"/>
<property name="sessionManager.globalSessionTimeout" value="3600000" />
</bean>
<bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor"/>
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="staticMethod" value="org.apache.shiro.SecurityUtils.setSecurityManager"/>
<property name="arguments" ref="securityManager"/>
</bean>
Run Code Online (Sandbox Code Playgroud) Apache Shiro是一个Java安全框架并支持SSO.我有多个子域,每个子域都有独立的应用程序运行.如何使用Apache Shiro Web过滤器(或任何其他)来提供单点登录.
在使用Apache Shiro之前,我是否需要SSO服务器或服务(如CAS?)?或Apache Shiro不需要SSO服务器或服务(如CAS)?
谢谢
我可以使用JDBC关系使用apache shiro通过数据库验证基于Web的应用程序.此外,我已经能够使用Shiro-Filters为web.xml中的Shiro过滤器配置和shiro.ini中的配置授予对特定Web资源或http URL的访问权限.
现在,我想为webservices实现相同的功能.特别是,如果凭据有效,我希望用户点击login-url获取令牌.之后,必须根据用户的特定令牌验证对Web服务的所有连续请求.我没有任何线索来实现这一点.任何建议,程序或暗示性链接都可以帮助我!
你能帮我解决下列情况吗?
背景资料:
[主要]
contextFactory = org.apache.shiro.realm.ldap.JndiLdapContextFactory
contextFactory.url = ldaps://<SERVER>:636
contextFactory.systemUsername = <USERNAME>@<COMPANY>
contextFactory.systemPassword = <PASSWORD>
contextFactory.environment[java.naming.security.protocol] = ssl
realm = org.apache.shiro.realm.activedirectory.ActiveDirectoryRealm
realm.ldapContextFactory = $contextFactory
realm.searchBase = "OU=<APPDIR>,DC=<COMPANY>,DC=lcl"
realm.groupRolesMap = "CN=<ROLE>,OU=<APPDIR>,DC=<COMPANY>,DC=lcl":"Admin"
Run Code Online (Sandbox Code Playgroud)
[作用]
# 'Admin' role has permissions *
Admin = *
Run Code Online (Sandbox Code Playgroud)
目标
问题
问题
关于Shiro记得我的功能我几乎没有问题:
CipherKey?shiro ×10
java ×6
apache ×2
grails ×2
spring-mvc ×2
database ×1
ldap ×1
nimble ×1
remember-me ×1
rest ×1
salt ×1
spring ×1
vaadin ×1
web-services ×1