jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1532774 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak: security/authentication/token/ spi/security/authentication/ spi/security/authentication/external/
Date Wed, 16 Oct 2013 14:08:03 GMT
Author: angela
Date: Wed Oct 16 14:08:03 2013
New Revision: 1532774

URL: http://svn.apache.org/r1532774
Log:
OAK-91 : authentication (minor improvement)

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/token/TokenLoginModule.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/AbstractLoginModule.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/external/ExternalLoginModule.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/external/SyncHandler.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/token/TokenLoginModule.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/token/TokenLoginModule.java?rev=1532774&r1=1532773&r2=1532774&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/token/TokenLoginModule.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/token/TokenLoginModule.java
Wed Oct 16 14:08:03 2013
@@ -215,7 +215,7 @@ public final class TokenLoginModule exte
         SecurityProvider securityProvider = getSecurityProvider();
         Root root = getRoot();
         if (root != null && securityProvider != null) {
-            AuthenticationConfiguration authConfig = getSecurityProvider().getConfiguration(AuthenticationConfiguration.class);
+            AuthenticationConfiguration authConfig = securityProvider.getConfiguration(AuthenticationConfiguration.class);
             provider = authConfig.getTokenProvider(root);
         }
         if (provider == null && callbackHandler != null) {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/AbstractLoginModule.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/AbstractLoginModule.java?rev=1532774&r1=1532773&r2=1532774&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/AbstractLoginModule.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/AbstractLoginModule.java
Wed Oct 16 14:08:03 2013
@@ -372,10 +372,10 @@ public abstract class AbstractLoginModul
     protected UserManager getUserManager() {
         UserManager userManager = null;
         SecurityProvider sp = getSecurityProvider();
-        Root root = getRoot();
-        if (root != null && sp != null) {
+        Root r = getRoot();
+        if (r != null && sp != null) {
             UserConfiguration uc = securityProvider.getConfiguration(UserConfiguration.class);
-            userManager = uc.getUserManager(root, NamePathMapper.DEFAULT);
+            userManager = uc.getUserManager(r, NamePathMapper.DEFAULT);
         }
 
         if (userManager == null && callbackHandler != null) {
@@ -404,10 +404,10 @@ public abstract class AbstractLoginModul
     protected PrincipalProvider getPrincipalProvider() {
         PrincipalProvider principalProvider = null;
         SecurityProvider sp = getSecurityProvider();
-        Root root = getRoot();
-        if (root != null && sp != null) {
+        Root r = getRoot();
+        if (r != null && sp != null) {
             PrincipalConfiguration pc = sp.getConfiguration(PrincipalConfiguration.class);
-            principalProvider = pc.getPrincipalProvider(root, NamePathMapper.DEFAULT);
+            principalProvider = pc.getPrincipalProvider(r, NamePathMapper.DEFAULT);
         }
 
         if (principalProvider == null && callbackHandler != null) {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/external/ExternalLoginModule.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/external/ExternalLoginModule.java?rev=1532774&r1=1532773&r2=1532774&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/external/ExternalLoginModule.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/external/ExternalLoginModule.java
Wed Oct 16 14:08:03 2013
@@ -18,9 +18,11 @@ package org.apache.jackrabbit.oak.spi.se
 
 import java.util.Collections;
 import java.util.Set;
+import javax.annotation.Nonnull;
 import javax.jcr.SimpleCredentials;
 import javax.security.auth.login.LoginException;
 
+import org.apache.jackrabbit.api.security.user.UserManager;
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.spi.security.authentication.AbstractLoginModule;
@@ -56,6 +58,7 @@ public abstract class ExternalLoginModul
      *
      * @return
      */
+    @Nonnull
     protected abstract ExternalUser getExternalUser();
 
     /**
@@ -64,6 +67,7 @@ public abstract class ExternalLoginModul
      * @return
      * @throws SyncException
      */
+    @Nonnull
     protected SyncHandler getSyncHandler() throws SyncException {
         Object syncHandler = options.getConfigValue(PARAM_SYNC_HANDLER, null, null);
         if (syncHandler == null) {
@@ -117,6 +121,10 @@ public abstract class ExternalLoginModul
         try {
             SyncHandler handler = getSyncHandler();
             Root root = getRoot();
+            UserManager userManager = getUserManager();
+            if (root == null || userManager == null) {
+                throw new LoginException("Cannot synchronize user.");
+            }
             Object smValue = options.getConfigValue(PARAM_SYNC_MODE, null, null);
             SyncMode syncMode;
             if (smValue == null) {
@@ -124,7 +132,7 @@ public abstract class ExternalLoginModul
             } else {
                 syncMode = SyncMode.fromObject(smValue);
             }
-            if (handler.initialize(getUserManager(), root, syncMode, options)) {
+            if (handler.initialize(userManager, root, syncMode, options)) {
                 handler.sync(getExternalUser());
                 root.commit();
                 return true;

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/external/SyncHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/external/SyncHandler.java?rev=1532774&r1=1532773&r2=1532774&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/external/SyncHandler.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/external/SyncHandler.java
Wed Oct 16 14:08:03 2013
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.oak.spi.security.authentication.external;
 
+import javax.annotation.Nonnull;
+
 import org.apache.jackrabbit.api.security.user.UserManager;
 import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters;
@@ -25,8 +27,9 @@ import org.apache.jackrabbit.oak.spi.sec
  */
 public interface SyncHandler {
 
-    boolean initialize(UserManager userManager, Root root, SyncMode mode,
-                       ConfigurationParameters options) throws SyncException;
+    boolean initialize(@Nonnull UserManager userManager, @Nonnull Root root,
+                       @Nonnull SyncMode mode,
+                       @Nonnull ConfigurationParameters options) throws SyncException;
 
-    boolean sync(ExternalUser externalUser) throws SyncException;
+    boolean sync(@Nonnull ExternalUser externalUser) throws SyncException;
 }
\ No newline at end of file



Mime
View raw message