mirror of https://github.com/apache/archiva.git
fix second person registering issue
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@442127 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d89e505d1e
commit
e5610b9357
|
@ -122,42 +122,46 @@ public class DefaultRoleManager
|
||||||
{
|
{
|
||||||
if ( !manager.permissionExists( "Edit Configuration" ) )
|
if ( !manager.permissionExists( "Edit Configuration" ) )
|
||||||
{
|
{
|
||||||
Permission editConfiguration =
|
Permission editConfiguration = manager.createPermission( "Edit Configuration", "edit-configuration",
|
||||||
manager.createPermission( "Edit Configuration", "edit-configuration", manager.getGlobalResource().getIdentifier() );
|
manager.getGlobalResource().getIdentifier() );
|
||||||
manager.savePermission( editConfiguration );
|
manager.savePermission( editConfiguration );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !manager.permissionExists( "Run Indexer" ) )
|
if ( !manager.permissionExists( "Run Indexer" ) )
|
||||||
{
|
{
|
||||||
Permission runIndexer = manager.createPermission( "Run Indexer", "run-indexer", manager.getGlobalResource().getIdentifier() );
|
Permission runIndexer = manager.createPermission( "Run Indexer", "run-indexer",
|
||||||
|
manager.getGlobalResource().getIdentifier() );
|
||||||
|
|
||||||
manager.savePermission( runIndexer );
|
manager.savePermission( runIndexer );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !manager.permissionExists( "Add Repository" ) )
|
if ( !manager.permissionExists( "Add Repository" ) )
|
||||||
{
|
{
|
||||||
Permission runIndexer = manager.createPermission( "Add Repository", "add-repository", manager.getGlobalResource().getIdentifier() );
|
Permission runIndexer = manager.createPermission( "Add Repository", "add-repository",
|
||||||
|
manager.getGlobalResource().getIdentifier() );
|
||||||
manager.savePermission( runIndexer );
|
manager.savePermission( runIndexer );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !manager.permissionExists( "Edit All Users" ) )
|
if ( !manager.permissionExists( "Edit All Users" ) )
|
||||||
{
|
{
|
||||||
Permission editAllUsers = manager.createPermission( "Edit All Users", "edit-all-users", manager.getGlobalResource().getIdentifier() );
|
Permission editAllUsers = manager.createPermission( "Edit All Users", "edit-all-users",
|
||||||
|
manager.getGlobalResource().getIdentifier() );
|
||||||
|
|
||||||
manager.savePermission( editAllUsers );
|
manager.savePermission( editAllUsers );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !manager.permissionExists( "Remove Roles" ) )
|
if ( !manager.permissionExists( "Remove Roles" ) )
|
||||||
{
|
{
|
||||||
Permission editAllUsers = manager.createPermission( "Remove Roles", "remove-roles", manager.getGlobalResource().getIdentifier() );
|
Permission editAllUsers = manager.createPermission( "Remove Roles", "remove-roles",
|
||||||
|
manager.getGlobalResource().getIdentifier() );
|
||||||
|
|
||||||
manager.savePermission( editAllUsers );
|
manager.savePermission( editAllUsers );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ( !manager.permissionExists( "Regenerate Index" ) )
|
if ( !manager.permissionExists( "Regenerate Index" ) )
|
||||||
{
|
{
|
||||||
Permission regenIndex = manager.createPermission( "Regenerate Index", "regenerate-index", manager.getGlobalResource().getIdentifier() );
|
Permission regenIndex = manager.createPermission( "Regenerate Index", "regenerate-index",
|
||||||
|
manager.getGlobalResource().getIdentifier() );
|
||||||
|
|
||||||
manager.savePermission( regenIndex );
|
manager.savePermission( regenIndex );
|
||||||
}
|
}
|
||||||
|
@ -174,17 +178,16 @@ public class DefaultRoleManager
|
||||||
if ( !manager.roleExists( "System Administrator" ) )
|
if ( !manager.roleExists( "System Administrator" ) )
|
||||||
{
|
{
|
||||||
Role admin = manager.createRole( "System Administrator" );
|
Role admin = manager.createRole( "System Administrator" );
|
||||||
admin.addChildRole( manager.getRole( "User Administrator" ) ) ;
|
admin.addChildRole( manager.getRole( "User Administrator" ) );
|
||||||
admin.addPermission( manager.getPermission( "Edit Configuration" ) );
|
admin.addPermission( manager.getPermission( "Edit Configuration" ) );
|
||||||
admin.addPermission( manager.getPermission( "Run Indexer" ) );
|
admin.addPermission( manager.getPermission( "Run Indexer" ) );
|
||||||
admin.addPermission( manager.getPermission( "Add Repository") );
|
admin.addPermission( manager.getPermission( "Add Repository" ) );
|
||||||
admin.addPermission( manager.getPermission( "Regenerate Index" ) );
|
admin.addPermission( manager.getPermission( "Regenerate Index" ) );
|
||||||
admin.setAssignable( true );
|
admin.setAssignable( true );
|
||||||
manager.saveRole( admin );
|
manager.saveRole( admin );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch ( RbacObjectNotFoundException ne )
|
catch ( RbacObjectNotFoundException ne )
|
||||||
{
|
{
|
||||||
|
@ -197,31 +200,23 @@ public class DefaultRoleManager
|
||||||
public void addUser( String principal )
|
public void addUser( String principal )
|
||||||
throws RbacStoreException
|
throws RbacStoreException
|
||||||
{
|
{
|
||||||
try
|
|
||||||
{
|
|
||||||
// make the resource
|
|
||||||
Resource usernameResource = manager.createResource( principal );
|
|
||||||
manager.saveResource( usernameResource );
|
|
||||||
|
|
||||||
Permission editUser = manager.createPermission( "Edit Myself" );
|
// make the resource
|
||||||
editUser.setOperation( manager.getOperation( "edit-user" ) );
|
Resource usernameResource = manager.createResource( principal );
|
||||||
editUser.setResource( manager.getResource( principal ) );
|
manager.saveResource( usernameResource );
|
||||||
editUser = manager.savePermission( editUser );
|
|
||||||
|
|
||||||
// todo this one role a user will go away when we have expressions in the resources
|
Permission editUser = manager.createPermission( "Edit Myself - " + principal, "edit-user", principal );
|
||||||
Role userRole = manager.createRole( "Personal Role - " + principal );
|
editUser = manager.savePermission( editUser );
|
||||||
userRole.addPermission( editUser );
|
|
||||||
userRole = manager.saveRole( userRole );
|
|
||||||
|
|
||||||
UserAssignment assignment = manager.createUserAssignment( principal );
|
// todo this one role a user will go away when we have expressions in the resources
|
||||||
assignment.addRole( userRole );
|
Role userRole = manager.createRole( "Personal Role - " + principal );
|
||||||
manager.saveUserAssignment( assignment );
|
userRole.addPermission( editUser );
|
||||||
|
userRole = manager.saveRole( userRole );
|
||||||
|
|
||||||
|
UserAssignment assignment = manager.createUserAssignment( principal );
|
||||||
|
assignment.addRole( userRole );
|
||||||
|
manager.saveUserAssignment( assignment );
|
||||||
|
|
||||||
}
|
|
||||||
catch ( RbacObjectNotFoundException ne )
|
|
||||||
{
|
|
||||||
throw new RbacStoreException( "rbac object not found in repo role creation", ne );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addRepository( String repositoryName )
|
public void addRepository( String repositoryName )
|
||||||
|
@ -244,8 +239,7 @@ public class DefaultRoleManager
|
||||||
deleteRepo.setResource( repoResource );
|
deleteRepo.setResource( repoResource );
|
||||||
deleteRepo = manager.savePermission( deleteRepo );
|
deleteRepo = manager.savePermission( deleteRepo );
|
||||||
|
|
||||||
Permission getReports =
|
Permission getReports = manager.createPermission( "Get Reports - " + repositoryName );
|
||||||
manager.createPermission( "Get Reports - " + repositoryName );
|
|
||||||
getReports.setOperation( manager.getOperation( "get-reports" ) );
|
getReports.setOperation( manager.getOperation( "get-reports" ) );
|
||||||
getReports.setResource( repoResource );
|
getReports.setResource( repoResource );
|
||||||
getReports = manager.savePermission( getReports );
|
getReports = manager.savePermission( getReports );
|
||||||
|
|
Loading…
Reference in New Issue