aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-web/archiva-webapp
diff options
context:
space:
mode:
authorEmmanuel Venisse <evenisse@apache.org>2009-03-11 06:12:17 +0000
committerEmmanuel Venisse <evenisse@apache.org>2009-03-11 06:12:17 +0000
commitaae839ff4b8a2577336047520bab827d7f244038 (patch)
tree7c628cb1d8c21d8c41923d637f3390551f8b0f0c /archiva-modules/archiva-web/archiva-webapp
parentbf03bbad7ae8caac18adbfe9010e18956872e37a (diff)
downloadarchiva-aae839ff4b8a2577336047520bab827d7f244038.tar.gz
archiva-aae839ff4b8a2577336047520bab827d7f244038.zip
[ARCHIVA-938] Remove harcoded guest user
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@752384 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/archiva-web/archiva-webapp')
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/SecuritySynchronization.java45
1 files changed, 25 insertions, 20 deletions
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/SecuritySynchronization.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/SecuritySynchronization.java
index 76ca70288..46fd35753 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/SecuritySynchronization.java
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/SecuritySynchronization.java
@@ -30,6 +30,7 @@ import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.ConfigurationNames;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.security.ArchivaRoleConstants;
+import org.apache.maven.archiva.security.ArchivaXworkUser;
import org.codehaus.plexus.redback.rbac.RBACManager;
import org.codehaus.plexus.redback.rbac.RbacManagerException;
import org.codehaus.plexus.redback.rbac.UserAssignment;
@@ -45,7 +46,6 @@ import org.slf4j.LoggerFactory;
* ConfigurationSynchronization
*
* @version $Id$
- *
* @plexus.component role="org.apache.maven.archiva.web.startup.SecuritySynchronization"
* role-hint="default"
*/
@@ -53,7 +53,7 @@ public class SecuritySynchronization
implements RegistryListener
{
private Logger log = LoggerFactory.getLogger( SecuritySynchronization.class );
-
+
/**
* @plexus.requirement role-hint="default"
*/
@@ -74,6 +74,11 @@ public class SecuritySynchronization
*/
private ArchivaConfiguration archivaConfiguration;
+ /**
+ * @plexus.requirement
+ */
+ private ArchivaXworkUser archivaXworkUser;
+
public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )
{
if ( ConfigurationNames.isManagedRepositories( propertyName ) )
@@ -96,18 +101,18 @@ public class SecuritySynchronization
// manage roles for repositories
try
{
- if ( !roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoConfig
- .getId() ) )
+ if ( !roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER,
+ repoConfig.getId() ) )
{
- roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoConfig
- .getId() );
+ roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER,
+ repoConfig.getId() );
}
- if ( !roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoConfig
- .getId() ) )
+ if ( !roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER,
+ repoConfig.getId() ) )
{
- roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoConfig
- .getId() );
+ roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER,
+ repoConfig.getId() );
}
}
catch ( RoleManagerException e )
@@ -137,8 +142,8 @@ public class SecuritySynchronization
{
if ( ( checkers == null ) || CollectionUtils.isEmpty( checkers.values() ) )
{
- throw new ArchivaException( "Unable to initialize the Redback Security Environment, "
- + "no Environment Check components found." );
+ throw new ArchivaException(
+ "Unable to initialize the Redback Security Environment, " + "no Environment Check components found." );
}
List<String> violations = new ArrayList<String>();
@@ -172,8 +177,8 @@ public class SecuritySynchronization
msg.append( "======================================================================" );
log.error( msg.toString() );
- throw new ArchivaException( "Unable to initialize Redback Security Environment, [" + violations.size()
- + "] violation(s) encountered, See log for details." );
+ throw new ArchivaException( "Unable to initialize Redback Security Environment, [" + violations.size() +
+ "] violation(s) encountered, See log for details." );
}
}
@@ -182,10 +187,9 @@ public class SecuritySynchronization
for ( ManagedRepositoryConfiguration repoConfig : repos )
{
String repoId = repoConfig.getId();
-
- // TODO: Use the Redback / UserConfiguration..getString( "redback.default.guest" ) to get the right name.
- String principal = "guest";
-
+
+ String principal = archivaXworkUser.getGuest();
+
try
{
UserAssignment ua;
@@ -204,8 +208,9 @@ public class SecuritySynchronization
}
catch ( RbacManagerException e )
{
- log.warn( "Unable to add role [" + ArchivaRoleConstants.toRepositoryObserverRoleName( repoId )
- + "] to " + principal + " user.", e );
+ log.warn(
+ "Unable to add role [" + ArchivaRoleConstants.toRepositoryObserverRoleName( repoId ) + "] to " +
+ principal + " user.", e );
}
}
}