use of org.apache.directory.fortress.core.model.Role in project directory-fortress-core by apache.
the class DelegatedAccessMgrConsole method canDeassign.
void canDeassign() {
try {
ReaderUtil.clearScreen();
System.out.println("Enter userId:");
User user = new User(ReaderUtil.readLn());
System.out.println("Enter role name:");
Role role = new Role(ReaderUtil.readLn());
boolean result = dAmgr.canDeassign(session, user, role);
System.out.println("Can Deassign User [" + user.getUserId() + "] Role [" + role.getName() + "] return [" + result + "]");
System.out.println("ENTER to continue");
} catch (SecurityException e) {
LOG.error("canDeassign caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
}
ReaderUtil.readChar();
}
use of org.apache.directory.fortress.core.model.Role in project directory-fortress-core by apache.
the class DelegatedAccessMgrConsole method canGrant.
void canGrant() {
try {
ReaderUtil.clearScreen();
System.out.println("Enter role name:");
Role role = new Role(ReaderUtil.readLn());
System.out.println("Enter perm object name:");
String objName = ReaderUtil.readLn();
boolean result = dAmgr.canGrant(session, role, new Permission(objName));
System.out.println("Can Assign Role [" + role.getName() + "] Object name [" + objName + "] return [" + result + "]");
System.out.println("ENTER to continue");
} catch (SecurityException e) {
LOG.error("canGrant caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
}
ReaderUtil.readChar();
}
use of org.apache.directory.fortress.core.model.Role in project directory-fortress-core by apache.
the class DelegatedAccessMgrConsole method canRevoke.
void canRevoke() {
try {
ReaderUtil.clearScreen();
System.out.println("Enter role name:");
Role role = new Role(ReaderUtil.readLn());
System.out.println("Enter perm object name:");
String objName = ReaderUtil.readLn();
boolean result = dAmgr.canRevoke(session, role, new Permission(objName));
System.out.println("Can Revoke Role [" + role.getName() + "] Object name [" + objName + "] return [" + result + "]");
System.out.println("ENTER to continue");
} catch (SecurityException e) {
LOG.error("canRevoke caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
}
ReaderUtil.readChar();
}
use of org.apache.directory.fortress.core.model.Role in project directory-fortress-core by apache.
the class ReviewMgrRestImpl method readRole.
/**
* {@inheritDoc}
*/
@Override
public Role readRole(Role role) throws SecurityException {
VUtil.assertNotNull(role, GlobalErrIds.ROLE_NULL, CLS_NM + ".readRole");
Role retRole;
FortRequest request = new FortRequest();
request.setContextId(this.contextId);
request.setEntity(role);
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ROLE_READ);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
retRole = (Role) response.getEntity();
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return retRole;
}
use of org.apache.directory.fortress.core.model.Role in project directory-fortress-core by apache.
the class ReviewMgrRestImpl method findRoles.
/**
* {@inheritDoc}
*/
@Override
public List<Role> findRoles(String searchVal) throws SecurityException {
VUtil.assertNotNull(searchVal, GlobalErrIds.ROLE_NM_NULL, CLS_NM + ".findRoles");
List<Role> retRoles;
FortRequest request = new FortRequest();
request.setContextId(this.contextId);
request.setValue(searchVal);
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ROLE_SEARCH);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
retRoles = response.getEntities();
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return retRoles;
}
Aggregations