PrivilegeAuthzModule.java revision ba07e74da87b2caf40d3397e50523632daeb4cac
/*
* The contents of this file are subject to the terms of the Common Development and
* Distribution License (the License). You may not use this file except in compliance with the
* License.
*
* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
* specific language governing permission and limitations under the License.
*
* When distributing Covered Software, include this CDDL Header Notice in each file and include
* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions copyright [year] [name of copyright owner]".
*
* Copyright 2014 ForgeRock AS.
*/
/**
* This authorisation module ties the calling subject back into the delegation privilege framework to
* verify whether the subject has been delegated the privilege to carry out the action they're attempting.
*
* @since 12.0.0
*/
public class PrivilegeAuthzModule implements CrestAuthorizationModule {
private final DelegationEvaluator evaluator;
private final DelegationPermissionFactory permissionFactory;
this.actionToDefinition = actionToDefinition;
this.permissionFactory = permissionFactory;
}
}
}
}
}
}
}
// Get the privilege definition for the CREST action.
if (definition == null) {
return Promises.newSuccessfulPromise(
}
}
/**
* Given the calling context and the privilege definition attempts to authorise the calling subject.
*
* @param context
* the server context
* @param definition
* the privilege definition
*
* @return the authorisation result
*/
final PrivilegeDefinition definition) {
// If no realm is specified default to the root realm.
// Map the set of actions to a set of action strings.
try {
// Authorisation has been approved.
}
} catch (DelegationException dE) {
return Promises.newFailedPromise(
} catch (SSOException ssoE) {
return Promises.newFailedPromise(
}
return Promises.newSuccessfulPromise(AuthorizationResult.failure("The user has insufficient privileges"));
}
/**
* Function converts an action to a string representation.
*/
private final static class ActionToStringMapper implements
}
}
}