1 package org.codehaus.redback.integration.checks.security;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import java.util.List;
24 import javax.inject.Inject;
26 import org.apache.archiva.redback.role.RoleManager;
27 import org.apache.archiva.redback.role.RoleManagerException;
28 import org.apache.archiva.redback.system.check.EnvironmentCheck;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
31 import org.springframework.stereotype.Service;
34 * RequiredRolesEnvironmentCheck: this environment check will check that the
35 * required roles of the redback-xwork-integration artifact exist to be
38 * @author: Jesse McConnell <jesse@codehaus.org>
41 @Service("environmentCheck#required-roles")
42 public class RequiredRolesEnvironmentCheck
43 implements EnvironmentCheck
46 protected Logger log = LoggerFactory.getLogger( getClass() );
49 private RoleManager roleManager;
52 * boolean detailing if this environment check has been executed
54 private boolean checked = false;
59 public void validateEnvironment( List<String> violations )
63 log.info( "Checking the existence of required roles." );
67 if ( !roleManager.roleExists( "registered-user" ) )
69 violations.add( "unable to validate existence of the registered-user role" );
72 if ( !roleManager.roleExists( "user-administrator" ) )
74 violations.add( "unable to validate existence of the user-administator role" );
77 if ( !roleManager.roleExists( "system-administrator" ) )
79 violations.add( "unable to validate existence of the system-administrator role" );
82 catch ( RoleManagerException e )
84 violations.add( "unable to check required roles: " + e.getMessage() );