1 package org.codehaus.redback.integration.checks.security;
4 * Copyright 2005-2006 The Codehaus.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 import java.util.List;
21 import javax.annotation.Resource;
22 import javax.inject.Inject;
23 import javax.inject.Named;
25 import org.codehaus.plexus.redback.role.RoleManager;
26 import org.codehaus.plexus.redback.role.RoleManagerException;
27 import org.codehaus.plexus.redback.system.check.EnvironmentCheck;
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
30 import org.springframework.stereotype.Service;
33 * RequiredRolesEnvironmentCheck: this environment check will check that the
34 * required roles of the redback-xwork-integration artifact exist to be
37 * @author: Jesse McConnell <jesse@codehaus.org>
40 @Service("environmentCheck#required-roles")
41 public class RequiredRolesEnvironmentCheck
42 implements EnvironmentCheck
45 protected Logger log = LoggerFactory.getLogger( getClass() );
48 private RoleManager roleManager;
51 * boolean detailing if this environment check has been executed
53 private boolean checked = false;
58 public void validateEnvironment( List<String> violations )
62 log.info( "Checking the existence of required roles." );
66 if ( !roleManager.roleExists( "registered-user" ) )
68 violations.add( "unable to validate existence of the registered-user role" );
71 if ( !roleManager.roleExists( "user-administrator" ) )
73 violations.add( "unable to validate existence of the user-administator role" );
76 if ( !roleManager.roleExists( "system-administrator" ) )
78 violations.add( "unable to validate existence of the system-administrator role" );
81 catch ( RoleManagerException e )
83 violations.add( "unable to check required roles: " + e.getMessage() );