1 package org.codehaus.plexus.redback.struts2.checks;
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.ArrayList;
23 import java.util.List;
25 import org.apache.archiva.redback.system.check.EnvironmentCheck;
26 import org.apache.archiva.redback.integration.checks.xwork.XworkPackageConfig;
28 import com.opensymphony.xwork2.config.Configuration;
29 import com.opensymphony.xwork2.config.ConfigurationManager;
33 * ExpectedXworkConfiguration reason for existence is to validate that the executing
34 * environment has everything needed for a proper execution of
35 * Plexus Security :: UI Web components and javascript and jsps.
39 * It is quite possible for the environment overlay to have not been done.
40 * Such as when using <code>"mvn jetty:run"</code>, but forgetting to run
41 * <code>"mvn war:inplace"</code> first.
44 * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
47 * TODO: Address comment below and add back in the component declaration
50 public class ExpectedXworkConfiguration
51 extends AbstractXworkConfigurationCheck
52 implements EnvironmentCheck
54 public void validateEnvironment( List<String> violations )
56 // Get the configuration.
58 Configuration xworkConfig = new ConfigurationManager().getConfiguration();
60 if ( xworkConfig != null )
62 List<String> internalViolations = new ArrayList<String>();
65 * TODO: this currently throws a violation since the standard practice is
66 * to include the xwork-security namespace in from the war overlay. Otherwise
67 * all actions in the security namespace are also addressable from the
68 * root default action lookup since by extending the security package thats how
69 * webwork/xwork deals with the actions
71 XworkPackageConfig expectedPackage = new XworkPackageConfig( "/security" );
73 expectedPackage.addAction( "account", "redback-account", "show" ).addResult( "input" ).addResult(
74 "error" ).addResult( "success" );
76 expectedPackage.addAction( "login", "redback-login", "show" ).addResult( "input" ).addResult(
77 "error" ).addResult( "success" );
79 expectedPackage.addAction( "logout", "redback-logout", "show" ).addResult( "input" ).addResult(
80 "error" ).addResult( "success" );
82 expectedPackage.addAction( "register", "redback-register", "show" ).addResult( "input" ).addResult(
83 "error" ).addResult( "success" );
85 expectedPackage.addAction( "password", "redback-password", "show" ).addResult( "input" ).addResult(
86 "error" ).addResult( "success" );
88 // -----------------------------------------------------------------
89 // Security Admin Tests
91 expectedPackage.addAction( "systeminfo", "redback-sysinfo", "show" );
92 expectedPackage.addAction( "adminConsole", "redback-admin-console", "show" );
94 expectedPackage.addAction( "userlist", "redback-admin-user-list", "show" ).addResult( "input" ).addResult(
97 expectedPackage.addAction( "useredit", "redback-admin-user-edit", "edit" ).addResult( "input" ).addResult(
98 "error" ).addResult( "success" );
100 expectedPackage.addAction( "usercreate", "redback-admin-user-create", "edit" ).addResult( "input" ).addResult(
101 "error" ).addResult( "success" );
103 expectedPackage.addAction( "userdelete", "redback-admin-user-delete", "confirm" ).addResult(
104 "input" ).addResult( "error" ).addResult( "success" );
106 expectedPackage.addAction( "assignments", "redback-assignments", "show" ).addResult( "input" ).addResult(
107 "error" ).addResult( "success" );
109 expectedPackage.addAction( "roles", "redback-roles", "show" ).addResult( "input" ).addResult(
110 "error" ).addResult( "success" );
112 expectedPackage.addAction( "permissions", "redback-permissions", "show" ).addResult( "input" ).addResult(
113 "error" ).addResult( "success" );
115 checkPackage( internalViolations, expectedPackage, xworkConfig );
117 if ( internalViolations.size() > 0 )
119 violations.addAll( internalViolations );
120 violations.add( "Missing [" + internalViolations.size() + "] xwork.xml configuration elements." );
125 violations.add( "Missing xwork.xml configuration." );