]> source.dussan.org Git - archiva.git/commitdiff
package move to o.a.a.r module redback-authentication-keys
authorOlivier Lamy <olamy@apache.org>
Sat, 7 Apr 2012 21:56:43 +0000 (21:56 +0000)
committerOlivier Lamy <olamy@apache.org>
Sat, 7 Apr 2012 21:56:43 +0000 (21:56 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1310882 13f79535-47bb-0310-9956-ffa450edef68

redback-keys/redback-authentication-keys/src/main/java/org/apache/archiva/redback/authentication/keystore/KeyStoreAuthenticator.java [new file with mode: 0644]
redback-keys/redback-authentication-keys/src/main/java/org/codehaus/plexus/redback/authentication/keystore/KeyStoreAuthenticator.java [deleted file]
redback-keys/redback-authentication-keys/src/main/resources/META-INF/spring-context.xml

diff --git a/redback-keys/redback-authentication-keys/src/main/java/org/apache/archiva/redback/authentication/keystore/KeyStoreAuthenticator.java b/redback-keys/redback-authentication-keys/src/main/java/org/apache/archiva/redback/authentication/keystore/KeyStoreAuthenticator.java
new file mode 100644 (file)
index 0000000..910dc0f
--- /dev/null
@@ -0,0 +1,117 @@
+package org.apache.archiva.redback.authentication.keystore;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.redback.authentication.AuthenticationDataSource;
+import org.apache.archiva.redback.authentication.AuthenticationException;
+import org.apache.archiva.redback.authentication.AuthenticationResult;
+import org.apache.archiva.redback.authentication.Authenticator;
+import org.apache.archiva.redback.authentication.TokenBasedAuthenticationDataSource;
+import org.apache.archiva.redback.keys.AuthenticationKey;
+import org.apache.archiva.redback.keys.KeyManager;
+import org.apache.archiva.redback.keys.KeyManagerException;
+import org.apache.archiva.redback.keys.KeyNotFoundException;
+import org.codehaus.plexus.redback.policy.AccountLockedException;
+import org.codehaus.plexus.redback.policy.MustChangePasswordException;
+import org.apache.archiva.redback.users.User;
+import org.apache.archiva.redback.users.UserManager;
+import org.apache.archiva.redback.users.UserNotFoundException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+
+/**
+ * KeyStoreAuthenticator:
+ *
+ * @author: Jesse McConnell <jesse@codehaus.org>
+ * @version: $Id$
+ */
+@Service( "authenticator#keystore" )
+public class KeyStoreAuthenticator
+    implements Authenticator
+{
+    private Logger log = LoggerFactory.getLogger( getClass() );
+
+    @Resource( name = "keyManager#cached" )
+    private KeyManager keystore;
+
+    @Resource( name = "userManager#configurable" )
+    private UserManager userManager;
+
+    public String getId()
+    {
+        return "$Id$";
+    }
+
+    public AuthenticationResult authenticate( AuthenticationDataSource source )
+        throws AccountLockedException, AuthenticationException, MustChangePasswordException
+    {
+        TokenBasedAuthenticationDataSource dataSource = (TokenBasedAuthenticationDataSource) source;
+
+        String key = dataSource.getToken();
+        try
+        {
+            AuthenticationKey authKey = keystore.findKey( key );
+
+            // if we find a key (exception was probably thrown if not) then we should be authentic
+            if ( authKey != null )
+            {
+                User user = userManager.findUser( dataSource.getPrincipal() );
+
+                if ( user.isLocked() )
+                {
+                    throw new AccountLockedException( "Account " + source.getPrincipal() + " is locked.", user );
+                }
+
+                if ( user.isPasswordChangeRequired() && source.isEnforcePasswordChange() )
+                {
+                    throw new MustChangePasswordException( "Password expired.", user );
+                }
+
+                return new AuthenticationResult( true, dataSource.getPrincipal(), null );
+            }
+            else
+            {
+                return new AuthenticationResult( false, dataSource.getPrincipal(),
+                                                 new AuthenticationException( "unable to find key" ) );
+            }
+        }
+        catch ( KeyNotFoundException ne )
+        {
+            return new AuthenticationResult( false, null, ne );
+        }
+        catch ( KeyManagerException ke )
+        {
+            throw new AuthenticationException( "underlaying keymanager issue", ke );
+        }
+        catch ( UserNotFoundException e )
+        {
+            log.warn( "Login for user " + source.getPrincipal() + " failed. user not found." );
+            return new AuthenticationResult( false, null, e );
+        }
+    }
+
+    public boolean supportsDataSource( AuthenticationDataSource source )
+    {
+        return source instanceof TokenBasedAuthenticationDataSource;
+    }
+}
\ No newline at end of file
diff --git a/redback-keys/redback-authentication-keys/src/main/java/org/codehaus/plexus/redback/authentication/keystore/KeyStoreAuthenticator.java b/redback-keys/redback-authentication-keys/src/main/java/org/codehaus/plexus/redback/authentication/keystore/KeyStoreAuthenticator.java
deleted file mode 100644 (file)
index f290687..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-package org.codehaus.plexus.redback.authentication.keystore;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.archiva.redback.authentication.AuthenticationDataSource;
-import org.apache.archiva.redback.authentication.AuthenticationException;
-import org.apache.archiva.redback.authentication.AuthenticationResult;
-import org.apache.archiva.redback.authentication.Authenticator;
-import org.apache.archiva.redback.authentication.TokenBasedAuthenticationDataSource;
-import org.apache.archiva.redback.keys.AuthenticationKey;
-import org.apache.archiva.redback.keys.KeyManager;
-import org.apache.archiva.redback.keys.KeyManagerException;
-import org.apache.archiva.redback.keys.KeyNotFoundException;
-import org.codehaus.plexus.redback.policy.AccountLockedException;
-import org.codehaus.plexus.redback.policy.MustChangePasswordException;
-import org.apache.archiva.redback.users.User;
-import org.apache.archiva.redback.users.UserManager;
-import org.apache.archiva.redback.users.UserNotFoundException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Service;
-
-import javax.annotation.Resource;
-
-/**
- * KeyStoreAuthenticator:
- *
- * @author: Jesse McConnell <jesse@codehaus.org>
- * @version: $Id$
- */
-@Service( "authenticator#keystore" )
-public class KeyStoreAuthenticator
-    implements Authenticator
-{
-    private Logger log = LoggerFactory.getLogger( getClass() );
-
-    @Resource( name = "keyManager#cached" )
-    private KeyManager keystore;
-
-    @Resource( name = "userManager#configurable" )
-    private UserManager userManager;
-
-    public String getId()
-    {
-        return "$Id$";
-    }
-
-    public AuthenticationResult authenticate( AuthenticationDataSource source )
-        throws AccountLockedException, AuthenticationException, MustChangePasswordException
-    {
-        TokenBasedAuthenticationDataSource dataSource = (TokenBasedAuthenticationDataSource) source;
-
-        String key = dataSource.getToken();
-        try
-        {
-            AuthenticationKey authKey = keystore.findKey( key );
-
-            // if we find a key (exception was probably thrown if not) then we should be authentic
-            if ( authKey != null )
-            {
-                User user = userManager.findUser( dataSource.getPrincipal() );
-
-                if ( user.isLocked() )
-                {
-                    throw new AccountLockedException( "Account " + source.getPrincipal() + " is locked.", user );
-                }
-
-                if ( user.isPasswordChangeRequired() && source.isEnforcePasswordChange() )
-                {
-                    throw new MustChangePasswordException( "Password expired.", user );
-                }
-
-                return new AuthenticationResult( true, dataSource.getPrincipal(), null );
-            }
-            else
-            {
-                return new AuthenticationResult( false, dataSource.getPrincipal(),
-                                                 new AuthenticationException( "unable to find key" ) );
-            }
-        }
-        catch ( KeyNotFoundException ne )
-        {
-            return new AuthenticationResult( false, null, ne );
-        }
-        catch ( KeyManagerException ke )
-        {
-            throw new AuthenticationException( "underlaying keymanager issue", ke );
-        }
-        catch ( UserNotFoundException e )
-        {
-            log.warn( "Login for user " + source.getPrincipal() + " failed. user not found." );
-            return new AuthenticationResult( false, null, e );
-        }
-    }
-
-    public boolean supportsDataSource( AuthenticationDataSource source )
-    {
-        return source instanceof TokenBasedAuthenticationDataSource;
-    }
-}
\ No newline at end of file
index 0b7db173fcd4e29230c552e5c1b1f95ba8b8177f..9f1df8757aecb62f46c4d5da28592ba59dc7cd6e 100644 (file)
@@ -29,6 +29,6 @@
 
   <context:annotation-config />
   <context:component-scan 
-    base-package="org.codehaus.plexus.redback.authentication.keystore"/>
+    base-package="org.apache.archiva.redback.authentication.keystore"/>
  
 </beans>
\ No newline at end of file