in src/main/java/org/apache/directory/fortress/core/cli/CommandLineInterpreter.java [698:843]
private void processReviewCommand( Set<String> commands, Options options )
{
String command;
try
{
if ( commands.contains( READ_USER ) )
{
command = READ_USER;
LOG.info( READ_USER );
User inUser = options.getUser();
User outUser = reviewMgr.readUser( inUser );
printUser( outUser );
}
else if ( commands.contains( FIND_USERS ) )
{
command = FIND_USERS;
LOG.info( command );
User user = options.getUser();
List<User> outUsers = reviewMgr.findUsers( user );
if ( CollectionUtils.isNotEmpty( outUsers ) )
{
int ctr = 0;
for ( User outUser : outUsers )
{
printRow( "U", "CTR ", "" + ctr++ );
printUser( outUser );
}
}
}
else if ( commands.contains( ASSIGNED_USERS ) )
{
command = ASSIGNED_USERS;
LOG.info( command );
Role inRole = options.getRole();
List<User> outUsers = reviewMgr.assignedUsers( inRole );
if ( CollectionUtils.isNotEmpty( outUsers ) )
{
for ( User outUser : outUsers )
{
printUser( outUser );
}
}
}
else if ( commands.contains( READ_ROLE ) )
{
command = READ_ROLE;
LOG.info( command );
Role inRole = options.getRole();
Role outRole = reviewMgr.readRole( inRole );
printRole( outRole );
}
else if ( commands.contains( FIND_ROLES ) )
{
command = FIND_ROLES;
LOG.info( command );
String inRoleNm = options.getName();
List<Role> outRoles = reviewMgr.findRoles( inRoleNm );
if ( CollectionUtils.isNotEmpty( outRoles ) )
{
int ctr = 0;
for ( Role outRole : outRoles )
{
printSeparator();
printRow( "R", "ROLE[" + ++ctr + "]", outRole.getName() );
printRole( outRole );
}
}
}
else if ( commands.contains( ASSIGNED_ROLES ) )
{
command = ASSIGNED_ROLES;
LOG.info( command );
String userId = options.getUserId();
List<UserRole> uRoles = reviewMgr.assignedRoles( new User( userId ) );
if ( uRoles != null )
{
for ( UserRole ur : uRoles )
{
printTemporal( "R", ur, "RBACROLE" );
printSeparator();
}
}
}
else if ( commands.contains( READ_POBJ ) )
{
command = READ_POBJ;
LOG.info( command );
PermObj inPermObj = options.getPermObj();
PermObj outPermObj = reviewMgr.readPermObj( inPermObj );
printPermObj( outPermObj );
}
else if ( commands.contains( FIND_POBJS ) )
{
command = FIND_POBJS;
LOG.info( command );
PermObj inPermObj = options.getPermObj();
List<PermObj> outPermObjs = reviewMgr.findPermObjs( inPermObj );
if ( CollectionUtils.isNotEmpty( outPermObjs ) )
{
int ctr = 0;
for ( PermObj outPermObj : outPermObjs )
{
printSeparator();
printRow( "PO", "POBJ[" + ++ctr + "]", outPermObj.getObjName() );
printPermObj( outPermObj );
}
}
}
else if ( commands.contains( READ_PERM ) )
{
command = READ_PERM;
LOG.info( command );
Permission inPerm = options.getPermission();
Permission outPerm = reviewMgr.readPermission( inPerm );
printPermission( outPerm );
}
else if ( commands.contains( FIND_PERMS ) )
{
command = FIND_PERMS;
LOG.info( command );
Permission inPerm = options.getPermission();
List<Permission> outPerms = reviewMgr.findPermissions( inPerm );
if ( CollectionUtils.isNotEmpty( outPerms ) )
{
int ctr = 0;
for ( Permission outPerm : outPerms )
{
printSeparator();
printRow( "P", "PERM[" + ++ctr + "]", outPerm.getAbstractName() );
printPermission( outPerm );
}
}
}
else
{
LOG.warn( "unknown review operation detected" );
return;
}
LOG.info( "command:{} was successful", command );
}
catch ( SecurityException se )
{
String error = "processReviewCommand caught SecurityException=" + se + ", return code=" + se.getErrorId();
LOG.error( error );
}
}