use of org.apache.directory.fortress.core.model.Permission in project directory-fortress-core by apache.
the class DelAdminMgrRestImpl method updatePermission.
/**
* {@inheritDoc}
*/
@Override
public Permission updatePermission(Permission perm) throws SecurityException {
VUtil.assertNotNull(perm, GlobalErrIds.PERM_OPERATION_NULL, CLS_NM + ".updatePermission");
Permission retPerm;
FortRequest request = new FortRequest();
request.setContextId(this.contextId);
perm.setAdmin(true);
request.setEntity(perm);
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.PERM_UPDATE);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
retPerm = (Permission) response.getEntity();
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return retPerm;
}
use of org.apache.directory.fortress.core.model.Permission in project directory-fortress-core by apache.
the class DelAdminMgrRestImpl method addPermission.
/**
* {@inheritDoc}
*/
@Override
public Permission addPermission(Permission perm) throws SecurityException {
VUtil.assertNotNull(perm, GlobalErrIds.PERM_OPERATION_NULL, CLS_NM + ".addPermission");
Permission retPerm;
FortRequest request = new FortRequest();
request.setContextId(this.contextId);
perm.setAdmin(true);
request.setEntity(perm);
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.PERM_ADD);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
retPerm = (Permission) response.getEntity();
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return retPerm;
}
use of org.apache.directory.fortress.core.model.Permission in project directory-fortress-core by apache.
the class AdminMgrRestImpl method addPermission.
/**
* {@inheritDoc}
*/
@Override
public Permission addPermission(Permission perm) throws SecurityException {
VUtil.assertNotNull(perm, GlobalErrIds.PERM_OPERATION_NULL, CLS_NM + ".addPermission");
Permission retPerm;
FortRequest request = RestUtils.getRequest(this.contextId);
request.setEntity(perm);
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.PERM_ADD);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
retPerm = (Permission) response.getEntity();
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return retPerm;
}
use of org.apache.directory.fortress.core.model.Permission in project directory-fortress-core by apache.
the class ReviewMgrConsole method rolePermissions.
/**
*/
void rolePermissions() {
try {
System.out.println("Enter role name:");
String name = ReaderUtil.readLn();
List<Permission> list = rm.rolePermissions(new Role(name));
if (list != null) {
int ctr = 0;
for (Permission pe : list) {
System.out.println("**perm:" + (++ctr) + "***");
// System.out.println("perm operation [" + pe.operation + "]");
System.out.println("object name [" + pe.getObjName() + "]");
System.out.println("object id [" + pe.getObjId() + "]");
System.out.println("operation name [" + pe.getOpName() + "]");
System.out.println("abstract perm name [" + pe.getAbstractName() + "]");
System.out.println("internalId [" + pe.getInternalId() + "]");
if (pe.getUsers() != null && pe.getUsers().size() > 0) {
int ctr2 = 0;
for (String user : pe.getUsers()) {
System.out.println("user[" + ctr2++ + "]=" + user);
}
}
if (pe.getRoles() != null && pe.getRoles().size() > 0) {
int ctr2 = 0;
for (String role : pe.getRoles()) {
System.out.println("name[" + ctr2++ + "]=" + role);
}
}
if (pe.getProperties() != null && pe.getProperties().size() > 0) {
int pctr = 0;
for (Enumeration e = pe.getProperties().propertyNames(); e.hasMoreElements(); ) {
String key = (String) e.nextElement();
String val = pe.getProperty(key);
System.out.println("prop key[" + pctr + "]=" + key);
System.out.println("prop value[" + pctr++ + "]=" + val);
}
}
// prettyPrintFinePermissions(pe.getFinePerms());
System.out.println("**");
}
System.out.println("search complete");
System.out.println("ENTER to continue");
}
} catch (SecurityException e) {
LOG.error("rolePermissions 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 ReviewMgrConsole method permissionRoles.
/**
* Description of the Method
*/
void permissionRoles() {
Permission pe;
try {
Permission permission = new Permission();
ReaderUtil.clearScreen();
System.out.println("Enter perm object name:");
String name = ReaderUtil.readLn();
permission.setObjName(name);
System.out.println("Enter perm object id or null for none:");
String oid = ReaderUtil.readLn();
permission.setObjId(oid);
System.out.println("Enter perm operation name:");
String op = ReaderUtil.readLn();
permission.setOpName(op);
pe = rm.readPermission(permission);
if (pe != null) {
// System.out.println("perm operation [" + pe.operation + "]");
System.out.println("object name [" + pe.getObjName() + "]");
System.out.println("object id [" + pe.getObjId() + "]");
System.out.println("operation name [" + pe.getOpName() + "]");
System.out.println("abstract perm name [" + pe.getAbstractName() + "]");
System.out.println("internalId [" + pe.getInternalId() + "]");
if (pe.getRoles() != null && pe.getRoles().size() > 0) {
int ctr = 0;
for (String role : pe.getRoles()) {
System.out.println("name[" + ctr++ + "]=" + role);
}
}
System.out.println("**");
System.out.println("read operation complete");
System.out.println("ENTER to continue");
}
} catch (SecurityException e) {
LOG.error("permissionRoles caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
}
ReaderUtil.readChar();
}
Aggregations