move a couple of pages around and improve an action

git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@443124 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jesse McConnell 2006-09-13 21:17:14 +00:00
parent e0e1b86df1
commit ca5303139b
6 changed files with 170 additions and 250 deletions

View File

@ -17,11 +17,12 @@ package org.apache.maven.archiva.web.action.admin;
* limitations under the License.
*/
import com.opensymphony.xwork.Preparable;
import org.codehaus.plexus.security.rbac.RBACManager;
import org.codehaus.plexus.security.system.SecuritySession;
import org.codehaus.plexus.security.user.User;
import org.codehaus.plexus.security.user.UserManager;
import org.codehaus.plexus.security.user.UserNotFoundException;
import org.codehaus.plexus.security.system.SecuritySession;
import org.codehaus.plexus.xwork.action.PlexusActionSupport;
import java.util.ArrayList;
@ -37,9 +38,8 @@ import java.util.List;
* role-hint="userManagement"
*/
public class UserManagementAction
extends PlexusActionSupport
extends PlexusActionSupport implements Preparable
{
/**
* @plexus.requirement
*/
@ -52,12 +52,12 @@ public class UserManagementAction
private User user;
private boolean save = false;
private String email;
private String fullName;
private boolean locked;
private String username;
private String principal;
@ -70,55 +70,18 @@ public class UserManagementAction
private String resourceName;
/**
* for this method username should be populated
*
* @return
*/
public String findUser()
{
try
{
if ( username == null )
{
return INPUT;
}
else
{
user = userManager.findUser( username );
return SUCCESS;
}
}
catch ( UserNotFoundException ne )
{
addActionError( "user could not be found " + username );
return ERROR;
}
}
/**
* For this method, principal should be populated
*
* @throws Exception
*/
public String display()
public void prepare()
throws Exception
{
if ( username != null )
{
user = userManager.findUser( username );
principal = user.getPrincipal().toString();
fullName = user.getFullName();
email = user.getEmail();
locked = user.isLocked();
// for displaying the potential repositories to be displayed, remove the global resource
// from the list
resources = rbacManager.getAllResources();
//resources.remove( rbacManager.getGlobalResource() );
// check if the user has any roles assigned to them, and populate the lists for
// rendering assign and remove roles links
if ( principal != null && rbacManager.userAssignmentExists( principal ) )
{
assignedRoles = new ArrayList( rbacManager.getAssignedRoles( principal ) );
@ -129,18 +92,54 @@ public class UserManagementAction
assignedRoles = new ArrayList();
availableRoles = rbacManager.getAllAssignableRoles();
}
}
}
/**
* for this method username should be populated
*
* @return
*/
public String input()
{
try
{
if ( username != null )
{
user = userManager.findUser( username );
return SUCCESS;
}
else
{
return INPUT;
}
}
catch ( UserNotFoundException ne )
{
addActionError( "user could not be found " + username );
return ERROR;
}
}
public String save()
throws Exception
{
if ( !save )
{
return INPUT;
}
User temp = userManager.findUser( username );
if ( email != null )
{
temp.setEmail( email );
}
if ( fullName != null )
{
temp.setFullName( fullName );
temp.setLocked( locked );
}
temp = userManager.updateUser( temp );
@ -195,16 +194,6 @@ public class UserManagementAction
this.fullName = fullName;
}
public boolean isLocked()
{
return locked;
}
public void setLocked( boolean locked )
{
this.locked = locked;
}
public String getPrincipal()
{
return principal;
@ -254,4 +243,14 @@ public class UserManagementAction
{
this.resourceName = resourceName;
}
public boolean isSave()
{
return save;
}
public void setSave( boolean save )
{
this.save = save;
}
}

View File

@ -253,18 +253,22 @@
</action>
<action name="user" class="userManagement" method="display">
<result name="success">/WEB-INF/jsp/user.jsp</result>
<action name="user" class="userManagement">
<result name="success">/WEB-INF/jsp/admin/user.jsp</result>
<result name="input" type="chain">userManagement</result>
<interceptor-ref name="configuredPrepareParamsStack"/>
</action>
<!-- plexus security actions -->
<action name="userDetails" class="userManagement" method="display">
<result name="success">/WEB-INF/jsp/userDetails.jsp</result>
<action name="userDetails" class="userManagement" method="save">
<result name="input">/WEB-INF/jsp/admin/userDetails.jsp</result>
<result name="success" type="chain">user</result>
<interceptor-ref name="configuredPrepareParamsStack"/>
</action>
<action name="userManagement" class="userManagement" method="findUser">
<result name="input">/WEB-INF/jsp/findUser.jsp</result>
<action name="userManagement" class="userManagement" method="input">
<result name="input">/WEB-INF/jsp/admin/findUser.jsp</result>
<result name="success" type="chain">user</result>
</action>

View File

@ -0,0 +1,99 @@
<%--
~ Copyright 2005-2006 The Apache Software Foundation.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
--%>
<%@ taglib prefix="ww" uri="/webwork" %>
<%@ taglib prefix="pss" uri="plexusSecuritySystem" %>
<html>
<head>
<title>User Management</title>
<ww:head />
</head>
<body>
<div id="contentArea">
<div id="searchBox">
<div style="float: right">
<%-- add this back in when the functionality works, or when we move to the plexus-user-management pages
<pss:ifAnyAuthorized permissions="edit-all-users,edit-user" resource="${username}">
<ww:url id="userDetailsUrl" action="userDetails" method="input">
<ww:param name="username">${sessionScope.SecuritySessionUser.username}</ww:param>
</ww:url>
<ww:a href="%{userDetailsUrl}">Edit details</ww:a>
</pss:ifAnyAuthorized>
--%>
</div>
<h2>${fullName}</h2>
<table class="bodyTable">
<tr class="a">
<th>Username</th>
<td>${username}</td>
</tr>
<tr class="b">
<th>Email</th>
<td>${email}</td>
</tr>
</table>
<h2>Currently Assigned Roles</h2>
<table class="bodyTable">
<ww:iterator id="role" value="assignedRoles">
<tr class="a">
<td>
<em>${role.name}</em><br/>
</td>
</tr>
</ww:iterator>
</table>
<pss:ifAnyAuthorized permissions="grant-roles,remove-roles">
<h2>Role Management</h2>
<pss:ifAuthorized permission="grant-roles">
<h3>Grant</h3>
<ww:form action="assignRoleToUser" method="post">
<ww:hidden name="principal" value="${username}"/>
<ww:hidden name="username" value="${username}"/>
<ww:radio name="roleName" list="availableRoles" listKey="name" listValue="name" labelposition="left"/>
<ww:submit value="Grant"/>
</ww:form>
</pss:ifAuthorized>
<pss:ifAuthorized permission="remove-roles">
<h3>Remove</h3>
<ww:form action="removeRoleFromUser" method="post">
<ww:hidden name="principal" value="${username}"/>
<ww:hidden name="username" value="${username}"/>
<ww:radio name="roleName" list="assignedRoles" listKey="name" listValue="name" labelposition="left"/>
<ww:submit value="Remove"/>
</ww:form>
</pss:ifAuthorized>
</pss:ifAnyAuthorized>
</div>
</div>
<div class="clear">
<hr/>
</div>
</body>
</html>

View File

@ -1,182 +0,0 @@
<%--
~ Copyright 2005-2006 The Apache Software Foundation.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
--%>
<%@ taglib prefix="ww" uri="/webwork" %>
<%@ taglib prefix="pss" uri="plexusSecuritySystem" %>
<html>
<head>
<title>User Management</title>
<ww:head />
</head>
<body>
<div id="contentArea">
<div id="searchBox">
<div style="float: right">
<pss:ifAnyAuthorized permissions="edit-all-users,edit-user" resource="${username}">
<ww:url id="userDetailsUrl" action="userDetails">
<ww:param name="username">${sessionScope.SecuritySessionUser.username}</ww:param>
</ww:url>
<ww:a href="%{userDetailsUrl}">Edit details</ww:a>
</pss:ifAnyAuthorized>
</div>
<h2>${sessionScope.SecuritySessionUser.fullName}</h2>
<table class="bodyTable">
<tr class="a">
<th>Username</th>
<td>${username}</td>
</tr>
<tr class="b">
<th>Email</th>
<td>${email}</td>
</tr>
</table>
<h2>Assigned Roles</h2>
<table class="bodyTable">
<ww:iterator id="role" value="assignedRoles">
<tr class="a">
<td>
<em>${role.name}</em><br/>
</td>
<td>
<pss:ifAuthorized permission="remove-roles">
<ww:url id="removeAssignedRoleUrl" action="removeRoleFromUser">
<ww:param name="principal">${username}</ww:param>
<ww:param name="roleName">${role.name}</ww:param>
</ww:url>
<ww:a href="%{removeAssignedRoleUrl}">Delete</ww:a>
</pss:ifAuthorized>
</td>
</tr>
</ww:iterator>
</table>
<h2>Grant Roles</h2>
<pss:ifAuthorized permission="grant-roles">
<table class="bodyTable">
<ww:iterator id="role" value="availableRoles">
<tr class="a">
<td>
<em>${role.name}</em><br/>
</td>
<td>
<ww:url id="addRoleUrl" action="assignRoleToUser">
<ww:param name="principal">${username}</ww:param>
<ww:param name="roleName">${role.name}</ww:param>
</ww:url>
<ww:a href="%{addRoleUrl}">Add</ww:a>
</td>
</tr>
</ww:iterator>
</table>
</pss:ifAuthorized>
<%--
<p>
This following screen needs have the various roles worked into it.
</p>
<table class="bodyTable">
<tr class="b">
<td>
<input type="radio" checked="checked"></input>
</td>
<td>Administrator</td>
<td>
<select>
<option>(Please Select)</option>
<option>System Administrator</option>
<option>User Administrator</option>
</select>
</td>
</tr>
<tr class="a">
<td>
<input type="radio"></input>
</td>
<td>Repository</td>
<td>
<select>
<option>(Please Select)</option>
<option>manager</option>
<option>obverser</option>
</select>
of
<ww:select name="resourceName" list="resources" listKey="identifier" listValue="identifier" headerKey="" headerValue="(Please Select)"/>
</td>
</tr> --%>
<%-- add in for project level security
<tr class="b">
<td>
<input type="radio"></input>
</td>
<td>Project</td>
<td>
<select>
<option>(Please Select)</option>
<option>manager</option>
<option>obverser</option>
</select>
of
<select>
<option>(Please Select)</option>
<option>central</option>
<option>central-plugins</option>
<option>All repositories</option>
</select>
for project group
<input type="text" name="projectExpression"></input>
<br></br>
<span style="font-size: x-small">
(eg org.apache.maven gives permissions on that group, and any sugroups)
</span>
</td>
</tr>
<tr class="a">
<td></td>
<td>
<input type="submit" value="Add Role"></input>
</td>
<td></td>
</tr>
</table>
--%>
</div>
</div>
<div class="clear">
<hr/>
</div>
</body>
</html>