use of com.sun.identity.policy.NameNotFoundException in project OpenAM by OpenRock.
the class PolicyModelImpl method getActiveConditionTypes.
/**
* Returns a map of active condition types for a realm to its display name.
*
* @param realmName Name of Realm.
* @return a map of active condition types for a realm to its display name.
*/
public Map getActiveConditionTypes(String realmName) {
Map condTypes = null;
try {
PolicyManager policyMgr = getPolicyManager(realmName);
if (policyMgr != null) {
ConditionTypeManager condTypeMgr = policyMgr.getConditionTypeManager();
if (condTypeMgr != null) {
Set types = condTypeMgr.getSelectedConditionTypeNames();
condTypes = new HashMap(types.size() * 2);
for (Iterator iter = types.iterator(); iter.hasNext(); ) {
String rName = (String) iter.next();
condTypes.put(rName, condTypeMgr.getDisplayName(rName));
}
}
}
} catch (AMConsoleException e) {
debug.warning("PolicyModelImpl.getActiveConditionTypes", e);
} catch (SSOException e) {
debug.warning("PolicyModelImpl.getActiveConditionTypes", e);
} catch (NameNotFoundException e) {
debug.warning("PolicyModelImpl.getActiveConditionTypes", e);
} catch (PolicyException e) {
debug.warning("PolicyModelImpl.getActiveConditionTypes", e);
}
return (condTypes == null) ? Collections.EMPTY_MAP : condTypes;
}
use of com.sun.identity.policy.NameNotFoundException in project OpenAM by OpenRock.
the class PolicyModelImpl method cachePolicy.
/**
* Caches an existing policy. Returns the cache ID of the policy object.
*
* @param realmName Name of realm.
* @param policyName Name of policy.
* @return cache ID of the policy object.
* @throws AMConsoleException if policy cannot be cached.
*/
public String cachePolicy(String realmName, String policyName) throws AMConsoleException {
try {
PolicyManager policyManager = getPolicyManager(realmName);
Policy policy = policyManager.getPolicy(policyName);
PolicyCache cache = PolicyCache.getInstance();
return cache.cachePolicy(getUserSSOToken(), new CachedPolicy(policy));
} catch (InvalidFormatException e) {
throw new AMConsoleException(getErrorString(e));
} catch (InvalidNameException e) {
throw new AMConsoleException(getErrorString(e));
} catch (NoPermissionException e) {
throw new AMConsoleException(getErrorString(e));
} catch (NameNotFoundException e) {
throw new AMConsoleException(getErrorString(e));
} catch (PolicyException e) {
throw new AMConsoleException(getErrorString(e));
} catch (SSOException e) {
throw new AMConsoleException(getErrorString(e));
}
}
use of com.sun.identity.policy.NameNotFoundException in project OpenAM by OpenRock.
the class PolicyModelImpl method createReferral.
/**
* Returns a referral object.
*
* @param realmName Name of Realm.
* @param referralType Name of referral type.
* @param values Values of the referral.
* @return referral obejct.
* @throws AMConsoleException if referral cannot be created.
*/
public Referral createReferral(String realmName, String referralType, Set values) throws AMConsoleException {
Referral referral = null;
try {
PolicyManager policyMgr = getPolicyManager(realmName);
if (policyMgr != null) {
ReferralTypeManager referralTypeMgr = policyMgr.getReferralTypeManager();
referral = referralTypeMgr.getReferral(referralType);
referral.setValues(values);
}
} catch (NameNotFoundException e) {
throw new AMConsoleException(getErrorString(e));
} catch (PolicyException e) {
throw new AMConsoleException(getErrorString(e));
}
return referral;
}
use of com.sun.identity.policy.NameNotFoundException in project OpenAM by OpenRock.
the class PolicyModelImpl method getActiveSubjectTypes.
/**
* Returns a map of active subject types for a realm to its display name.
*
* @param realmName Name of Realm.
* @return a map of active subject types for a realm to its display name.
*/
public QueryResults getActiveSubjectTypes(String realmName) {
Map subjectTypes = Collections.EMPTY_MAP;
String strError = null;
try {
PolicyManager policyMgr = getPolicyManager(realmName);
if (policyMgr != null) {
SubjectTypeManager subjectTypeMgr = policyMgr.getSubjectTypeManager();
if (subjectTypeMgr != null) {
Set types = subjectTypeMgr.getSelectedSubjectTypeNames();
subjectTypes = new HashMap(types.size() * 2);
for (Iterator iter = types.iterator(); iter.hasNext(); ) {
String rName = (String) iter.next();
try {
Subject subject = subjectTypeMgr.getSubject(rName);
if (subject != null) {
Syntax syntax = subject.getValueSyntax(getUserSSOToken());
if (!syntax.equals(Syntax.NONE)) {
subjectTypes.put(rName, subjectTypeMgr.getDisplayName(rName));
}
}
} catch (SSOException e) {
strError = getErrorString(e);
} catch (NameNotFoundException e) {
strError = getErrorString(e);
} catch (PolicyException e) {
strError = getErrorString(e);
}
}
}
}
} catch (AMConsoleException e) {
debug.error("PolicyModelImpl.getActiveSubjectTypes", e);
} catch (SSOException e) {
debug.error("PolicyModelImpl.getActiveSubjectTypes", e);
} catch (NameNotFoundException e) {
debug.error("PolicyModelImpl.getActiveSubjectTypes", e);
} catch (PolicyException e) {
debug.error("PolicyModelImpl.getActiveSubjectTypes", e);
}
return new QueryResults(subjectTypes, strError);
}
use of com.sun.identity.policy.NameNotFoundException in project OpenAM by OpenRock.
the class PolicyModelImpl method getDisplayNameForReferralValues.
/**
* Returns a map of values to localized label.
*
* @param realmName Name of realm.
* @param referralTypeName Name of referral Type.
* @param values Valid values.
* @return a map of values to localized label.
*/
public Map getDisplayNameForReferralValues(String realmName, String referralTypeName, Set values) {
Map map = null;
if ((values != null) && !values.isEmpty()) {
map = new HashMap(values.size() * 2);
Locale locale = getUserLocale();
try {
PolicyManager policyMgr = getPolicyManager(realmName);
if (policyMgr != null) {
ReferralTypeManager mgr = policyMgr.getReferralTypeManager();
Referral referral = mgr.getReferral(referralTypeName);
for (Iterator i = values.iterator(); i.hasNext(); ) {
String v = (String) i.next();
map.put(v, referral.getDisplayNameForValue(v, locale));
}
}
} catch (AMConsoleException e) {
debug.warning("PolicyModelImpl.getDisplayNameForReferralValues", e);
} catch (NameNotFoundException e) {
debug.warning("PolicyModelImpl.getDisplayNameForReferralValues", e);
} catch (PolicyException e) {
debug.warning("PolicyModelImpl.getDisplayNameForReferralValues", e);
}
}
return (map == null) ? Collections.EMPTY_MAP : map;
}
Aggregations