You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by ol...@apache.org on 2012/04/06 11:59:32 UTC
svn commit: r1310268 [38/42] - in /archiva/redback/redback-core/trunk: ./
redback-authentication/ redback-authentication/redback-authentication-api/
redback-authentication/redback-authentication-api/src/
redback-authentication/redback-authentication-ap...
Added: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-tests/src/main/java/org/codehaus/plexus/redback/tests/utils/RBACDefaults.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-tests/src/main/java/org/codehaus/plexus/redback/tests/utils/RBACDefaults.java?rev=1310268&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-tests/src/main/java/org/codehaus/plexus/redback/tests/utils/RBACDefaults.java (added)
+++ archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-tests/src/main/java/org/codehaus/plexus/redback/tests/utils/RBACDefaults.java Fri Apr 6 09:58:14 2012
@@ -0,0 +1,190 @@
+package org.codehaus.plexus.redback.tests.utils;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.codehaus.plexus.redback.rbac.Operation;
+import org.codehaus.plexus.redback.rbac.Permission;
+import org.codehaus.plexus.redback.rbac.RBACManager;
+import org.codehaus.plexus.redback.rbac.RbacManagerException;
+import org.codehaus.plexus.redback.rbac.Role;
+
+public class RBACDefaults
+{
+ private final RBACManager manager;
+
+ public RBACDefaults( RBACManager manager )
+ {
+ this.manager = manager;
+ }
+
+ public RBACManager createDefaults()
+ throws RbacManagerException
+ {
+ if ( !manager.operationExists( "add-repository" ) )
+ {
+ Operation operation = manager.createOperation( "add-repository" );
+ manager.saveOperation( operation );
+ }
+
+ if ( !manager.operationExists( "edit-repository" ) )
+ {
+ Operation operation = manager.createOperation( "edit-repository" );
+ manager.saveOperation( operation );
+ }
+
+ if ( !manager.operationExists( "delete-repository" ) )
+ {
+ Operation operation = manager.createOperation( "delete-repository" );
+ manager.saveOperation( operation );
+ }
+
+ if ( !manager.operationExists( "edit-configuration" ) )
+ {
+ Operation operation = manager.createOperation( "edit-configuration" );
+ manager.saveOperation( operation );
+ }
+
+ if ( !manager.operationExists( "run-indexer" ) )
+ {
+ Operation operation = manager.createOperation( "run-indexer" );
+ manager.saveOperation( operation );
+ }
+
+ if ( !manager.operationExists( "regenerate-index" ) )
+ {
+ Operation operation = manager.createOperation( "regenerate-index" );
+ manager.saveOperation( operation );
+ }
+
+ if ( !manager.operationExists( "get-reports" ) )
+ {
+ Operation operation = manager.createOperation( "get-reports" );
+ manager.saveOperation( operation );
+ }
+
+ if ( !manager.operationExists( "regenerate-reports" ) )
+ {
+ Operation operation = manager.createOperation( "regenerate-reports" );
+ manager.saveOperation( operation );
+ }
+
+ if ( !manager.operationExists( "edit-user" ) )
+ {
+ Operation operation = manager.createOperation( "edit-user" );
+ manager.saveOperation( operation );
+ }
+
+ if ( !manager.operationExists( "edit-all-users" ) )
+ {
+ Operation operation = manager.createOperation( "edit-all-users" );
+ manager.saveOperation( operation );
+ }
+
+ if ( !manager.operationExists( "remove-roles" ) )
+ {
+ Operation operation = manager.createOperation( "remove-roles" );
+ manager.saveOperation( operation );
+ }
+
+ if ( !manager.permissionExists( "Edit Configuration" ) )
+ {
+ Permission editConfiguration = manager.createPermission( "Edit Configuration", "edit-configuration",
+ manager.getGlobalResource().getIdentifier() );
+ manager.savePermission( editConfiguration );
+ }
+
+ if ( !manager.permissionExists( "Run Indexer" ) )
+ {
+ Permission runIndexer = manager.createPermission( "Run Indexer", "run-indexer", manager.getGlobalResource()
+ .getIdentifier() );
+
+ manager.savePermission( runIndexer );
+ }
+
+ if ( !manager.permissionExists( "Add Repository" ) )
+ {
+ Permission runIndexer = manager.createPermission( "Add Repository", "add-repository", manager
+ .getGlobalResource().getIdentifier() );
+ manager.savePermission( runIndexer );
+ }
+
+ if ( !manager.permissionExists( "Edit All Users" ) )
+ {
+ Permission editAllUsers = manager.createPermission( "Edit All Users", "edit-all-users", manager
+ .getGlobalResource().getIdentifier() );
+
+ manager.savePermission( editAllUsers );
+ }
+
+ if ( !manager.permissionExists( "Remove Roles" ) )
+ {
+ Permission editAllUsers = manager.createPermission( "Remove Roles", "remove-roles", manager
+ .getGlobalResource().getIdentifier() );
+
+ manager.savePermission( editAllUsers );
+ }
+
+ if ( !manager.permissionExists( "Regenerate Index" ) )
+ {
+ Permission regenIndex = manager.createPermission( "Regenerate Index", "regenerate-index", manager
+ .getGlobalResource().getIdentifier() );
+
+ manager.savePermission( regenIndex );
+ }
+
+ if ( !manager.roleExists( "User Administrator" ) )
+ {
+ Role userAdmin = manager.createRole( "User Administrator" );
+ userAdmin.addPermission( manager.getPermission( "Edit All Users" ) );
+ userAdmin.addPermission( manager.getPermission( "Remove Roles" ) );
+ userAdmin.setAssignable( true );
+ manager.saveRole( userAdmin );
+ }
+
+ if ( !manager.roleExists( "System Administrator" ) )
+ {
+ Role admin = manager.createRole( "System Administrator" );
+ admin.addChildRoleName( "User Administrator" );
+ admin.addPermission( manager.getPermission( "Edit Configuration" ) );
+ admin.addPermission( manager.getPermission( "Run Indexer" ) );
+ admin.addPermission( manager.getPermission( "Add Repository" ) );
+ admin.addPermission( manager.getPermission( "Regenerate Index" ) );
+ admin.setAssignable( true );
+ manager.saveRole( admin );
+ }
+
+ if ( !manager.roleExists( "Trusted Developer" ) )
+ {
+ Role developer = manager.createRole( "Trusted Developer" );
+ developer.addChildRoleName( "System Administrator" );
+ developer.addPermission( manager.getPermission( "Run Indexer" ) );
+ developer.setAssignable( true );
+ manager.saveRole( developer );
+ }
+
+ if ( !manager.roleExists( "Developer" ) )
+ {
+ Role developer = manager.createRole( "Developer" );
+ developer.addChildRoleName( "Trusted Developer" );
+ developer.addPermission( manager.getPermission( "Run Indexer" ) );
+ developer.setAssignable( true );
+ manager.saveRole( developer );
+ }
+
+ return manager;
+ }
+}
Propchange: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-tests/src/main/java/org/codehaus/plexus/redback/tests/utils/RBACDefaults.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-core/trunk/redback-rbac/redback-rbac-tests/src/main/java/org/codehaus/plexus/redback/tests/utils/RBACDefaults.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-core/trunk/redback-system/pom.xml
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-system/pom.xml?rev=1310268&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-system/pom.xml (added)
+++ archiva/redback/redback-core/trunk/redback-system/pom.xml Fri Apr 6 09:58:14 2012
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2006 The Codehaus.
+ ~
+ ~ Licensed 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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.codehaus.redback</groupId>
+ <artifactId>redback</artifactId>
+ <version>1.5-SNAPSHOT</version>
+ </parent>
+ <artifactId>redback-system</artifactId>
+ <name>Redback :: Core System</name>
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.redback</groupId>
+ <artifactId>redback-configuration</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.redback</groupId>
+ <artifactId>redback-authentication-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.redback</groupId>
+ <artifactId>redback-authorization-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.redback</groupId>
+ <artifactId>redback-users-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.redback</groupId>
+ <artifactId>redback-users-cached</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.redback</groupId>
+ <artifactId>redback-keys-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.redback</groupId>
+ <artifactId>redback-keys-cached</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context-support</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>jsr250-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.redback</groupId>
+ <artifactId>redback-authentication-memory</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
Propchange: archiva/redback/redback-core/trunk/redback-system/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-core/trunk/redback-system/pom.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-core/trunk/redback-system/src/main/java/org/codehaus/plexus/redback/system/DefaultSecuritySession.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-system/src/main/java/org/codehaus/plexus/redback/system/DefaultSecuritySession.java?rev=1310268&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-system/src/main/java/org/codehaus/plexus/redback/system/DefaultSecuritySession.java (added)
+++ archiva/redback/redback-core/trunk/redback-system/src/main/java/org/codehaus/plexus/redback/system/DefaultSecuritySession.java Fri Apr 6 09:58:14 2012
@@ -0,0 +1,74 @@
+package org.codehaus.plexus.redback.system;
+
+/*
+ * Copyright 2005 The Codehaus.
+ *
+ * Licensed 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.codehaus.plexus.redback.authentication.AuthenticationResult;
+import org.codehaus.plexus.redback.users.User;
+import org.springframework.stereotype.Service;
+
+import java.io.Serializable;
+
+/**
+ * @author Jason van Zyl
+ */
+@Service( "securitySession" )
+public class DefaultSecuritySession
+ implements SecuritySession, Serializable
+{
+ private AuthenticationResult authenticationResult;
+
+ private User user;
+
+ // TODO: ambiguity between this authenticated and authentication result's authenticated is dangerous
+ private boolean authenticated;
+
+ public DefaultSecuritySession()
+ {
+ this.authenticationResult = new AuthenticationResult();
+ this.user = null;
+ this.authenticated = false;
+ }
+
+ public DefaultSecuritySession( AuthenticationResult authResult )
+ {
+ this.authenticationResult = authResult;
+ this.user = null;
+ this.authenticated = false;
+ }
+
+ public DefaultSecuritySession( AuthenticationResult authenticationResult, User user )
+ {
+ this.authenticationResult = authenticationResult;
+ this.user = user;
+ this.authenticated = true;
+ }
+
+ public AuthenticationResult getAuthenticationResult()
+ {
+ return authenticationResult;
+ }
+
+ public User getUser()
+ {
+ return user;
+ }
+
+ public boolean isAuthenticated()
+ {
+ return ( ( user != null ) && authenticated );
+ }
+}
Propchange: archiva/redback/redback-core/trunk/redback-system/src/main/java/org/codehaus/plexus/redback/system/DefaultSecuritySession.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-core/trunk/redback-system/src/main/java/org/codehaus/plexus/redback/system/DefaultSecuritySession.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-core/trunk/redback-system/src/main/java/org/codehaus/plexus/redback/system/DefaultSecuritySystem.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-system/src/main/java/org/codehaus/plexus/redback/system/DefaultSecuritySystem.java?rev=1310268&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-system/src/main/java/org/codehaus/plexus/redback/system/DefaultSecuritySystem.java (added)
+++ archiva/redback/redback-core/trunk/redback-system/src/main/java/org/codehaus/plexus/redback/system/DefaultSecuritySystem.java Fri Apr 6 09:58:14 2012
@@ -0,0 +1,279 @@
+package org.codehaus.plexus.redback.system;
+
+/*
+ * Copyright 2005 The Codehaus.
+ *
+ * Licensed 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.codehaus.plexus.redback.authentication.AuthenticationDataSource;
+import org.codehaus.plexus.redback.authentication.AuthenticationException;
+import org.codehaus.plexus.redback.authentication.AuthenticationManager;
+import org.codehaus.plexus.redback.authentication.AuthenticationResult;
+import org.codehaus.plexus.redback.authorization.AuthorizationDataSource;
+import org.codehaus.plexus.redback.authorization.AuthorizationException;
+import org.codehaus.plexus.redback.authorization.AuthorizationResult;
+import org.codehaus.plexus.redback.authorization.Authorizer;
+import org.codehaus.plexus.redback.keys.KeyManager;
+import org.codehaus.plexus.redback.policy.AccountLockedException;
+import org.codehaus.plexus.redback.policy.MustChangePasswordException;
+import org.codehaus.plexus.redback.policy.UserSecurityPolicy;
+import org.codehaus.plexus.redback.users.User;
+import org.codehaus.plexus.redback.users.UserManager;
+import org.codehaus.plexus.redback.users.UserNotFoundException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+/**
+ * DefaultSecuritySystem:
+ *
+ * @author: Jesse McConnell <je...@codehaus.org>
+ * @version: $Id$
+ */
+@Service( "securitySystem" )
+public class DefaultSecuritySystem
+ implements SecuritySystem
+{
+ private Logger log = LoggerFactory.getLogger( DefaultSecuritySystem.class );
+
+ @Inject
+ private AuthenticationManager authnManager;
+
+ @Inject
+ @Named( value = "authorizer#rbac" )
+ private Authorizer authorizer;
+
+ @Inject
+ @Named( value = "userManager#configurable" )
+ private UserManager userManager;
+
+ @Inject
+ @Named( value = "keyManager#cached" )
+ private KeyManager keyManager;
+
+ @Inject
+ private UserSecurityPolicy policy;
+
+ // ----------------------------------------------------------------------------
+ // Authentication: delegate to the authnManager
+ // ----------------------------------------------------------------------------
+
+ /**
+ * delegate to the authentication system for boolean authentication checks,
+ * if the result is authentic then pull the user object from the user
+ * manager and add it to the session. If the result is false return the result in
+ * an authenticated session and a null user object.
+ * <p/>
+ * in the event of a successful authentication and a lack of corresponding user in the
+ * usermanager return a null user as well
+ * <p/>
+ * //todo should this last case create a user in the usermanager?
+ *
+ * @param source
+ * @return
+ * @throws AuthenticationException
+ * @throws UserNotFoundException
+ * @throws MustChangePasswordException
+ * @throws AccountLockedException
+ * @throws MustChangePasswordException
+ */
+ public SecuritySession authenticate( AuthenticationDataSource source )
+ throws AuthenticationException, UserNotFoundException, AccountLockedException, MustChangePasswordException
+ {
+ // Perform Authentication.
+ AuthenticationResult result = authnManager.authenticate( source );
+
+ log.debug( "authnManager.authenticate() result: {}", result );
+
+ // Process Results.
+ if ( result.isAuthenticated() )
+ {
+ log.debug( "User '{}' authenticated.", result.getPrincipal());
+ User user = userManager.findUser( result.getPrincipal() );
+ if ( user != null )
+ {
+ log.debug( "User '{}' exists.", result.getPrincipal() );
+ log.debug( "User: {}", user );
+ return new DefaultSecuritySession( result, user );
+ }
+ else
+ {
+ log.debug( "User '{}' DOES NOT exist.", result.getPrincipal() );
+ return new DefaultSecuritySession( result );
+ }
+ }
+ else
+ {
+ log.debug( "User '{}' IS NOT authenticated.", result.getPrincipal() );
+ return new DefaultSecuritySession( result );
+ }
+ }
+
+ public boolean isAuthenticated( AuthenticationDataSource source )
+ throws AuthenticationException, UserNotFoundException, AccountLockedException, MustChangePasswordException
+ {
+ return authenticate( source ).getAuthenticationResult().isAuthenticated();
+ }
+
+ public String getAuthenticatorId()
+ {
+ if ( authnManager == null )
+ {
+ return "<null>";
+ }
+ return authnManager.getId();
+ }
+
+ // ----------------------------------------------------------------------------
+ // Authorization: delegate to the authorizer
+ // ----------------------------------------------------------------------------
+
+ public AuthorizationResult authorize( SecuritySession session, Object permission )
+ throws AuthorizationException
+ {
+ return authorize( session, permission, null );
+ }
+
+ public AuthorizationResult authorize( SecuritySession session, Object permission, Object resource )
+ throws AuthorizationException
+ {
+ AuthorizationDataSource source = null;
+
+ if ( session != null )
+ {
+ User user = session.getUser();
+ if ( user != null )
+ {
+ source = new AuthorizationDataSource( user.getPrincipal(), user, permission, resource );
+ }
+ }
+
+ if ( source == null )
+ {
+ source = new AuthorizationDataSource( null, null, permission, resource );
+ }
+
+ return authorizer.isAuthorized( source );
+ }
+
+ public boolean isAuthorized( SecuritySession session, Object permission )
+ throws AuthorizationException
+ {
+ return isAuthorized( session, permission, null );
+ }
+
+ public boolean isAuthorized( SecuritySession session, Object permission, Object resource )
+ throws AuthorizationException
+ {
+ return authorize( session, permission, resource ).isAuthorized();
+ }
+
+ public String getAuthorizerId()
+ {
+ if ( authorizer == null )
+ {
+ return "<null>";
+ }
+ return authorizer.getId();
+ }
+
+ // ----------------------------------------------------------------------------
+ // User Management: delegate to the user manager
+ // ----------------------------------------------------------------------------
+
+ public UserManager getUserManager()
+ {
+ return userManager;
+ }
+
+ public String getUserManagementId()
+ {
+ if ( userManager == null )
+ {
+ return "<null>";
+ }
+ return userManager.getId();
+ }
+
+ public KeyManager getKeyManager()
+ {
+ return keyManager;
+ }
+
+ public String getKeyManagementId()
+ {
+ if ( keyManager == null )
+ {
+ return "<null>";
+ }
+ return keyManager.getId();
+ }
+
+ public UserSecurityPolicy getPolicy()
+ {
+ return policy;
+ }
+
+ public String getPolicyId()
+ {
+ if ( policy == null )
+ {
+ return "<null>";
+ }
+ return policy.getId();
+ }
+
+ public AuthenticationManager getAuthenticationManager()
+ {
+ return authnManager;
+ }
+
+ public Authorizer getAuthorizer()
+ {
+ return authorizer;
+ }
+
+ public AuthenticationManager getAuthnManager()
+ {
+ return authnManager;
+ }
+
+ public void setAuthnManager( AuthenticationManager authnManager )
+ {
+ this.authnManager = authnManager;
+ }
+
+ public void setAuthorizer( Authorizer authorizer )
+ {
+ this.authorizer = authorizer;
+ }
+
+ public void setUserManager( UserManager userManager )
+ {
+ this.userManager = userManager;
+ }
+
+ public void setKeyManager( KeyManager keyManager )
+ {
+ this.keyManager = keyManager;
+ }
+
+ public void setPolicy( UserSecurityPolicy policy )
+ {
+ this.policy = policy;
+ }
+}
Propchange: archiva/redback/redback-core/trunk/redback-system/src/main/java/org/codehaus/plexus/redback/system/DefaultSecuritySystem.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-core/trunk/redback-system/src/main/java/org/codehaus/plexus/redback/system/DefaultSecuritySystem.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-core/trunk/redback-system/src/main/java/org/codehaus/plexus/redback/system/SecuritySession.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-system/src/main/java/org/codehaus/plexus/redback/system/SecuritySession.java?rev=1310268&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-system/src/main/java/org/codehaus/plexus/redback/system/SecuritySession.java (added)
+++ archiva/redback/redback-core/trunk/redback-system/src/main/java/org/codehaus/plexus/redback/system/SecuritySession.java Fri Apr 6 09:58:14 2012
@@ -0,0 +1,40 @@
+package org.codehaus.plexus.redback.system;
+
+/*
+ * Copyright 2001-2006 The Codehaus.
+ *
+ * Licensed 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.codehaus.plexus.redback.authentication.AuthenticationResult;
+import org.codehaus.plexus.redback.users.User;
+
+import java.io.Serializable;
+
+/**
+ * @author Jason van Zyl
+ */
+public interface SecuritySession
+ extends Serializable
+{
+
+ static final String SESSION_KEY = SecuritySession.class.getName();
+
+ static final String USERKEY = "SecuritySessionUser";
+
+ AuthenticationResult getAuthenticationResult();
+
+ User getUser();
+
+ boolean isAuthenticated();
+}
Propchange: archiva/redback/redback-core/trunk/redback-system/src/main/java/org/codehaus/plexus/redback/system/SecuritySession.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-core/trunk/redback-system/src/main/java/org/codehaus/plexus/redback/system/SecuritySession.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-core/trunk/redback-system/src/main/java/org/codehaus/plexus/redback/system/SecuritySystem.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-system/src/main/java/org/codehaus/plexus/redback/system/SecuritySystem.java?rev=1310268&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-system/src/main/java/org/codehaus/plexus/redback/system/SecuritySystem.java (added)
+++ archiva/redback/redback-core/trunk/redback-system/src/main/java/org/codehaus/plexus/redback/system/SecuritySystem.java Fri Apr 6 09:58:14 2012
@@ -0,0 +1,96 @@
+package org.codehaus.plexus.redback.system;
+
+/*
+ * Copyright 2005 The Codehaus.
+ *
+ * Licensed 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.codehaus.plexus.redback.authentication.AuthenticationDataSource;
+import org.codehaus.plexus.redback.authentication.AuthenticationException;
+import org.codehaus.plexus.redback.authorization.AuthorizationException;
+import org.codehaus.plexus.redback.authorization.AuthorizationResult;
+import org.codehaus.plexus.redback.keys.KeyManager;
+import org.codehaus.plexus.redback.policy.AccountLockedException;
+import org.codehaus.plexus.redback.policy.MustChangePasswordException;
+import org.codehaus.plexus.redback.policy.UserSecurityPolicy;
+import org.codehaus.plexus.redback.users.UserManager;
+import org.codehaus.plexus.redback.users.UserNotFoundException;
+
+/**
+ * SecuritySystem:
+ *
+ * @author: Jesse McConnell <je...@codehaus.org>
+ * @version: $ID:$
+ *
+ */
+public interface SecuritySystem
+{
+
+ // ----------------------------------------------------------------------------
+ // Authentication
+ // ----------------------------------------------------------------------------
+
+ SecuritySession authenticate( AuthenticationDataSource source )
+ throws AuthenticationException, UserNotFoundException, AccountLockedException, MustChangePasswordException;
+
+ boolean isAuthenticated( AuthenticationDataSource source )
+ throws AuthenticationException, UserNotFoundException, AccountLockedException, MustChangePasswordException;
+
+ // ----------------------------------------------------------------------------
+ // Authorization
+ // ----------------------------------------------------------------------------
+
+ AuthorizationResult authorize( SecuritySession session, Object permission )
+ throws AuthorizationException;
+
+ boolean isAuthorized( SecuritySession session, Object permission )
+ throws AuthorizationException;
+
+ /**
+ * return AuthorizationResult without changing authorization
+ * @param session
+ * @param permission
+ * @param resource
+ * @return
+ * @throws AuthorizationException
+ */
+ AuthorizationResult authorize( SecuritySession session, Object permission, Object resource )
+ throws AuthorizationException;
+
+ boolean isAuthorized( SecuritySession session, Object permission, Object resource )
+ throws AuthorizationException;
+
+ // ----------------------------------------------------------------------------
+ // User Management
+ // ----------------------------------------------------------------------------
+
+ UserManager getUserManager();
+
+ // ----------------------------------------------------------------------------
+ // Key Management
+ // ----------------------------------------------------------------------------
+
+ KeyManager getKeyManager();
+
+ // ----------------------------------------------------------------------------
+ // Policy Management
+ // ----------------------------------------------------------------------------
+
+ UserSecurityPolicy getPolicy();
+
+ String getUserManagementId();
+ String getAuthenticatorId();
+ String getAuthorizerId();
+}
+
Propchange: archiva/redback/redback-core/trunk/redback-system/src/main/java/org/codehaus/plexus/redback/system/SecuritySystem.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-core/trunk/redback-system/src/main/java/org/codehaus/plexus/redback/system/SecuritySystem.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-core/trunk/redback-system/src/main/java/org/codehaus/plexus/redback/system/SecuritySystemConstants.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-system/src/main/java/org/codehaus/plexus/redback/system/SecuritySystemConstants.java?rev=1310268&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-system/src/main/java/org/codehaus/plexus/redback/system/SecuritySystemConstants.java (added)
+++ archiva/redback/redback-core/trunk/redback-system/src/main/java/org/codehaus/plexus/redback/system/SecuritySystemConstants.java Fri Apr 6 09:58:14 2012
@@ -0,0 +1,36 @@
+package org.codehaus.plexus.redback.system;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+/**
+ * SecuritySystemConstants - constants for use with contexts that use plexus-security.
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class SecuritySystemConstants
+{
+ /**
+ * Key in the sessionScope for the {@link SecuritySession} object.
+ */
+ public static final String SECURITY_SESSION_KEY = "securitySession";
+
+ private SecuritySystemConstants()
+ {
+ // no op
+ }
+}
Propchange: archiva/redback/redback-core/trunk/redback-system/src/main/java/org/codehaus/plexus/redback/system/SecuritySystemConstants.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-core/trunk/redback-system/src/main/java/org/codehaus/plexus/redback/system/SecuritySystemConstants.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-core/trunk/redback-system/src/main/java/org/codehaus/plexus/redback/system/check/EnvironmentCheck.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-system/src/main/java/org/codehaus/plexus/redback/system/check/EnvironmentCheck.java?rev=1310268&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-system/src/main/java/org/codehaus/plexus/redback/system/check/EnvironmentCheck.java (added)
+++ archiva/redback/redback-core/trunk/redback-system/src/main/java/org/codehaus/plexus/redback/system/check/EnvironmentCheck.java Fri Apr 6 09:58:14 2012
@@ -0,0 +1,36 @@
+package org.codehaus.plexus.redback.system.check;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed 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 java.util.List;
+
+/**
+ * EnvironmentCheck - Perform an Environment Check.
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public interface EnvironmentCheck
+{
+
+ /**
+ * Validate the environment.
+ *
+ * @param violations list to populate with environment violations.
+ */
+ void validateEnvironment( List<String> violations );
+}
Propchange: archiva/redback/redback-core/trunk/redback-system/src/main/java/org/codehaus/plexus/redback/system/check/EnvironmentCheck.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-core/trunk/redback-system/src/main/java/org/codehaus/plexus/redback/system/check/EnvironmentCheck.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-core/trunk/redback-system/src/main/resources/META-INF/spring-context.xml
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-system/src/main/resources/META-INF/spring-context.xml?rev=1310268&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-system/src/main/resources/META-INF/spring-context.xml (added)
+++ archiva/redback/redback-core/trunk/redback-system/src/main/resources/META-INF/spring-context.xml Fri Apr 6 09:58:14 2012
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+
+<!--
+ ~ 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.
+ -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ http://www.springframework.org/schema/context
+ http://www.springframework.org/schema/context/spring-context-3.0.xsd"
+ default-lazy-init="true">
+
+ <context:annotation-config />
+ <context:component-scan base-package="org.codehaus.plexus.redback.system"/>
+
+</beans>
\ No newline at end of file
Propchange: archiva/redback/redback-core/trunk/redback-system/src/main/resources/META-INF/spring-context.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-core/trunk/redback-system/src/main/resources/META-INF/spring-context.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-core/trunk/redback-system/src/test/java/org/codehaus/plexus/redback/system/DefaultSecureApplication.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-system/src/test/java/org/codehaus/plexus/redback/system/DefaultSecureApplication.java?rev=1310268&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-system/src/test/java/org/codehaus/plexus/redback/system/DefaultSecureApplication.java (added)
+++ archiva/redback/redback-core/trunk/redback-system/src/test/java/org/codehaus/plexus/redback/system/DefaultSecureApplication.java Fri Apr 6 09:58:14 2012
@@ -0,0 +1,9 @@
+package org.codehaus.plexus.redback.system;
+
+/**
+ * @author Jason van Zyl
+ */
+public class DefaultSecureApplication
+ implements SecureApplication
+{
+}
Propchange: archiva/redback/redback-core/trunk/redback-system/src/test/java/org/codehaus/plexus/redback/system/DefaultSecureApplication.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-core/trunk/redback-system/src/test/java/org/codehaus/plexus/redback/system/DefaultSecureApplication.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-core/trunk/redback-system/src/test/java/org/codehaus/plexus/redback/system/SecureApplication.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-system/src/test/java/org/codehaus/plexus/redback/system/SecureApplication.java?rev=1310268&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-system/src/test/java/org/codehaus/plexus/redback/system/SecureApplication.java (added)
+++ archiva/redback/redback-core/trunk/redback-system/src/test/java/org/codehaus/plexus/redback/system/SecureApplication.java Fri Apr 6 09:58:14 2012
@@ -0,0 +1,9 @@
+package org.codehaus.plexus.redback.system;
+
+/**
+ * @author Jason van Zyl
+ */
+public interface SecureApplication
+{
+ String ROLE = SecureApplication.class.getName();
+}
Propchange: archiva/redback/redback-core/trunk/redback-system/src/test/java/org/codehaus/plexus/redback/system/SecureApplication.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-core/trunk/redback-system/src/test/java/org/codehaus/plexus/redback/system/SecureApplication.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-core/trunk/redback-system/src/test/java/org/codehaus/plexus/redback/system/TestAuthenticationManager.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-system/src/test/java/org/codehaus/plexus/redback/system/TestAuthenticationManager.java?rev=1310268&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-system/src/test/java/org/codehaus/plexus/redback/system/TestAuthenticationManager.java (added)
+++ archiva/redback/redback-core/trunk/redback-system/src/test/java/org/codehaus/plexus/redback/system/TestAuthenticationManager.java Fri Apr 6 09:58:14 2012
@@ -0,0 +1,49 @@
+package org.codehaus.plexus.redback.system;
+
+import junit.framework.TestCase;
+import org.codehaus.plexus.redback.authentication.AuthenticationManager;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import javax.inject.Inject;
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+/**
+ * TestAuthenticationManager:
+ *
+ * @author: Jesse McConnell <je...@codehaus.org>
+ * @version: $ID:$
+ */
+@RunWith( SpringJUnit4ClassRunner.class )
+@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" } )
+public class TestAuthenticationManager
+ extends TestCase
+{
+
+ @Inject
+ AuthenticationManager authManager;
+
+ @Test
+ public void testAuthenticatorPopulation()
+ throws Exception
+ {
+ assertEquals( 1, authManager.getAuthenticators().size() );
+ }
+
+}
Propchange: archiva/redback/redback-core/trunk/redback-system/src/test/java/org/codehaus/plexus/redback/system/TestAuthenticationManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-core/trunk/redback-system/src/test/java/org/codehaus/plexus/redback/system/TestAuthenticationManager.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-core/trunk/redback-system/src/test/resources/spring-context.xml
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-system/src/test/resources/spring-context.xml?rev=1310268&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-system/src/test/resources/spring-context.xml (added)
+++ archiva/redback/redback-core/trunk/redback-system/src/test/resources/spring-context.xml Fri Apr 6 09:58:14 2012
@@ -0,0 +1,51 @@
+<?xml version="1.0"?>
+
+<!--
+ ~ 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.
+ -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ http://www.springframework.org/schema/context
+ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
+
+ <bean name="jdoFactory#users" class="org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory">
+ <property name="driverName" value="org.hsqldb.jdbcDriver"/>
+ <property name="url" value="jdbc:hsqldb:mem:redback-users-tests" />
+ <property name="userName" value="sa"/>
+ <property name="password" value=""/>
+ <property name="persistenceManagerFactoryClass" value="org.jpox.PersistenceManagerFactoryImpl"/>
+ <property name="otherProperties">
+ <props>
+ <prop key="org.jpox.rdbms.dateTimezone">JDK_DEFAULT_TIMEZONE</prop>
+ </props>
+ </property>
+ </bean>
+
+ <bean name="userConfiguration" class="org.codehaus.plexus.redback.configuration.UserConfiguration">
+ <property name="registry" ref="test-conf"/>
+ </bean>
+
+ <bean name="commons-configuration" class="org.codehaus.redback.components.registry.commons.CommonsConfigurationRegistry">
+ </bean>
+
+ <alias name="commons-configuration" alias="test-conf"/>
+
+</beans>
\ No newline at end of file
Propchange: archiva/redback/redback-core/trunk/redback-system/src/test/resources/spring-context.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-core/trunk/redback-system/src/test/resources/spring-context.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-core/trunk/redback-users/pom.xml
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-users/pom.xml?rev=1310268&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-users/pom.xml (added)
+++ archiva/redback/redback-core/trunk/redback-users/pom.xml Fri Apr 6 09:58:14 2012
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2006 The Codehaus.
+ ~
+ ~ Licensed 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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.codehaus.redback</groupId>
+ <artifactId>redback</artifactId>
+ <version>1.5-SNAPSHOT</version>
+ </parent>
+ <artifactId>redback-users</artifactId>
+ <name>Redback :: User Management</name>
+ <packaging>pom</packaging>
+ <modules>
+ <module>redback-users-api</module>
+ <module>redback-users-providers</module>
+ <module>redback-users-tests</module>
+ <module>redback-authentication-users</module>
+ </modules>
+</project>
Propchange: archiva/redback/redback-core/trunk/redback-users/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-core/trunk/redback-users/pom.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-core/trunk/redback-users/redback-authentication-users/pom.xml
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-users/redback-authentication-users/pom.xml?rev=1310268&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-users/redback-authentication-users/pom.xml (added)
+++ archiva/redback/redback-core/trunk/redback-users/redback-authentication-users/pom.xml Fri Apr 6 09:58:14 2012
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2006 The Codehaus.
+ ~
+ ~ Licensed 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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.codehaus.redback</groupId>
+ <artifactId>redback-authentication-providers</artifactId>
+ <version>1.5-SNAPSHOT</version>
+ <relativePath>../../redback-authentication/redback-authentication-providers/pom.xml</relativePath>
+ </parent>
+ <artifactId>redback-authentication-users</artifactId>
+ <name>Redback :: Authentication Provider :: Users</name>
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.redback</groupId>
+ <artifactId>redback-authentication-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.redback</groupId>
+ <artifactId>redback-policy</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.redback</groupId>
+ <artifactId>redback-users-configurable</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.redback</groupId>
+ <artifactId>redback-users-cached</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context-support</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>jsr250-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.redback</groupId>
+ <artifactId>redback-users-memory</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
Propchange: archiva/redback/redback-core/trunk/redback-users/redback-authentication-users/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-core/trunk/redback-users/redback-authentication-users/pom.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-core/trunk/redback-users/redback-authentication-users/src/main/java/org/codehaus/plexus/redback/authentication/users/UserManagerAuthenticator.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-users/redback-authentication-users/src/main/java/org/codehaus/plexus/redback/authentication/users/UserManagerAuthenticator.java?rev=1310268&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-users/redback-authentication-users/src/main/java/org/codehaus/plexus/redback/authentication/users/UserManagerAuthenticator.java (added)
+++ archiva/redback/redback-core/trunk/redback-users/redback-authentication-users/src/main/java/org/codehaus/plexus/redback/authentication/users/UserManagerAuthenticator.java Fri Apr 6 09:58:14 2012
@@ -0,0 +1,194 @@
+package org.codehaus.plexus.redback.authentication.users;
+
+/*
+ * Copyright 2005 The Codehaus.
+ *
+ * Licensed 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.codehaus.plexus.redback.authentication.AuthenticationConstants;
+import org.codehaus.plexus.redback.authentication.AuthenticationDataSource;
+import org.codehaus.plexus.redback.authentication.AuthenticationException;
+import org.codehaus.plexus.redback.authentication.AuthenticationResult;
+import org.codehaus.plexus.redback.authentication.Authenticator;
+import org.codehaus.plexus.redback.authentication.PasswordBasedAuthenticationDataSource;
+import org.codehaus.plexus.redback.policy.AccountLockedException;
+import org.codehaus.plexus.redback.policy.MustChangePasswordException;
+import org.codehaus.plexus.redback.policy.PasswordEncoder;
+import org.codehaus.plexus.redback.policy.PolicyViolationException;
+import org.codehaus.plexus.redback.policy.UserSecurityPolicy;
+import org.codehaus.plexus.redback.users.User;
+import org.codehaus.plexus.redback.users.UserManager;
+import org.codehaus.plexus.redback.users.UserNotFoundException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Named;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * {@link Authenticator} implementation that uses a wrapped {@link UserManager} to authenticate.
+ *
+ * @author <a href='mailto:rahul.thakur.xdev@gmail.com'>Rahul Thakur</a>
+ * @version $Id$
+ */
+@Service( "authenticator#user-manager" )
+public class UserManagerAuthenticator
+ implements Authenticator
+{
+ private Logger log = LoggerFactory.getLogger( UserManagerAuthenticator.class );
+
+ @Inject
+ @Named( value = "userManager#jdo" )
+ private UserManager userManager;
+
+ @Inject
+ private UserSecurityPolicy securityPolicy;
+
+ public String getId()
+ {
+ return "UserManagerAuthenticator";
+ }
+
+ /**
+ * @throws org.codehaus.plexus.redback.policy.AccountLockedException
+ *
+ * @throws MustChangePasswordException
+ * @throws MustChangePasswordException
+ * @throws PolicyViolationException
+ * @see org.codehaus.plexus.redback.authentication.Authenticator#authenticate(org.codehaus.plexus.redback.authentication.AuthenticationDataSource)
+ */
+ public AuthenticationResult authenticate( AuthenticationDataSource ds )
+ throws AuthenticationException, AccountLockedException, MustChangePasswordException
+ {
+ boolean authenticationSuccess = false;
+ String username = null;
+ Exception resultException = null;
+ PasswordBasedAuthenticationDataSource source = (PasswordBasedAuthenticationDataSource) ds;
+ Map<String, String> authnResultExceptionsMap = new HashMap<String, String>();
+
+ try
+ {
+ log.debug( "Authenticate: {}", source );
+ User user = userManager.findUser( source.getPrincipal() );
+ username = user.getUsername();
+
+ if ( user.isLocked() )
+ {
+ throw new AccountLockedException( "Account " + source.getPrincipal() + " is locked.", user );
+ }
+
+ if ( user.isPasswordChangeRequired() && source.isEnforcePasswordChange() )
+ {
+ throw new MustChangePasswordException( "Password expired.", user );
+ }
+
+ PasswordEncoder encoder = securityPolicy.getPasswordEncoder();
+ log.debug( "PasswordEncoder: {}", encoder.getClass().getName() );
+
+ boolean isPasswordValid = encoder.isPasswordValid( user.getEncodedPassword(), source.getPassword() );
+ if ( isPasswordValid )
+ {
+ log.debug( "User {} provided a valid password", source.getPrincipal() );
+
+ try
+ {
+ securityPolicy.extensionPasswordExpiration( user );
+ }
+ catch ( MustChangePasswordException e )
+ {
+ user.setPasswordChangeRequired( true );
+ throw e;
+ }
+
+ authenticationSuccess = true;
+
+ //REDBACK-151 do not make unnessesary updates to the user object
+ if ( user.getCountFailedLoginAttempts() > 0 )
+ {
+ user.setCountFailedLoginAttempts( 0 );
+ userManager.updateUser( user );
+ }
+
+ return new AuthenticationResult( true, source.getPrincipal(), null );
+ }
+ else
+ {
+ log.warn( "Password is Invalid for user " + source.getPrincipal() + "." );
+ authnResultExceptionsMap.put( AuthenticationConstants.AUTHN_NO_SUCH_USER,
+ "Password is Invalid for user " + source.getPrincipal() + "." );
+
+ try
+ {
+ securityPolicy.extensionExcessiveLoginAttempts( user );
+ }
+ finally
+ {
+ userManager.updateUser( user );
+ }
+
+ return new AuthenticationResult( false, source.getPrincipal(), null, authnResultExceptionsMap );
+ }
+ }
+ catch ( UserNotFoundException e )
+ {
+ log.warn( "Login for user " + source.getPrincipal() + " failed. user not found." );
+ resultException = e;
+ authnResultExceptionsMap.put( AuthenticationConstants.AUTHN_NO_SUCH_USER,
+ "Login for user \" + source.getPrincipal() + \" failed. user not found." );
+ }
+
+ return new AuthenticationResult( authenticationSuccess, username, resultException, authnResultExceptionsMap );
+ }
+
+ /**
+ * Returns the wrapped {@link UserManager} used by this {@link Authenticator}
+ * implementation for authentication.
+ *
+ * @return the userManager
+ */
+ public UserManager getUserManager()
+ {
+ return userManager;
+ }
+
+ /**
+ * Sets a {@link UserManager} to be used by this {@link Authenticator}
+ * implementation for authentication.
+ *
+ * @param userManager the userManager to set
+ */
+ public void setUserManager( UserManager userManager )
+ {
+ this.userManager = userManager;
+ }
+
+ public boolean supportsDataSource( AuthenticationDataSource source )
+ {
+ return ( source instanceof PasswordBasedAuthenticationDataSource );
+ }
+
+ public UserSecurityPolicy getSecurityPolicy()
+ {
+ return securityPolicy;
+ }
+
+ public void setSecurityPolicy( UserSecurityPolicy securityPolicy )
+ {
+ this.securityPolicy = securityPolicy;
+ }
+}
Propchange: archiva/redback/redback-core/trunk/redback-users/redback-authentication-users/src/main/java/org/codehaus/plexus/redback/authentication/users/UserManagerAuthenticator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-core/trunk/redback-users/redback-authentication-users/src/main/java/org/codehaus/plexus/redback/authentication/users/UserManagerAuthenticator.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-core/trunk/redback-users/redback-authentication-users/src/main/resources/META-INF/spring-context.xml
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-users/redback-authentication-users/src/main/resources/META-INF/spring-context.xml?rev=1310268&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-users/redback-authentication-users/src/main/resources/META-INF/spring-context.xml (added)
+++ archiva/redback/redback-core/trunk/redback-users/redback-authentication-users/src/main/resources/META-INF/spring-context.xml Fri Apr 6 09:58:14 2012
@@ -0,0 +1,34 @@
+<?xml version="1.0"?>
+
+<!--
+ ~ 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.
+ -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ http://www.springframework.org/schema/context
+ http://www.springframework.org/schema/context/spring-context-3.0.xsd"
+ default-lazy-init="true">
+
+ <context:annotation-config />
+ <context:component-scan
+ base-package="org.codehaus.plexus.redback.authentication.users"/>
+
+</beans>
\ No newline at end of file
Propchange: archiva/redback/redback-core/trunk/redback-users/redback-authentication-users/src/main/resources/META-INF/spring-context.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-core/trunk/redback-users/redback-authentication-users/src/main/resources/META-INF/spring-context.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-core/trunk/redback-users/redback-authentication-users/src/test/java/org/codehaus/plexus/redback/authentication/users/UserManagerAuthenticatorTest.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-users/redback-authentication-users/src/test/java/org/codehaus/plexus/redback/authentication/users/UserManagerAuthenticatorTest.java?rev=1310268&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-users/redback-authentication-users/src/test/java/org/codehaus/plexus/redback/authentication/users/UserManagerAuthenticatorTest.java (added)
+++ archiva/redback/redback-core/trunk/redback-users/redback-authentication-users/src/test/java/org/codehaus/plexus/redback/authentication/users/UserManagerAuthenticatorTest.java Fri Apr 6 09:58:14 2012
@@ -0,0 +1,211 @@
+package org.codehaus.plexus.redback.authentication.users;
+
+/*
+ * Copyright 2005 The Codehaus.
+ *
+ * Licensed 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 junit.framework.TestCase;
+import org.codehaus.plexus.redback.authentication.AuthenticationException;
+import org.codehaus.plexus.redback.authentication.AuthenticationResult;
+import org.codehaus.plexus.redback.authentication.Authenticator;
+import org.codehaus.plexus.redback.authentication.PasswordBasedAuthenticationDataSource;
+import org.codehaus.plexus.redback.policy.AccountLockedException;
+import org.codehaus.plexus.redback.policy.MustChangePasswordException;
+import org.codehaus.plexus.redback.policy.UserSecurityPolicy;
+import org.codehaus.plexus.redback.users.User;
+import org.codehaus.plexus.redback.users.UserManager;
+import org.codehaus.plexus.redback.users.UserNotFoundException;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import java.util.Calendar;
+import java.util.Date;
+
+/**
+ * Tests for {@link UserManagerAuthenticator} implementation.
+ *
+ * @author <a href='mailto:rahul.thakur.xdev@gmail.com'>Rahul Thakur</a>
+ */
+@RunWith( SpringJUnit4ClassRunner.class )
+@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" } )
+public class UserManagerAuthenticatorTest
+ extends TestCase
+{
+ @Inject
+ private UserSecurityPolicy userSecurityPolicy;
+
+ @Inject
+ @Named(value = "authenticator#user-manager")
+ Authenticator component;
+
+ @Inject
+ @Named(value = "userManager#memory")
+ UserManager um;
+
+ @Before
+ public void setUp()
+ throws Exception
+ {
+ super.setUp();
+ userSecurityPolicy.setEnabled( false );
+ }
+
+ @Test
+ public void testLookup()
+ throws Exception
+ {
+ assertNotNull( component );
+ assertEquals( UserManagerAuthenticator.class.getName(), component.getClass().getName() );
+ }
+
+ @Test
+ public void testAuthenticate()
+ throws Exception
+ {
+ // Set up a few users for the Authenticator
+
+ User user = um.createUser( "test", "Test User", "testuser@somedomain.com" );
+ user.setPassword( "testpass" );
+ um.addUser( user );
+
+ user = um.createUser( "guest", "Guest User", "testuser@somedomain.com" );
+ user.setPassword( "guestpass" );
+ um.addUser( user );
+
+ user = um.createUser( "anonymous", "Anonymous User", "testuser@somedomain.com" );
+ user.setPassword( "nopass" );
+ um.addUser( user );
+
+ // test with valid credentials
+ Authenticator auth = component;
+ assertNotNull( auth );
+
+ AuthenticationResult result = auth.authenticate( createAuthDataSource( "anonymous", "nopass" ) );
+ assertTrue( result.isAuthenticated() );
+
+ // test with invalid password
+ result = auth.authenticate( createAuthDataSource( "anonymous", "wrongpass" ) );
+ assertFalse( result.isAuthenticated() );
+ assertNull( result.getException() );
+
+ // test with unknown user
+ result = auth.authenticate( createAuthDataSource( "unknownuser", "wrongpass" ) );
+ assertFalse( result.isAuthenticated() );
+ assertNotNull( result.getException() );
+ assertEquals( result.getException().getClass().getName(), UserNotFoundException.class.getName() );
+ }
+
+ @Test
+ public void testAuthenticateLockedPassword()
+ throws AuthenticationException, MustChangePasswordException, UserNotFoundException
+ {
+ userSecurityPolicy.setEnabled( true );
+
+ // Set up a user for the Authenticator
+ User user = um.createUser( "testuser", "Test User Locked Password", "testuser@somedomain.com" );
+ user.setPassword( "correctpass1" );
+ user.setValidated( true );
+ user.setPasswordChangeRequired( false );
+ um.addUser( user );
+
+ Authenticator auth = component;
+ assertNotNull( auth );
+
+ boolean hasException = false;
+ AuthenticationResult result = null;
+
+ try
+ {
+ // test password lock
+ for ( int i = 0; i < 11; i++ )
+ {
+ result = auth.authenticate( createAuthDataSource( "testuser", "wrongpass" ) );
+ }
+ }
+ catch ( AccountLockedException e )
+ {
+ hasException = true;
+ }
+ finally
+ {
+ assertNotNull( result );
+ assertFalse( result.isAuthenticated() );
+ assertTrue( hasException );
+ }
+ }
+
+ @Test
+ public void testAuthenticateExpiredPassword()
+ throws AuthenticationException, AccountLockedException, UserNotFoundException
+ {
+ userSecurityPolicy.setEnabled( true );
+ userSecurityPolicy.setPasswordExpirationDays( 15 );
+
+ // Set up a user for the Authenticator
+ User user = um.createUser( "testuser", "Test User Expired Password", "testuser@somedomain.com" );
+ user.setPassword( "expiredpass1" );
+ user.setValidated( true );
+ user.setPasswordChangeRequired( false );
+ um.addUser( user );
+
+ Authenticator auth = component;
+ assertNotNull( auth );
+
+ boolean hasException = false;
+
+ try
+ {
+ // test successful authentication
+ AuthenticationResult result = auth.authenticate( createAuthDataSource( "testuser", "expiredpass1" ) );
+ assertTrue( result.isAuthenticated() );
+
+ // test expired password
+ user = um.findUser( "testuser" );
+
+ Calendar currentDate = Calendar.getInstance();
+ currentDate.set( Calendar.YEAR, currentDate.get( Calendar.YEAR ) - 1 );
+ Date lastPasswordChange = currentDate.getTime();
+ user.setLastPasswordChange( lastPasswordChange );
+
+ um.updateUser( user );
+
+ auth.authenticate( createAuthDataSource( "testuser", "expiredpass1" ) );
+ }
+ catch ( MustChangePasswordException e )
+ {
+ hasException = true;
+ }
+ finally
+ {
+ assertTrue( hasException );
+ }
+ }
+
+ private PasswordBasedAuthenticationDataSource createAuthDataSource( String username, String password )
+ {
+ PasswordBasedAuthenticationDataSource source = new PasswordBasedAuthenticationDataSource();
+
+ source.setPrincipal( username );
+ source.setPassword( password );
+
+ return source;
+
+ }
+}
Propchange: archiva/redback/redback-core/trunk/redback-users/redback-authentication-users/src/test/java/org/codehaus/plexus/redback/authentication/users/UserManagerAuthenticatorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-core/trunk/redback-users/redback-authentication-users/src/test/java/org/codehaus/plexus/redback/authentication/users/UserManagerAuthenticatorTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-core/trunk/redback-users/redback-authentication-users/src/test/resources/spring-context.xml
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-users/redback-authentication-users/src/test/resources/spring-context.xml?rev=1310268&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-users/redback-authentication-users/src/test/resources/spring-context.xml (added)
+++ archiva/redback/redback-core/trunk/redback-users/redback-authentication-users/src/test/resources/spring-context.xml Fri Apr 6 09:58:14 2012
@@ -0,0 +1,37 @@
+<?xml version="1.0"?>
+
+<!--
+ ~ 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.
+ -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ http://www.springframework.org/schema/context
+ http://www.springframework.org/schema/context/spring-context-3.0.xsd"
+ default-lazy-init="true">
+
+ <bean name="authenticator#user-manager" class="org.codehaus.plexus.redback.authentication.users.UserManagerAuthenticator">
+ <property name="userManager" ref="userManager#memory"/>
+ <property name="securityPolicy" ref="userSecurityPolicy"/>
+ </bean>
+
+ <alias name="userManager#memory" alias="userManager#jdo"/>
+
+</beans>
\ No newline at end of file
Propchange: archiva/redback/redback-core/trunk/redback-users/redback-authentication-users/src/test/resources/spring-context.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-core/trunk/redback-users/redback-authentication-users/src/test/resources/spring-context.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-core/trunk/redback-users/redback-users-api/pom.xml
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-users/redback-users-api/pom.xml?rev=1310268&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-users/redback-users-api/pom.xml (added)
+++ archiva/redback/redback-core/trunk/redback-users/redback-users-api/pom.xml Fri Apr 6 09:58:14 2012
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2006 The Codehaus.
+ ~
+ ~ Licensed 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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.codehaus.redback</groupId>
+ <artifactId>redback-users</artifactId>
+ <version>1.5-SNAPSHOT</version>
+ </parent>
+ <artifactId>redback-users-api</artifactId>
+ <name>Redback :: User Management API</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ </dependencies>
+</project>
Propchange: archiva/redback/redback-core/trunk/redback-users/redback-users-api/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-core/trunk/redback-users/redback-users-api/pom.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-core/trunk/redback-users/redback-users-api/src/main/java/org/codehaus/plexus/redback/users/AbstractUserManager.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-users/redback-users-api/src/main/java/org/codehaus/plexus/redback/users/AbstractUserManager.java?rev=1310268&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-users/redback-users-api/src/main/java/org/codehaus/plexus/redback/users/AbstractUserManager.java (added)
+++ archiva/redback/redback-core/trunk/redback-users/redback-users-api/src/main/java/org/codehaus/plexus/redback/users/AbstractUserManager.java Fri Apr 6 09:58:14 2012
@@ -0,0 +1,139 @@
+package org.codehaus.plexus.redback.users;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed 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 java.util.ArrayList;
+import java.util.List;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * AbstractUserManager
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public abstract class AbstractUserManager
+ implements UserManager
+{
+ protected Logger log = LoggerFactory.getLogger( getClass() );
+
+ private List<UserManagerListener> listeners = new ArrayList<UserManagerListener>();
+
+ public void addUserManagerListener( UserManagerListener listener )
+ {
+ if ( !listeners.contains( listener ) )
+ {
+ listeners.add( listener );
+ }
+ }
+
+ public void removeUserManagerListener( UserManagerListener listener )
+ {
+ listeners.remove( listener );
+ }
+
+ protected void fireUserManagerInit( boolean freshDatabase )
+ {
+ for ( UserManagerListener listener : listeners )
+ {
+ try
+ {
+ listener.userManagerInit( freshDatabase );
+ }
+ catch ( Exception e )
+ {
+ // Ignore
+ }
+ }
+ }
+
+ protected void fireUserManagerUserAdded( User addedUser )
+ {
+ for ( UserManagerListener listener : listeners )
+ {
+ try
+ {
+ listener.userManagerUserAdded( addedUser );
+ }
+ catch ( Exception e )
+ {
+ // Ignore
+ }
+ }
+ }
+
+ protected void fireUserManagerUserRemoved( User removedUser )
+ {
+ for ( UserManagerListener listener : listeners )
+ {
+ try
+ {
+ listener.userManagerUserRemoved( removedUser );
+ }
+ catch ( Exception e )
+ {
+ // Ignore
+ }
+ }
+ }
+
+ protected void fireUserManagerUserUpdated( User updatedUser )
+ {
+ for ( UserManagerListener listener : listeners )
+ {
+ try
+ {
+ listener.userManagerUserUpdated( updatedUser );
+ }
+ catch ( Exception e )
+ {
+ // Ignore
+ }
+ }
+ }
+
+ public User getGuestUser()
+ throws UserNotFoundException
+ {
+ return findUser( GUEST_USERNAME );
+ }
+
+ public User createGuestUser()
+ {
+ try
+ {
+ User u = getGuestUser();
+ if ( u != null )
+ {
+ return u;
+ }
+ }
+ catch ( UserNotFoundException e )
+ {
+ //Nothing to do
+ }
+
+ User user = createUser( GUEST_USERNAME, "Guest", "" );
+ user.setPermanent( true );
+ user.setPasswordChangeRequired( false );
+
+ user = addUser( user );
+ return user;
+ }
+}
Propchange: archiva/redback/redback-core/trunk/redback-users/redback-users-api/src/main/java/org/codehaus/plexus/redback/users/AbstractUserManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-core/trunk/redback-users/redback-users-api/src/main/java/org/codehaus/plexus/redback/users/AbstractUserManager.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-core/trunk/redback-users/redback-users-api/src/main/java/org/codehaus/plexus/redback/users/AbstractUserQuery.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-users/redback-users-api/src/main/java/org/codehaus/plexus/redback/users/AbstractUserQuery.java?rev=1310268&view=auto
==============================================================================
--- archiva/redback/redback-core/trunk/redback-users/redback-users-api/src/main/java/org/codehaus/plexus/redback/users/AbstractUserQuery.java (added)
+++ archiva/redback/redback-core/trunk/redback-users/redback-users-api/src/main/java/org/codehaus/plexus/redback/users/AbstractUserQuery.java Fri Apr 6 09:58:14 2012
@@ -0,0 +1,119 @@
+package org.codehaus.plexus.redback.users;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+/**
+ * Abstract Implementation of UserQuery.
+ * Intended to be subclassed by UserManager providers.
+ */
+public abstract class AbstractUserQuery
+ implements UserQuery
+{
+
+ private String username;
+
+ private String fullName;
+
+ private String email;
+
+ private long maxResults = -1;
+
+ private long firstResult;
+
+ private String orderBy = ORDER_BY_USERNAME;
+
+ private boolean ascending = true;
+
+ public String getUsername()
+ {
+ return username;
+ }
+
+ public void setUsername( String userName )
+ {
+ this.username = userName;
+ }
+
+ public String getFullName()
+ {
+ return fullName;
+ }
+
+ public void setFullName( String fullName )
+ {
+ this.fullName = fullName;
+ }
+
+ public String getEmail()
+ {
+ return email;
+ }
+
+ public void setEmail( String email )
+ {
+ this.email = email;
+ }
+
+ public long getFirstResult()
+ {
+ return firstResult;
+ }
+
+ public void setFirstResult( int firstResult )
+ {
+ this.firstResult = firstResult;
+ }
+
+ public long getMaxResults()
+ {
+ return maxResults;
+ }
+
+ public void setMaxResults( int maxResults )
+ {
+ this.maxResults = maxResults;
+ }
+
+ public String getOrderBy()
+ {
+ return orderBy;
+ }
+
+ public void setOrderBy( String orderBy )
+ {
+ if ( orderBy == null )
+ {
+ throw new IllegalArgumentException( "orderBy cannot be set to null" );
+ }
+ else if ( !ALLOWED_ORDER_FIELDS.contains( orderBy ) )
+ {
+ throw new IllegalArgumentException( orderBy + " is not an allowed orderBy field: " + orderBy );
+ }
+ this.orderBy = orderBy;
+ }
+
+ public boolean isAscending()
+ {
+ return ascending;
+ }
+
+ public void setAscending( boolean ascending )
+ {
+ this.ascending = ascending;
+ }
+
+}
\ No newline at end of file
Propchange: archiva/redback/redback-core/trunk/redback-users/redback-users-api/src/main/java/org/codehaus/plexus/redback/users/AbstractUserQuery.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-core/trunk/redback-users/redback-users-api/src/main/java/org/codehaus/plexus/redback/users/AbstractUserQuery.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision