use of com.sun.identity.policy.PolicyManager in project OpenAM by OpenRock.
the class PolicyModelImpl method createCondition.
/**
* Returns a condition object.
*
* @param realmName Name of Realm.
* @param conditionType Name of condition type.
* @param values Values of the condition.
* @return condition object.
* @throws AMConsoleException if condition cannot be created.
*/
public Condition createCondition(String realmName, String conditionType, Map values) throws AMConsoleException {
Condition condition = null;
try {
PolicyManager policyMgr = getPolicyManager(realmName);
if (policyMgr != null) {
ConditionTypeManager conditionTypeMgr = policyMgr.getConditionTypeManager();
condition = conditionTypeMgr.getCondition(conditionType);
condition.setProperties(values);
}
} catch (NameNotFoundException e) {
throw new AMConsoleException(getErrorString(e));
} catch (PolicyException e) {
throw new AMConsoleException(getErrorString(e));
}
return condition;
}
use of com.sun.identity.policy.PolicyManager in project OpenAM by OpenRock.
the class ConfigureData method createPolicies.
private void createPolicies(String realmName, String xmlFile) throws FileNotFoundException, PolicyException, SSOException, IOException {
PolicyManager pm = new PolicyManager(ssoToken, realmName);
InputStreamReader fin = new InputStreamReader(AMSetupUtils.getResourceAsStream(sctx, xmlFile));
StringBuilder sbuf = new StringBuilder();
char[] cbuf = new char[1024];
int len;
while ((len = fin.read(cbuf)) > 0) {
sbuf.append(cbuf, 0, len);
}
String data = ServicesDefaultValues.tagSwap(sbuf.toString(), true);
ByteArrayInputStream bis = new ByteArrayInputStream(data.getBytes());
PolicyUtils.createPolicies(pm, bis);
}
use of com.sun.identity.policy.PolicyManager in project OpenAM by OpenRock.
the class OpenSSOPolicyDataStore method createPolicy.
private Object createPolicy(SSOToken adminToken, String realm, String xml) throws Exception, SSOException, PolicyException {
Object policy = null;
if (xml.startsWith("xmlpolicy=")) {
xml = xml.substring(10);
}
Document doc = XMLUtils.getXMLDocument(new ByteArrayInputStream(xml.getBytes("UTF8")));
if (EntitlementConfiguration.getInstance(SubjectUtils.createSubject(adminToken), "/").xacmlPrivilegeEnabled()) {
//TODO: create xacml policy from xml document
} else {
PolicyManager pm = new PolicyManager(adminToken, realm);
Node rootNode = XMLUtils.getRootNode(doc, PolicyManager.POLICY_ROOT_NODE);
policy = new Policy(pm, rootNode);
}
return policy;
}
use of com.sun.identity.policy.PolicyManager in project OpenAM by OpenRock.
the class PolicyPrivilegeManager method initialize.
/**
* Initializes the object
* @param subject subject that would be used for privilege management
* operations
*/
@Override
public void initialize(String realm, Subject subject) {
super.initialize(realm, subject);
this.realm = realm;
SSOToken ssoToken = SubjectUtils.getSSOToken(subject);
if (!migratedToEntitlementSvc) {
try {
pm = new PolicyManager(ssoToken, realm);
} catch (SSOException e) {
PrivilegeManager.debug.error("PolicyPrivilegeManager.initialize", e);
} catch (PolicyException e) {
PrivilegeManager.debug.error("PolicyPrivilegeManager.initialize", e);
}
}
}
use of com.sun.identity.policy.PolicyManager in project OpenAM by OpenRock.
the class IDPPTest method cleanup.
@AfterClass
public void cleanup() throws Exception {
if (!migrated) {
return;
}
PolicyManager policyMgr = new PolicyManager(adminToken, orgName);
policyMgr.removePolicy("IDPPTestPolicy1");
Set<AMIdentity> identities = new HashSet<AMIdentity>();
identities.add(user1);
identities.add(group1);
IdRepoUtils.deleteIdentities(orgName, identities);
}
Aggregations