Skip to content

Commit

Permalink
cleanup, deprecation fixes, converted private to protected, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
burtbeckwith committed Sep 30, 2013
1 parent 4f3ca40 commit d64db51
Show file tree
Hide file tree
Showing 25 changed files with 321 additions and 279 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -5,3 +5,4 @@ stacktrace.log
/grails-spring-security-core-*.zip
/testapps.config.groovy
/plugin.xml
.settings
3 changes: 0 additions & 3 deletions application.properties
@@ -1,4 +1 @@
#Grails Metadata file
#Tue Jul 17 11:29:03 EDT 2012
app.grails.version=2.0.4
plugins.hibernate=2.0.4
17 changes: 10 additions & 7 deletions scripts/S2CreatePersistentToken.groovy
Expand Up @@ -13,7 +13,7 @@
* limitations under the License.
*/

includeTargets << new File("$springSecurityCorePluginDir/scripts/_S2Common.groovy")
includeTargets << new File(springSecurityCorePluginDir, 'scripts/_S2Common.groovy')

fullClassName = null

Expand Down Expand Up @@ -61,16 +61,19 @@ private boolean configure() {
private void createDomainClass() {
String dir = packageToDir(templateAttributes.packageName)
generateFile "$templateDir/PersistentLogin.groovy.template",
"$appDir/domain/${dir}${templateAttributes.className}.groovy"
"$appDir/domain/${dir}${templateAttributes.className}.groovy"
}

private void updateConfig() {
def configFile = new File(appDir, 'conf/Config.groovy')
if (configFile.exists()) {
configFile.withWriterAppend {
it.writeLine "grails.plugins.springsecurity.rememberMe.persistent = true"
it.writeLine "grails.plugins.springsecurity.rememberMe.persistentToken.domainClassName = '$fullClassName'"
}
if (!configFile.exists()) {
return
}

configFile.withWriterAppend { BufferedWriter writer ->
writer.writeLine "grails.plugin.springsecurity.rememberMe.persistent = true"
writer.writeLine "grails.plugin.springsecurity.rememberMe.persistentToken.domainClassName = '$fullClassName'"
writer.newLine()
}
}

Expand Down
2 changes: 1 addition & 1 deletion scripts/_S2Common.groovy
Expand Up @@ -33,7 +33,7 @@ packageToDir = { String packageName ->

okToWrite = { String dest ->

def file = new File(dest)
File file = new File(dest)
if (overwriteAll || !file.exists()) {
return true
}
Expand Down
Expand Up @@ -29,7 +29,7 @@ import org.springframework.security.web.authentication.rememberme.PersistentToke
*/
class GormPersistentTokenRepository implements PersistentTokenRepository {

private final Logger log = LoggerFactory.getLogger(getClass())
protected final Logger log = LoggerFactory.getLogger(getClass())

/** Dependency injection for grailsApplication */
GrailsApplication grailsApplication
Expand All @@ -40,13 +40,13 @@ class GormPersistentTokenRepository implements PersistentTokenRepository {
* org.springframework.security.web.authentication.rememberme.PersistentRememberMeToken)
*/
void createNewToken(PersistentRememberMeToken token) {
// join an existing transaction if one is active
def clazz = lookupDomainClass()
if (!clazz) return

// join an existing transaction if one is active
clazz.withTransaction { status ->
clazz.newInstance(username: token.username, series: token.series,
token: token.tokenValue, lastUsed: token.date).save()
token: token.tokenValue, lastUsed: token.date).save()
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/java/grails/plugin/springsecurity/SecurityEventListener.java
Expand Up @@ -42,7 +42,7 @@
* All callbacks are optional; you can implement just the ones you're interested in, e.g.
* <pre>
* grails {
* plugins {
* plugin {
* springsecurity {
* ...
* onAuthenticationSuccessEvent = { e, appCtx ->
Expand All @@ -59,7 +59,7 @@
*/
public class SecurityEventListener implements ApplicationListener<ApplicationEvent>, ApplicationContextAware {

private ApplicationContext _applicationContext;
protected ApplicationContext applicationContext;

/**
* {@inheritDoc}
Expand Down Expand Up @@ -89,10 +89,10 @@ else if (e instanceof AbstractAuthorizationEvent) {
}

@SuppressWarnings("rawtypes")
private void call(final ApplicationEvent e, final String closureName) {
protected void call(final ApplicationEvent e, final String closureName) {
Object closure = SpringSecurityUtils.getSecurityConfig().get(closureName);
if (closure instanceof Closure) {
((Closure)closure).call(new Object[] { e, _applicationContext });
((Closure)closure).call(new Object[] { e, applicationContext });
}
}

Expand All @@ -101,7 +101,7 @@ private void call(final ApplicationEvent e, final String closureName) {
* @see org.springframework.context.ApplicationContextAware#setApplicationContext(
* org.springframework.context.ApplicationContext)
*/
public void setApplicationContext(final ApplicationContext applicationContext) {
_applicationContext = applicationContext;
public void setApplicationContext(final ApplicationContext ctx) {
applicationContext = ctx;
}
}
Expand Up @@ -69,21 +69,22 @@ public enum SecurityFilterPosition {
LAST(Integer.MAX_VALUE);

private static final int INTERVAL = 100;
private final int _order;

private final int order;

private SecurityFilterPosition() {
_order = ordinal() * INTERVAL;
order = ordinal() * INTERVAL;
}

private SecurityFilterPosition(final int order) {
_order = order;
private SecurityFilterPosition(final int filterOrder) {
order = filterOrder;
}

/**
* The position in the chain.
* @return the order
*/
public int getOrder() {
return _order;
return order;
}
}

0 comments on commit d64db51

Please sign in to comment.