use of com.sun.identity.policy.PolicyManager in project OpenAM by OpenRock.
the class PolicyModelImpl method getActiveReferralTypes.
/**
* Returns a map of active referral types for a realm to its display name.
*
* @param realmName Name of Realm.
* @return a map of active referral types for a realm to its display name.
*/
public Map getActiveReferralTypes(String realmName) {
Map referralTypes = null;
try {
PolicyManager policyMgr = getPolicyManager(realmName);
if (policyMgr != null) {
ReferralTypeManager referralTypeMgr = policyMgr.getReferralTypeManager();
if (referralTypeMgr != null) {
Set types = referralTypeMgr.getSelectedReferralTypeNames();
referralTypes = new HashMap(types.size() * 2);
for (Iterator iter = types.iterator(); iter.hasNext(); ) {
String rName = (String) iter.next();
Referral referral = referralTypeMgr.getReferral(rName);
if (referral != null) {
Syntax syntax = referral.getValueSyntax(getUserSSOToken());
if (!syntax.equals(Syntax.NONE)) {
referralTypes.put(rName, referralTypeMgr.getDisplayName(rName));
}
}
}
}
}
} catch (AMConsoleException e) {
debug.warning("PolicyModelImpl.getActiveReferralTypes", e);
} catch (SSOException e) {
debug.warning("PolicyModelImpl.getActiveReferralTypes", e);
} catch (NameNotFoundException e) {
debug.warning("PolicyModelImpl.getActiveReferralTypes", e);
} catch (PolicyException e) {
debug.warning("PolicyModelImpl.getActiveReferralTypes", e);
}
return (referralTypes == null) ? Collections.EMPTY_MAP : referralTypes;
}
use of com.sun.identity.policy.PolicyManager in project OpenAM by OpenRock.
the class PolicyModelImpl method getManagedResources.
/**
* Returns a list of managed resource names.
*
* @param realmName Name of realm.
* @param serviceTypeName Name of service type.
* @return a list of managed resource names.
*/
public List getManagedResources(String realmName, String serviceTypeName) {
List managedResources = (List) mapSvcNameToManagedResource.get(serviceTypeName);
if (managedResources == null) {
managedResources = Collections.EMPTY_LIST;
try {
PolicyManager mgr = getPolicyManager(realmName);
if (mgr != null) {
Set resources = mgr.getManagedResourceNames(serviceTypeName);
if ((resources != null) && !resources.isEmpty()) {
managedResources = AMFormatUtils.sortItems(resources, getUserLocale());
}
}
} catch (PolicyException e) {
debug.warning("PolicyModelImpl.getManagedResources", e);
} catch (AMConsoleException e) {
debug.warning("PolicyModelImpl.getManagedResources", e);
}
mapSvcNameToManagedResource.put(serviceTypeName, managedResources);
}
return managedResources;
}
use of com.sun.identity.policy.PolicyManager in project OpenAM by OpenRock.
the class PrivilegePolicyMapping method cleanup.
@AfterClass
public void cleanup() throws Exception {
SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
IdRepoUtils.deleteIdentity("/", testUser);
PolicyManager pm = new PolicyManager(adminToken, "/");
pm.removePolicy(POLICY_NAME);
}
use of com.sun.identity.policy.PolicyManager in project OpenAM by OpenRock.
the class UpgradeUtils method removeDelegationPolicyAttribute.
/**
* Removes attribute from a condition.
*
* @param policyName Name of Policy.
* @param attributeName the name of the attribute to be removed.
* @param conditionName name of the condition
*/
public static void removeDelegationPolicyAttribute(String policyName, String attributeName, String conditionName) {
String classMethod = "UpgradeUtils:removeDelegationPolicyAttribute";
try {
PolicyManager pm = new PolicyManager(ssoToken, HIDDEN_REALM);
Policy policy = pm.getPolicy(policyName);
Condition cond = policy.getCondition(conditionName);
HashMap newMap = new HashMap();
if (cond != null) {
Map orig = cond.getProperties();
Iterator i = (orig.keySet()).iterator();
while (i.hasNext()) {
String key = (String) i.next();
if (!key.equals(attributeName)) {
HashSet values = (HashSet) orig.get(key);
newMap.put(key, values);
}
}
if (debug.messageEnabled()) {
debug.message(classMethod + "attributes :" + newMap);
}
cond.setProperties(newMap);
policy.replaceCondition(conditionName, cond);
}
pm.replacePolicy(policy);
} catch (PolicyException e) {
debug.error(classMethod, e);
} catch (SSOException e) {
debug.error(classMethod, e);
}
}
use of com.sun.identity.policy.PolicyManager in project OpenAM by OpenRock.
the class PolicyModelImpl method getResponseProviderInstance.
private ResponseProvider getResponseProviderInstance(String realmName, String typeName) {
ResponseProvider provider = null;
try {
PolicyManager policyMgr = getPolicyManager(realmName);
if (policyMgr != null) {
ResponseProviderTypeManager mgr = policyMgr.getResponseProviderTypeManager();
provider = mgr.getResponseProvider(typeName);
}
} catch (AMConsoleException e) {
debug.warning("PolicyModelImpl.getResponseProviderInstance", e);
} catch (NameNotFoundException e) {
debug.warning("PolicyModelImpl.getResponseProviderInstance", e);
} catch (PolicyException e) {
debug.warning("PolicyModelImpl.getResponseProviderInstance", e);
}
return provider;
}
Aggregations