use of com.sun.identity.entitlement.EntitlementConfiguration in project OpenAM by OpenRock.
the class PolicyManager method initialise.
private static void initialise() {
// Do this outside of a static block to avoid issues on container shutdown/restart
adminSubject = SubjectUtils.createSubject((SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance()));
EntitlementConfiguration ec = EntitlementConfiguration.getInstance(adminSubject, "/");
migratedToEntitlementService = ec.migratedToEntitlementService();
}
use of com.sun.identity.entitlement.EntitlementConfiguration in project OpenAM by OpenRock.
the class SubRealmObserver method registerListener.
private static void registerListener() {
SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
EntitlementConfiguration ec = EntitlementConfiguration.getInstance(SubjectUtils.createSubject(adminToken), "/");
if (ec.migratedToEntitlementService()) {
try {
ServiceConfigManager scm = new ServiceConfigManager(IdConstants.REPO_SERVICE, adminToken);
scm.addListener(new SubRealmObserver());
} catch (SMSException e) {
PrivilegeManager.debug.error("SubRealmObserver.registerListener", e);
} catch (SSOException e) {
PrivilegeManager.debug.error("SubRealmObserver.registerListener", e);
}
}
}
use of com.sun.identity.entitlement.EntitlementConfiguration in project OpenAM by OpenRock.
the class EntitlementServiceTest method hasEntitlementDITs.
@Test
public void hasEntitlementDITs() {
SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
EntitlementConfiguration ec = EntitlementConfiguration.getInstance(SubjectUtils.createSubject(adminToken), "/");
boolean result = ec.hasEntitlementDITs();
UnittestLog.logMessage("EntitlementServiceTest.hasEntitlementDITs: returns " + result);
}
use of com.sun.identity.entitlement.EntitlementConfiguration in project OpenAM by OpenRock.
the class CreateXACML method ensureEntitlementServiceActive.
private void ensureEntitlementServiceActive(Subject adminSubject, String realm) throws CLIException {
// FIXME: change to use entitlementService.xacmlPrivilegEnabled()
EntitlementConfiguration ec = EntitlementConfiguration.getInstance(adminSubject, "/");
if (!ec.migratedToEntitlementService()) {
String[] args = { realm, "ANY", "create-xacml not supported in legacy policy mode" };
debugError("CreateXACML.handleRequest(): create-xacml not supported in legacy policy mode");
writeLog(LOG_ERROR, INFO, "FAILED_CREATE_POLICY_IN_REALM", args);
throw new CLIException(getResourceString("create-xacml-not-supported-in-legacy-policy-mode"), ExitCodes.REQUEST_CANNOT_BE_PROCESSED, "create-xacml");
}
}
use of com.sun.identity.entitlement.EntitlementConfiguration in project OpenAM by OpenRock.
the class DeleteXACML method handleRequest.
/**
* Services a Commandline Request.
*
* @param rc Request Context.
* @throws CLIException if the request cannot serviced.
*/
public void handleRequest(RequestContext rc) throws CLIException {
super.handleRequest(rc);
ldapLogin();
SSOToken adminSSOToken = getAdminSSOToken();
Subject adminSubject = SubjectUtils.createSubject(adminSSOToken);
String realm = getStringOptionValue(IArgument.REALM_NAME);
// FIXME: change to use entitlementService.xacmlPrivilegEnabled()
EntitlementConfiguration ec = EntitlementConfiguration.getInstance(adminSubject, "/");
if (!ec.migratedToEntitlementService()) {
String[] args = { realm, "ANY", "list-xacml not supported in legacy policy mode" };
debugError("DeleteXACML.handleRequest(): " + "delete-xacml not supported in legacy policy mode");
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_DELETE_POLICY_IN_REALM", args);
throw new CLIException(getResourceString("delete-xacml-not-supported-in-legacy-policy-mode"), ExitCodes.REQUEST_CANNOT_BE_PROCESSED, "delete-xacml");
}
List policyNames = (List) rc.getOption(ARGUMENT_POLICY_NAMES);
String file = getStringOptionValue(IArgument.FILE);
if (policyNames == null) {
policyNames = new ArrayList();
}
if (file != null) {
policyNames.addAll(AttributeValues.parseValues(file));
}
if (policyNames.isEmpty()) {
throw new CLIException(getResourceString("missing-policy-names"), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
IOutput outputWriter = getOutputWriter();
String currentPolicyName = null;
try {
PrivilegeManager pm = PrivilegeManager.getInstance(realm, adminSubject);
String[] params = new String[2];
params[0] = realm;
for (Iterator i = policyNames.iterator(); i.hasNext(); ) {
currentPolicyName = (String) i.next();
params[1] = currentPolicyName;
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_DELETE_POLICY_IN_REALM", params);
pm.remove(currentPolicyName);
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_DELETE_POLICY_IN_REALM", params);
}
String[] arg = { realm };
outputWriter.printlnMessage(MessageFormat.format(getResourceString("delete-policy-in-realm-succeed"), (Object[]) arg));
} catch (EntitlementException e) {
String[] args = { realm, currentPolicyName, e.getMessage() };
debugError("DeleteXACML.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_DELETE_POLICY_IN_REALM", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
Aggregations