jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1430947 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication: token/TokenProviderImpl.java user/LoginModuleImpl.java user/UserAuthentication.java
Date Wed, 09 Jan 2013 16:37:05 GMT
Author: angela
Date: Wed Jan  9 16:37:04 2013
New Revision: 1430947

URL: http://svn.apache.org/viewvc?rev=1430947&view=rev
Log:
 OAK-91 - Implement Authentication Support (WIP)

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/token/TokenProviderImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/user/LoginModuleImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/user/UserAuthentication.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/token/TokenProviderImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/token/TokenProviderImpl.java?rev=1430947&r1=1430946&r2=1430947&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/token/TokenProviderImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/token/TokenProviderImpl.java
Wed Jan  9 16:37:04 2013
@@ -159,6 +159,7 @@ public class TokenProviderImpl implement
 
     @Override
     public TokenInfo createToken(String userId, Map<String, ?> attributes) {
+        String error = "Failed to create login token ";
         try {
             Authorizable user = userManager.getAuthorizable(userId);
             if (user != null && !user.isGroup()) {
@@ -199,13 +200,13 @@ public class TokenProviderImpl implement
             }
 
         } catch (NoSuchAlgorithmException e) {
-            log.debug("Failed to create login token ", e.getMessage());
+            log.debug(error, e.getMessage());
         } catch (UnsupportedEncodingException e) {
-            log.debug("Failed to create login token ", e.getMessage());
+            log.debug(error, e.getMessage());
         } catch (CommitFailedException e) {
-            log.debug("Failed to create login token ", e.getMessage());
+            log.debug(error, e.getMessage());
         } catch (RepositoryException e) {
-            log.debug("Failed to create login token ", e.getMessage());
+            log.debug(error, e.getMessage());
         }
 
         return null;
@@ -333,7 +334,7 @@ public class TokenProviderImpl implement
     /**
      * TokenInfo
      */
-    private static class TokenInfoImpl implements TokenInfo {
+    private static final class TokenInfoImpl implements TokenInfo {
 
         private final String token;
         private final String tokenPath;
@@ -390,12 +391,12 @@ public class TokenProviderImpl implement
 
         @Override
         public boolean matches(TokenCredentials tokenCredentials) {
-            String token = tokenCredentials.getToken();
-            int pos = token.lastIndexOf(DELIM);
+            String tk = tokenCredentials.getToken();
+            int pos = tk.lastIndexOf(DELIM);
             if (pos > -1) {
-                token = token.substring(pos + 1);
+                tk = tk.substring(pos + 1);
             }
-            if (key == null || !PasswordUtility.isSame(key, token)) {
+            if (key == null || !PasswordUtility.isSame(key, tk)) {
                 return false;
             }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/user/LoginModuleImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/user/LoginModuleImpl.java?rev=1430947&r1=1430946&r2=1430947&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/user/LoginModuleImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/user/LoginModuleImpl.java
Wed Jan  9 16:37:04 2013
@@ -26,7 +26,6 @@ import javax.annotation.CheckForNull;
 import javax.jcr.Credentials;
 import javax.jcr.GuestCredentials;
 import javax.jcr.SimpleCredentials;
-import javax.security.auth.Subject;
 import javax.security.auth.callback.Callback;
 import javax.security.auth.callback.NameCallback;
 import javax.security.auth.callback.UnsupportedCallbackException;
@@ -38,7 +37,6 @@ import org.apache.jackrabbit.oak.spi.sec
 import org.apache.jackrabbit.oak.spi.security.authentication.AbstractLoginModule;
 import org.apache.jackrabbit.oak.spi.security.authentication.Authentication;
 import org.apache.jackrabbit.oak.spi.security.authentication.ImpersonationCredentials;
-import org.apache.jackrabbit.oak.spi.security.principal.PrincipalProvider;
 import org.apache.jackrabbit.oak.spi.security.user.util.UserUtility;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -46,7 +44,8 @@ import org.slf4j.LoggerFactory;
 /**
  * Default login module implementation that authenticates JCR {@code Credentials}
  * against the repository. Based on the credentials the {@link Principal}s
- * associated with user are retrieved from a configurable {@link PrincipalProvider}.
+ * associated with user are retrieved from a configurable
+ * {@link org.apache.jackrabbit.oak.spi.security.principal.PrincipalProvider}.
  *
  * <h3>Credentials</h3>
  *
@@ -60,7 +59,7 @@ import org.slf4j.LoggerFactory;
  *     expected value is a validated single {@code Credentials} object.</li>
  *     <li>If neither of the above variants provides Credentials this module
  *     tries to obtain them from the subject. See also
- *     {@link Subject#getSubject(java.security.AccessControlContext)}</li>
+ *     {@link javax.security.auth.Subject#getSubject(java.security.AccessControlContext)}</li>
  * </ul>
  *
  * This implementation of the {@code LoginModule} currently supports the following

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/user/UserAuthentication.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/user/UserAuthentication.java?rev=1430947&r1=1430946&r2=1430947&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/user/UserAuthentication.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/user/UserAuthentication.java
Wed Jan  9 16:37:04 2013
@@ -122,7 +122,7 @@ class UserAuthentication implements Auth
 
     private boolean impersonate(AuthInfo info, User user) {
         try {
-            if (info.getUserID().equals(user.getID())) {
+            if (user.getID().equals(info.getUserID())) {
                 log.debug("User " + info.getUserID() + " wants to impersonate himself ->
success.");
                 return true;
             } else {



Mime
View raw message