]> source.dussan.org Git - archiva.git/blob
b3108dd3296e85c8ec047ecd8a65a97f2c1f9539
[archiva.git] /
1 package org.codehaus.plexus.redback.struts2.checks;
2
3 /*
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
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
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
19  * under the License.
20  */
21
22 import java.util.ArrayList;
23 import java.util.List;
24
25 import org.apache.archiva.redback.system.check.EnvironmentCheck;
26 import org.apache.archiva.redback.integration.checks.xwork.XworkPackageConfig;
27
28 import com.opensymphony.xwork2.config.Configuration;
29 import com.opensymphony.xwork2.config.ConfigurationManager;
30
31 /**
32  * <p/>
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.
36  * </p>
37  * <p/>
38  * <p/>
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.
42  * </p>
43  *
44  * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
45  * @version $Id$
46  * 
47  * TODO: Address comment below and add back in the component declaration
48  *
49  */
50 public class ExpectedXworkConfiguration
51     extends AbstractXworkConfigurationCheck
52     implements EnvironmentCheck
53 {       
54     public void validateEnvironment( List<String> violations )
55     {
56         // Get the configuration.
57         
58         Configuration xworkConfig = new ConfigurationManager().getConfiguration();
59
60         if ( xworkConfig != null )
61         {
62             List<String> internalViolations = new ArrayList<String>();
63
64             /* PLXREDBACK-67
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
70              */
71             XworkPackageConfig expectedPackage = new XworkPackageConfig( "/security" );
72
73             expectedPackage.addAction( "account", "redback-account", "show" ).addResult( "input" ).addResult(
74                 "error" ).addResult( "success" );
75
76             expectedPackage.addAction( "login", "redback-login", "show" ).addResult( "input" ).addResult(
77                 "error" ).addResult( "success" );
78
79             expectedPackage.addAction( "logout", "redback-logout", "show" ).addResult( "input" ).addResult(
80                 "error" ).addResult( "success" );
81
82             expectedPackage.addAction( "register", "redback-register", "show" ).addResult( "input" ).addResult(
83                 "error" ).addResult( "success" );
84
85             expectedPackage.addAction( "password", "redback-password", "show" ).addResult( "input" ).addResult(
86                 "error" ).addResult( "success" );
87
88             // -----------------------------------------------------------------
89             // Security Admin Tests
90
91             expectedPackage.addAction( "systeminfo", "redback-sysinfo", "show" );
92             expectedPackage.addAction( "adminConsole", "redback-admin-console", "show" );
93
94             expectedPackage.addAction( "userlist", "redback-admin-user-list", "show" ).addResult( "input" ).addResult(
95                 "success" );
96
97             expectedPackage.addAction( "useredit", "redback-admin-user-edit", "edit" ).addResult( "input" ).addResult(
98                 "error" ).addResult( "success" );
99
100             expectedPackage.addAction( "usercreate", "redback-admin-user-create", "edit" ).addResult( "input" ).addResult(
101                 "error" ).addResult( "success" );
102
103             expectedPackage.addAction( "userdelete", "redback-admin-user-delete", "confirm" ).addResult(
104                 "input" ).addResult( "error" ).addResult( "success" );
105
106             expectedPackage.addAction( "assignments", "redback-assignments", "show" ).addResult( "input" ).addResult(
107                 "error" ).addResult( "success" );
108
109             expectedPackage.addAction( "roles", "redback-roles", "show" ).addResult( "input" ).addResult(
110                 "error" ).addResult( "success" );
111
112             expectedPackage.addAction( "permissions", "redback-permissions", "show" ).addResult( "input" ).addResult(
113                 "error" ).addResult( "success" );
114
115             checkPackage( internalViolations, expectedPackage, xworkConfig );
116
117             if ( internalViolations.size() > 0 )
118             {
119                 violations.addAll( internalViolations );
120                 violations.add( "Missing [" + internalViolations.size() + "] xwork.xml configuration elements." );
121             }
122         }
123         else
124         {
125             violations.add( "Missing xwork.xml configuration." );
126         }
127     }
128
129 }