use of com.sun.identity.policy.PolicyManager in project OpenAM by OpenRock.
the class PolicyModelImpl method getPolicyNames.
/**
* Returns policy names that are under a realm.
*
* @param realmName Name of realm.
* @param filter Filter string.
* @return policy names that are under a realm.
* @throws AMConsoleException if policy names cannot be returned.
*/
public Set getPolicyNames(String realmName, String filter) throws AMConsoleException {
Set names = null;
try {
String[] param = { realmName };
logEvent("ATTEMPT_GET_POLICY_NAMES", param);
PolicyManager policyManager = getPolicyManager(realmName);
names = policyManager.getPolicyNames(filter);
logEvent("SUCCEED_GET_POLICY_NAMES", param);
} catch (SSOException e) {
String strError = getErrorString(e);
String[] params = { realmName, strError };
logEvent("SSO_EXCEPTION_GET_POLICY_NAMES", params);
throw new AMConsoleException(strError);
} catch (PolicyException e) {
String strError = getErrorString(e);
String[] params = { realmName, strError };
logEvent("POLICY_EXCEPTION_GET_POLICY_NAMES", params);
throw new AMConsoleException(strError);
}
return (names != null) ? names : Collections.EMPTY_SET;
}
use of com.sun.identity.policy.PolicyManager 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.PolicyManager in project OpenAM by OpenRock.
the class PolicyModelImpl method canCreateNewResource.
/**
* Returns true of new resource can be created under a realm of a given
* service type.
*
* @param realmName Name of Realm.
* @param svcTypeName Name of Service Type.
* @return true of new resource can be created under a realm of a given
* service type.
*/
public boolean canCreateNewResource(String realmName, String svcTypeName) {
boolean can = false;
try {
PolicyManager mgr = getPolicyManager(realmName);
can = mgr.canCreateNewResource(svcTypeName);
} catch (AMConsoleException e) {
debug.warning("PolicyModelImpl.canCreateNewResource", e);
}
return can;
}
use of com.sun.identity.policy.PolicyManager 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;
}
use of com.sun.identity.policy.PolicyManager in project OpenAM by OpenRock.
the class PolicyModelImpl method getSubjectViewBeanURL.
/**
* Returns properties view bean URL of a subject.
*
* @param realmName Name of realm.
* @param subjectTypeName Name of Subject Type.
* @return properties view bean URL of a subject.
*/
public String getSubjectViewBeanURL(String realmName, String subjectTypeName) {
String url = null;
try {
PolicyManager policyMgr = getPolicyManager(realmName);
if (policyMgr != null) {
SubjectTypeManager subjectTypeMgr = policyMgr.getSubjectTypeManager();
Subject subject = subjectTypeMgr.getSubject(subjectTypeName);
url = subjectTypeMgr.getViewBeanURL(subject);
}
} catch (AMConsoleException e) {
debug.warning("PolicyModelImpl.getSubjectViewBeanURL", e);
} catch (NameNotFoundException e) {
debug.warning("PolicyModelImpl.getSubjectViewBeanURL", e);
} catch (PolicyException e) {
debug.warning("PolicyModelImpl.getSubjectViewBeanURL", e);
}
return url;
}
Aggregations