use of com.sun.identity.policy.Rule in project OpenAM by OpenRock.
the class RuleOpViewBeanBase method createRule.
protected Rule createRule() throws ModelControlException {
Rule rule = null;
String serviceType = (String) propertySheetModel.getValue(SERVICE_TYPE);
String ruleName = getRuleName();
Boolean b = ((Boolean) getPageSessionAttribute(WITH_RESOURCE));
boolean withResource = (b != null) ? b.booleanValue() : false;
String resourceName = (withResource) ? getResourceName() : null;
// Get action values if this is not a referral policy
actionValues = (!isReferralPolicy()) ? getActionValues(serviceType, withResource) : Collections.EMPTY_MAP;
if ((ruleName != null) && (!withResource || (resourceName != null)) && (actionValues != null)) {
rule = createRule(ruleName, serviceType, resourceName, actionValues);
}
return rule;
}
use of com.sun.identity.policy.Rule in project OpenAM by OpenRock.
the class PolicyModelImpl method getProtectedResourceNames.
public Set getProtectedResourceNames(String realmName, String policyName) throws AMConsoleException {
Set resourceNames = new HashSet();
String policyID = cachePolicy(realmName, policyName);
CachedPolicy cachedPolicy = getCachedPolicy(policyID);
Policy policy = cachedPolicy.getPolicy();
Set ruleNames = policy.getRuleNames();
if ((ruleNames != null) && !ruleNames.isEmpty()) {
for (Iterator iter = ruleNames.iterator(); iter.hasNext(); ) {
String ruleName = (String) iter.next();
try {
Rule rule = policy.getRule(ruleName);
if (rule != null) {
String resName = rule.getResourceName();
if ((resName != null) && (resName.trim().length() > 0)) {
resourceNames.add(resName);
}
}
} catch (NameNotFoundException nnfe) {
if (debug.warningEnabled()) {
debug.warning("Cannot find the rule with name '" + ruleName + " in policy " + policy.getName(), nnfe);
}
}
}
}
return resourceNames;
}
use of com.sun.identity.policy.Rule in project OpenAM by OpenRock.
the class PolicyModelImpl method getRuleNamesWithoutRes.
private Set getRuleNamesWithoutRes(Policy policy, String serviceTypeName) {
Set rules = getRules(policy);
Set selected = new HashSet(rules.size() * 2);
for (Iterator iter = rules.iterator(); iter.hasNext(); ) {
Rule rule = (Rule) iter.next();
if (rule.getServiceTypeName().equals(serviceTypeName)) {
String res = rule.getResourceName();
if (res == null) {
selected.add(rule.getName());
}
}
}
return selected;
}
use of com.sun.identity.policy.Rule in project OpenAM by OpenRock.
the class UpgradeUtils method createRealmAdminPolicy.
/**
* Creates Realm Admin Policy.
*
* @param policyManager the policy manager object.
* @param orgDN the organization dn.
* @param orgID the organization identifier.
*/
private static void createRealmAdminPolicy(PolicyManager policyManager, String orgDN, String orgID) {
String classMethod = "UpgradeUtils:createRealmAdminPolicy";
try {
String policyName = orgID + "^^RealmAdmin";
Policy realmPolicy = new Policy(policyName, null, false, true);
// create Rule
String resourceName = "sms://*" + orgDN + "/*";
Rule rule = getRule(DELEGATION_SERVICE, resourceName);
if (rule != null) {
realmPolicy.addRule(rule);
}
String universalID = getUniversalID(orgDN, ORG_ADMIN_ROLE);
Subject subject = getSubject(policyManager, universalID);
if (subject != null) {
realmPolicy.addSubject(DELEGATION_SUBJECT, subject, false);
}
policyManager.addPolicy(realmPolicy);
} catch (Exception e) {
debug.error(classMethod + "Error creating realm admin policy", e);
}
}
use of com.sun.identity.policy.Rule in project OpenAM by OpenRock.
the class UpgradeUtils method createDatastoresReadOnlyPolicy.
/**
* Creates DataStores Read Only Policy
*
* @param policyManager the policy manager object.
* @param orgDN the organization dn.
* @param orgID the organization identifier.
*/
private static void createDatastoresReadOnlyPolicy(PolicyManager policyManager, String orgDN, String orgID) {
String classMethod = "UpgradeUtils:createDatastoresReadOnlyPolicy";
try {
String policyName = orgID + "^^" + DATA_STORE_READ_ONLY;
Policy realmPolicy = new Policy(policyName, null, false, true);
// create Rule
String serviceName = DELEGATION_SERVICE;
String resourceName = "sms://*" + orgDN + "/" + IDREPO_SERVICE;
Rule rule = getRule(serviceName, resourceName);
if (rule != null) {
realmPolicy.addRule(rule);
}
// add subjects
String policyAdminRoleUniversalID = getUniversalID(orgDN, ORG_POLICY_ADMIN_ROLE);
Subject subject = getSubject(policyManager, policyAdminRoleUniversalID);
if (subject != null) {
realmPolicy.addSubject(DELEGATION_SUBJECT, subject, false);
}
policyManager.addPolicy(realmPolicy);
} catch (Exception e) {
debug.error(classMethod + "Error creating datastores readonly policy", e);
}
}
Aggregations