Search in sources :

Example 26 with SecurityException

use of org.apache.directory.fortress.core.SecurityException in project directory-fortress-core by apache.

the class ConfigMgrRestImpl method add.

/**
 * {@inheritDoc}
 */
@Override
public Properties add(String name, Properties inProperties) throws SecurityException {
    VUtil.assertNotNull(name, GlobalErrIds.FT_CONFIG_NAME_NULL, CLS_NM + ".add");
    VUtil.assertNotNull(inProperties, GlobalErrIds.FT_CONFIG_PROPS_NULL, CLS_NM + ".add");
    Properties retProperties;
    FortRequest request = new FortRequest();
    Props inProps = RestUtils.getProps(inProperties);
    request.setEntity(inProps);
    request.setValue(name);
    String szRequest = RestUtils.marshal(request);
    String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.CFG_ADD);
    FortResponse response = RestUtils.unmarshall(szResponse);
    if (response.getErrorCode() == 0) {
        Props outProps = (Props) response.getEntity();
        retProperties = RestUtils.getProperties(outProps);
    } else {
        throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
    }
    return retProperties;
}
Also used : FortResponse(org.apache.directory.fortress.core.model.FortResponse) SecurityException(org.apache.directory.fortress.core.SecurityException) Properties(java.util.Properties) Props(org.apache.directory.fortress.core.model.Props) FortRequest(org.apache.directory.fortress.core.model.FortRequest)

Example 27 with SecurityException

use of org.apache.directory.fortress.core.SecurityException in project directory-fortress-core by apache.

the class ConfigMgrRestImpl method read.

/**
 * {@inheritDoc}
 */
@Override
public Properties read(String name) throws SecurityException {
    VUtil.assertNotNull(name, GlobalErrIds.FT_CONFIG_NAME_NULL, CLS_NM + ".readRole");
    Properties retProps;
    FortRequest request = new FortRequest();
    request.setValue(name);
    String szRequest = RestUtils.marshal(request);
    String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.CFG_READ);
    FortResponse response = RestUtils.unmarshall(szResponse);
    Props props;
    if (response.getErrorCode() == 0) {
        props = (Props) response.getEntity();
        retProps = RestUtils.getProperties(props);
    } else {
        throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
    }
    return retProps;
}
Also used : FortResponse(org.apache.directory.fortress.core.model.FortResponse) SecurityException(org.apache.directory.fortress.core.SecurityException) Properties(java.util.Properties) Props(org.apache.directory.fortress.core.model.Props) FortRequest(org.apache.directory.fortress.core.model.FortRequest)

Example 28 with SecurityException

use of org.apache.directory.fortress.core.SecurityException in project directory-fortress-core by apache.

the class DelAccessMgrRestImpl method canGrant.

/**
 * {@inheritDoc}
 */
@Override
public boolean canGrant(Session session, Role role, Permission perm) throws SecurityException {
    String methodName = CLS_NM + "canGrant";
    VUtil.assertNotNull(session, GlobalErrIds.USER_SESS_NULL, methodName);
    VUtil.assertNotNull(perm, GlobalErrIds.PERM_OBJECT_NULL, methodName);
    VUtil.assertNotNull(role, GlobalErrIds.ROLE_NULL, methodName);
    boolean result;
    FortRequest request = new FortRequest();
    request.setContextId(this.contextId);
    RolePerm context = new RolePerm();
    context.setPerm(perm);
    context.setRole(role);
    request.setSession(session);
    request.setEntity(context);
    String szRequest = RestUtils.marshal(request);
    String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ADMIN_GRANT);
    FortResponse response = RestUtils.unmarshall(szResponse);
    if (response.getErrorCode() == 0) {
        result = response.getAuthorized();
        Session outSession = response.getSession();
        session.copy(outSession);
    } else {
        throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
    }
    return result;
}
Also used : RolePerm(org.apache.directory.fortress.core.model.RolePerm) FortResponse(org.apache.directory.fortress.core.model.FortResponse) SecurityException(org.apache.directory.fortress.core.SecurityException) FortRequest(org.apache.directory.fortress.core.model.FortRequest) Session(org.apache.directory.fortress.core.model.Session)

Example 29 with SecurityException

use of org.apache.directory.fortress.core.SecurityException in project directory-fortress-core by apache.

the class DelAccessMgrRestImpl method checkAccess.

/**
 * {@inheritDoc}
 */
@Override
public boolean checkAccess(Session session, Permission perm) throws SecurityException {
    String methodName = CLS_NM + ".checkAccess";
    VUtil.assertNotNull(perm, GlobalErrIds.PERM_NULL, methodName);
    VUtil.assertNotNullOrEmpty(perm.getOpName(), GlobalErrIds.PERM_OPERATION_NULL, methodName);
    VUtil.assertNotNullOrEmpty(perm.getObjName(), GlobalErrIds.PERM_OBJECT_NULL, methodName);
    VUtil.assertNotNull(session, GlobalErrIds.USER_SESS_NULL, methodName);
    boolean result;
    FortRequest request = new FortRequest();
    request.setContextId(this.contextId);
    request.setSession(session);
    request.setEntity(perm);
    String szRequest = RestUtils.marshal(request);
    String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ADMIN_AUTHZ);
    FortResponse response = RestUtils.unmarshall(szResponse);
    if (response.getErrorCode() == 0) {
        result = response.getAuthorized();
        Session outSession = response.getSession();
        session.copy(outSession);
    } else {
        throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
    }
    return result;
}
Also used : FortResponse(org.apache.directory.fortress.core.model.FortResponse) SecurityException(org.apache.directory.fortress.core.SecurityException) FortRequest(org.apache.directory.fortress.core.model.FortRequest) Session(org.apache.directory.fortress.core.model.Session)

Example 30 with SecurityException

use of org.apache.directory.fortress.core.SecurityException in project directory-fortress-core by apache.

the class DelAccessMgrRestImpl method authorizedAdminRoles.

/**
 * {@inheritDoc}
 */
@Override
public Set<String> authorizedAdminRoles(Session session) throws SecurityException {
    VUtil.assertNotNull(session, GlobalErrIds.USER_SESS_NULL, CLS_NM + ".authorizedAdminRoles");
    Set<String> retRoleNames = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
    FortRequest request = new FortRequest();
    request.setContextId(this.contextId);
    request.setSession(session);
    String szRequest = RestUtils.marshal(request);
    String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ADMIN_AUTHZ_ROLES);
    FortResponse response = RestUtils.unmarshall(szResponse);
    if (response.getErrorCode() == 0) {
        Set<String> tempNames = response.getValueSet();
        // This is done to use a case insensitive TreeSet for returned names.
        retRoleNames.addAll(tempNames);
        Session outSession = response.getSession();
        session.copy(outSession);
    } else {
        throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
    }
    return retRoleNames;
// throw new java.lang.UnsupportedOperationException();
}
Also used : TreeSet(java.util.TreeSet) FortResponse(org.apache.directory.fortress.core.model.FortResponse) SecurityException(org.apache.directory.fortress.core.SecurityException) FortRequest(org.apache.directory.fortress.core.model.FortRequest) Session(org.apache.directory.fortress.core.model.Session)

Aggregations

SecurityException (org.apache.directory.fortress.core.SecurityException)441 FortRequest (org.apache.directory.fortress.core.model.FortRequest)152 FortResponse (org.apache.directory.fortress.core.model.FortResponse)152 User (org.apache.directory.fortress.core.model.User)125 AdminMgr (org.apache.directory.fortress.core.AdminMgr)89 UserRole (org.apache.directory.fortress.core.model.UserRole)88 Role (org.apache.directory.fortress.core.model.Role)66 ReviewMgr (org.apache.directory.fortress.core.ReviewMgr)65 Session (org.apache.directory.fortress.core.model.Session)59 Permission (org.apache.directory.fortress.core.model.Permission)56 AccessMgr (org.apache.directory.fortress.core.AccessMgr)41 DelAdminMgr (org.apache.directory.fortress.core.DelAdminMgr)39 SDSet (org.apache.directory.fortress.core.model.SDSet)37 OrgUnit (org.apache.directory.fortress.core.model.OrgUnit)36 RoleConstraint (org.apache.directory.fortress.core.model.RoleConstraint)34 UserAdminRole (org.apache.directory.fortress.core.model.UserAdminRole)33 AdminRole (org.apache.directory.fortress.core.model.AdminRole)25 PermObj (org.apache.directory.fortress.core.model.PermObj)22 Group (org.apache.directory.fortress.core.model.Group)19 PwPolicyMgr (org.apache.directory.fortress.core.PwPolicyMgr)17