import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.security.ArchivaRoleConstants;
-import org.codehaus.plexus.redback.rbac.RBACManager;
-import org.codehaus.plexus.redback.rbac.RbacManagerException;
-import org.codehaus.plexus.redback.rbac.UserAssignment;
import org.codehaus.plexus.redback.role.RoleManager;
import org.codehaus.plexus.redback.role.RoleManagerException;
*/
protected RoleManager roleManager;
- /**
- * @plexus.requirement role-hint="cached"
- */
- protected RBACManager rbacManager;
-
public RoleManager getRoleManager()
{
return roleManager;
{
roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId );
}
-
- try
- {
- UserAssignment ua = rbacManager.getUserAssignment( ArchivaRoleConstants.GUEST_ROLE );
- ua.addRoleName( ArchivaRoleConstants.REPOSITORY_OBSERVER_ROLE_PREFIX + " - " + repoId );
- rbacManager.saveUserAssignment( ua );
- }
- catch ( RbacManagerException e )
- {
- getLogger().warn( "Unable to add role [" + ArchivaRoleConstants.REPOSITORY_OBSERVER_ROLE_PREFIX + " - "
- + repoId + "] to Guest user.", e );
- }
}
protected void removeContents( ManagedRepositoryConfiguration existingRepository )
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.security.ArchivaRoleConstants;
import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.redback.rbac.RBACManager;
+import org.codehaus.plexus.redback.rbac.RbacManagerException;
+import org.codehaus.plexus.redback.rbac.UserAssignment;
import org.codehaus.plexus.redback.role.RoleManager;
import org.codehaus.plexus.redback.role.RoleManagerException;
import org.codehaus.plexus.registry.Registry;
* @plexus.requirement role-hint="default"
*/
private RoleManager roleManager;
+
+ /**
+ * @plexus.requirement role-hint="cached"
+ */
+ private RBACManager rbacManager;
/**
* @plexus.requirement
{
synchConfiguration( archivaConfiguration.getConfiguration().getManagedRepositories() );
archivaConfiguration.addChangeListener( this );
+
+ if ( archivaConfiguration.isDefaulted() )
+ {
+ assignRepositoryObserverToGuestUser( archivaConfiguration.getConfiguration().getManagedRepositories() );
+ }
+ }
+
+ private void assignRepositoryObserverToGuestUser( List<ManagedRepositoryConfiguration> repos )
+ {
+ for ( ManagedRepositoryConfiguration repoConfig : repos )
+ {
+ String repoId = repoConfig.getId();
+ try
+ {
+ UserAssignment ua = rbacManager.getUserAssignment( ArchivaRoleConstants.GUEST_ROLE );
+ ua.addRoleName( ArchivaRoleConstants.REPOSITORY_OBSERVER_ROLE_PREFIX + " - " + repoId );
+ rbacManager.saveUserAssignment( ua );
+ }
+ catch ( RbacManagerException e )
+ {
+ getLogger().warn( "Unable to add role [" + ArchivaRoleConstants.REPOSITORY_OBSERVER_ROLE_PREFIX + " - "
+ + repoId + "] to Guest user.", e );
+ }
+ }
}
}