Browse files

Applied patch by Luis Arias. Also enabled Grails 1.3+ BuildConfig.gro…

…ovy for dependency resolution instead of saving the .jars in the project's lib directory in SVN.
  • Loading branch information...
1 parent ef0be5e commit 0a91a578350c415a86450f036ee95d14c3ce7414 Les Hazlewood committed Jun 15, 2010
View
4 .bzrignore
@@ -0,0 +1,4 @@
+./.idea
+./grails-shiro.iml
+./target
+./web-app
View
39 ShiroGrailsPlugin.groovy
@@ -30,8 +30,8 @@ import org.apache.shiro.grails.annotations.PermissionRequired
import org.apache.shiro.grails.annotations.RoleRequired
import org.apache.shiro.mgt.SecurityManager
import org.apache.shiro.realm.Realm
-import org.apache.shiro.web.DefaultWebSecurityManager
-import org.apache.shiro.web.WebRememberMeManager
+import org.apache.shiro.web.mgt.DefaultWebSecurityManager
+import org.apache.shiro.web.mgt.CookieRememberMeManager
import org.codehaus.groovy.grails.commons.ConfigurationHolder
import org.codehaus.groovy.grails.commons.ControllerArtefactHandler
@@ -40,6 +40,9 @@ import org.codehaus.groovy.grails.plugins.web.filters.FilterConfig
import org.springframework.aop.framework.ProxyFactoryBean
import org.springframework.aop.target.HotSwappableTargetSource
+import org.apache.shiro.authc.pam.ModularRealmAuthenticator
+import org.apache.shiro.spring.web.ShiroFilterFactoryBean
+import org.apache.shiro.web.mgt.WebSecurityManager
class ShiroGrailsPlugin {
// the plugin version
@@ -104,11 +107,14 @@ Adopted from previous JSecurity plugin.
// instances.
shiroPermissionResolver(WildcardPermissionResolver)
- // Default authentication strategy.
+ // Default authentication strategy
shiroAuthenticationStrategy(AtLeastOneSuccessfulStrategy)
-
+ // Default authenticator
+ shiroAuthenticator(ModularRealmAuthenticator) {
+ authenticationStrategy = ref("shiroAuthenticationStrategy")
+ }
// Default remember-me manager.
- shiroRememberMeManager(WebRememberMeManager)
+ shiroRememberMeManager(CookieRememberMeManager)
// If we're in development mode, then place the security manager
// behind a proxy. This allows us to change the security manager
@@ -133,7 +139,7 @@ Adopted from previous JSecurity plugin.
shiroSecurityManagerProxy(ProxyFactoryBean) {
targetSource = ref("shiroSecurityManagerTargetSource")
- proxyInterfaces = [ SecurityManager ]
+ proxyInterfaces = [ WebSecurityManager ]
}
}
@@ -153,9 +159,13 @@ Adopted from previous JSecurity plugin.
// Allow the user to provide his own versions of these
// components in resources.xml or resources.groovy.
- authenticationStrategy = ref("shiroAuthenticationStrategy")
+ authenticator = ref("shiroAuthenticator")
rememberMeManager = ref("shiroRememberMeManager")
}
+
+ shiroFilter(ShiroFilterFactoryBean) {
+ securityManager = GrailsUtil.isDevelopmentEnv() ? ref("shiroSecurityManagerProxy") : ref("shiroSecurityManager")
+ }
}
def doWithApplicationContext = { applicationContext ->
@@ -235,16 +245,11 @@ Adopted from previous JSecurity plugin.
def contextParam = xml.'context-param'
contextParam[contextParam.size() - 1] + {
'filter' {
- 'filter-name'('securityContextFilter')
- 'filter-class'('org.apache.shiro.spring.SpringShiroFilter')
+ 'filter-name'('shiroFilter')
+ 'filter-class'('org.springframework.web.filter.DelegatingFilterProxy')
'init-param' {
- 'param-name'('securityManagerBeanName')
- if (GrailsUtil.isDevelopmentEnv()) {
- 'param-value'('shiroSecurityManagerProxy')
- }
- else {
- 'param-value'('shiroSecurityManager')
- }
+ 'param-name'('targetFilterLifecycle')
+ 'param-value'('true')
}
// If a Shiro configuration is available, add it
@@ -326,7 +331,7 @@ Adopted from previous JSecurity plugin.
// Finally add the Shiro filter mapping after the selected insertion point.
filter + {
'filter-mapping' {
- 'filter-name'('securityContextFilter')
+ 'filter-name'('shiroFilter')
'url-pattern'("/*")
}
}
View
10 application.properties
@@ -1,4 +1,6 @@
-#utf-8
-#Thu Jul 16 22:42:30 CDT 2009
-app.grails.version=1.2.0
-app.name=grails-shiro
+#Grails Metadata file
+#Thu Jun 10 18:05:22 PDT 2010
+app.grails.version=1.3.1
+app.name=grails-shiro
+plugins.hibernate=1.3.1
+plugins.tomcat=1.3.1
View
40 grails-app/conf/BuildConfig.groovy
@@ -0,0 +1,40 @@
+grails.project.class.dir = "target/classes"
+grails.project.test.class.dir = "target/test-classes"
+grails.project.test.reports.dir = "target/test-reports"
+//grails.project.war.file = "target/${appName}-${appVersion}.war"
+grails.project.dependency.resolution = {
+ // inherit Grails' default dependencies
+ inherits( "global" ) {
+ // uncomment to disable ehcache
+ // excludes 'ehcache'
+ }
+ log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
+ repositories {
+ grailsPlugins()
+ grailsHome()
+ grailsCentral()
+
+ // uncomment the below to enable remote dependency resolution
+ // from public Maven repositories
+ mavenLocal()
+ mavenCentral()
+ //mavenRepo "http://snapshots.repository.codehaus.org"
+ //mavenRepo "http://repository.codehaus.org"
+ //mavenRepo "http://download.java.net/maven/2/"
+ //mavenRepo "http://repository.jboss.com/maven2/"
+ }
+ dependencies {
+ // specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.
+
+ // runtime 'mysql:mysql-connector-java:5.1.5'
+ compile 'org.apache.shiro:shiro-core:1.0.0-incubating'
+ compile 'org.apache.shiro:shiro-web:1.0.0-incubating'
+ compile 'org.apache.shiro:shiro-ehcache:1.0.0-incubating'
+ compile 'org.apache.shiro:shiro-quartz:1.0.0-incubating'
+ compile 'org.apache.shiro:shiro-spring:1.0.0-incubating'
+
+ excludes 'ejb', 'jsf-api', 'jms', 'connector-api'
+
+ }
+
+}
View
BIN lib/shiro-all-1.0-incubating-SNAPSHOT.jar
Binary file not shown.
View
42 plugin.xml
@@ -6,46 +6,10 @@ Adopted from previous JSecurity plugin.
</description>
<documentation>http://grails.org/Shiro+Plugin</documentation>
<resources>
+ <resource>BuildConfig</resource>
<resource>ShiroFilters</resource>
<resource>ShiroTagLib</resource>
</resources>
- <dependencies>
- <resolvers>
- <resolver type='grailsPlugins' name='grailsPlugins' />
- </resolvers>
- </dependencies>
- <behavior>
- <method name='getRoleMap' artefact='Filters' type='org.codehaus.groovy.grails.web.filters.JavascriptLibraryFilters'>
- <description />
- <argument type='java.lang.String' />
- </method>
- <method name='getPermissionMap' artefact='Filters' type='org.codehaus.groovy.grails.web.filters.JavascriptLibraryFilters'>
- <description />
- <argument type='java.lang.String' />
- </method>
- <method name='getRoleMap' artefact='Filters' type='ShiroFilters'>
- <description />
- <argument type='java.lang.String' />
- </method>
- <method name='getPermissionMap' artefact='Filters' type='ShiroFilters'>
- <description />
- <argument type='java.lang.String' />
- </method>
- <method name='accessControl' artefact='Filters' type='org.codehaus.groovy.grails.plugins.web.filters.FilterConfig'>
- <description />
- </method>
- <method name='accessControl' artefact='Filters' type='org.codehaus.groovy.grails.plugins.web.filters.FilterConfig'>
- <description />
- <argument type='java.util.Map' />
- </method>
- <method name='accessControl' artefact='Filters' type='org.codehaus.groovy.grails.plugins.web.filters.FilterConfig'>
- <description />
- <argument type='groovy.lang.Closure' />
- </method>
- <method name='accessControl' artefact='Filters' type='org.codehaus.groovy.grails.plugins.web.filters.FilterConfig'>
- <description />
- <argument type='java.util.Map' />
- <argument type='groovy.lang.Closure' />
- </method>
- </behavior>
+ <dependencies />
+ <behavior />
</plugin>
View
41 src/java/org/apache/shiro/grails/DummySecurityManager.java
@@ -1,21 +1,21 @@
package org.apache.shiro.grails;
-import java.io.Serializable;
-import java.net.InetAddress;
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authz.AuthorizationException;
import org.apache.shiro.authz.Permission;
-import org.apache.shiro.mgt.SecurityManager;
-import org.apache.shiro.session.InvalidSessionException;
+import org.apache.shiro.session.Session;
+import org.apache.shiro.session.SessionException;
+import org.apache.shiro.session.mgt.SessionContext;
+import org.apache.shiro.session.mgt.SessionKey;
import org.apache.shiro.subject.PrincipalCollection;
import org.apache.shiro.subject.Subject;
+import org.apache.shiro.subject.SubjectContext;
+import org.apache.shiro.web.mgt.WebSecurityManager;
+
+import java.util.Collection;
+import java.util.List;
/**
* An empty implementation of the Shiro SecurityManager interface. It
@@ -24,9 +24,8 @@
*
* @author Peter Ledbrook
*/
-public class DummySecurityManager implements SecurityManager {
- public Subject createSubject(Map arg0) { return null; }
- public Subject getSubject() { return null; }
+public class DummySecurityManager implements WebSecurityManager {
+ public Subject createSubject(SubjectContext arg0) { return null; }
public Subject login(Subject arg0, AuthenticationToken arg1) throws AuthenticationException { return null; }
public void logout(Subject arg0) { }
public AuthenticationInfo authenticate(AuthenticationToken arg0) throws AuthenticationException { return null; }
@@ -45,19 +44,7 @@ public void checkRoles(PrincipalCollection arg0, Collection<String> arg1) throws
public boolean[] isPermitted(PrincipalCollection arg0, List<Permission> arg1) { return null; }
public boolean isPermittedAll(PrincipalCollection arg0, String... arg1) { return false; }
public boolean isPermittedAll(PrincipalCollection arg0, Collection<Permission> arg1) { return false; }
- public void checkValid(Serializable arg0) throws InvalidSessionException { }
- public Object getAttribute(Serializable arg0, Object arg1) throws InvalidSessionException { return null; }
- public Collection<Object> getAttributeKeys(Serializable arg0) { return null; }
- public InetAddress getHostAddress(Serializable arg0) { return null; }
- public Date getLastAccessTime(Serializable arg0) { return null; }
- public Date getStartTimestamp(Serializable arg0) { return null; }
- public long getTimeout(Serializable arg0) throws InvalidSessionException { return 0; }
- public boolean isValid(Serializable arg0) { return false; }
- public Object removeAttribute(Serializable arg0, Object arg1) throws InvalidSessionException { return null; }
- public void setAttribute(Serializable arg0, Object arg1, Object arg2) throws InvalidSessionException { }
- public void setTimeout(Serializable arg0, long arg1) throws InvalidSessionException { }
- public Serializable start(InetAddress arg0) throws AuthorizationException { return null; }
- public Serializable start(Map arg0) throws AuthorizationException { return null; }
- public void stop(Serializable arg0) throws InvalidSessionException { }
- public void touch(Serializable arg0) throws InvalidSessionException { }
+ public Session start(SessionContext sessionContext) { return null; }
+ public Session getSession(SessionKey sessionKey) throws SessionException { return null; }
+ public boolean isHttpSessionMode() { return false; }
}
View
4 src/templates/artifacts/controllers/AuthController.groovy
@@ -1,8 +1,8 @@
import org.apache.shiro.SecurityUtils
import org.apache.shiro.authc.AuthenticationException
import org.apache.shiro.authc.UsernamePasswordToken
-import org.apache.shiro.web.SavedRequest
-import org.apache.shiro.web.WebUtils
+import org.apache.shiro.web.util.SavedRequest
+import org.apache.shiro.web.util.WebUtils
class AuthController {
def shiroSecurityManager
View
2 src/templates/artifacts/realms/ShiroLdapRealm.groovy
@@ -101,7 +101,7 @@ class @realm.name@ {
if (!urlUsed) {
def msg = 'No LDAP server available.'
log.error msg
- throw new org.jsecurity.authc.AuthenticationException(msg)
+ throw new org.apache.shiro.authc.AuthenticationException(msg)
}
// Look up the DN for the LDAP entry that has a 'uid' value

0 comments on commit 0a91a57

Please sign in to comment.