use of org.apache.directory.fortress.core.model.Permission in project directory-fortress-core by apache.
the class DelegatedAccessMgrConsole method checkAccess.
void checkAccess() {
try {
VUtil.assertNotNull(session, GlobalErrIds.USER_SESS_NULL, ".checkAccess");
ReaderUtil.clearScreen();
System.out.println("Enter object name:");
String objName = ReaderUtil.readLn();
System.out.println("Enter operation name:");
String opName = ReaderUtil.readLn();
boolean result = dAmgr.checkAccess(session, new Permission(objName, opName));
System.out.println("CheckAccess return [" + result + "] for user [" + session.getUserId() + "] objName [" + objName + "] operationName [" + opName + "]");
System.out.println("ENTER to continue");
} catch (SecurityException e) {
LOG.error("checkAccess caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
}
ReaderUtil.readChar();
}
use of org.apache.directory.fortress.core.model.Permission 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.Permission 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.Permission in project directory-fortress-core by apache.
the class ReviewMgrRestImpl method findAnyPermissions.
/**
* {@inheritDoc}
*/
@Override
public List<Permission> findAnyPermissions(Permission permission) throws SecurityException {
VUtil.assertNotNull(permission, GlobalErrIds.PERM_OPERATION_NULL, CLS_NM + ".findAnyPermissions");
List<Permission> retPerms;
FortRequest request = new FortRequest();
request.setContextId(this.contextId);
request.setEntity(permission);
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.PERM_SEARCH_ANY);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
retPerms = response.getEntities();
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return retPerms;
}
use of org.apache.directory.fortress.core.model.Permission in project directory-fortress-core by apache.
the class ReviewMgrRestImpl method userPermissions.
/**
* {@inheritDoc}
*/
@Override
public List<Permission> userPermissions(User user) throws SecurityException {
VUtil.assertNotNull(user, GlobalErrIds.USER_NULL, CLS_NM + ".userPermissions");
List<Permission> retPerms;
FortRequest request = new FortRequest();
request.setContextId(this.contextId);
request.setEntity(user);
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.USER_PERMS);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
retPerms = response.getEntities();
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return retPerms;
}
Aggregations