use of com.sun.identity.policy.interfaces.Subject in project OpenAM by OpenRock.
the class PolicyModelImpl method getSubjectSyntax.
/**
* Returns syntax for a subject.
*
* @param realmName Name of Realm.
* @param subjectType Name of Subject type.
* @return syntax for a subject.
*/
public Syntax getSubjectSyntax(String realmName, String subjectType) {
Syntax syntax = Syntax.NONE;
try {
PolicyManager policyMgr = getPolicyManager(realmName);
if (policyMgr != null) {
SubjectTypeManager subjectTypeMgr = policyMgr.getSubjectTypeManager();
Subject subject = subjectTypeMgr.getSubject(subjectType);
syntax = subject.getValueSyntax(getUserSSOToken());
}
} catch (SSOException e) {
debug.warning("PolicyModelImpl.getActiveSubjectTypes", e);
} catch (NameNotFoundException e) {
debug.warning("PolicyModelImpl.getActiveSubjectTypes", e);
} catch (PolicyException e) {
debug.warning("PolicyModelImpl.getActiveSubjectTypes", e);
} catch (AMConsoleException e) {
debug.warning("PolicyModelImpl.getActiveSubjectTypes", e);
}
return syntax;
}
use of com.sun.identity.policy.interfaces.Subject in project OpenAM by OpenRock.
the class PolicyModelImpl method createSubject.
/**
* Returns a subject object.
*
* @param realmName Name of Realm.
* @param subjectType Name of subject type.
* @param values Values of the subject.
* @return subject object.
* @throws AMConsoleException if subject cannot be created.
*/
public Subject createSubject(String realmName, String subjectType, Set values) throws AMConsoleException {
Subject subject = null;
try {
PolicyManager policyMgr = getPolicyManager(realmName);
if (policyMgr != null) {
SubjectTypeManager subjectTypeMgr = policyMgr.getSubjectTypeManager();
subject = subjectTypeMgr.getSubject(subjectType);
subject.setValues(values);
}
} catch (NameNotFoundException e) {
throw new AMConsoleException(getErrorString(e));
} catch (PolicyException e) {
throw new AMConsoleException(getErrorString(e));
}
return subject;
}
use of com.sun.identity.policy.interfaces.Subject 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.interfaces.Subject 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;
}
use of com.sun.identity.policy.interfaces.Subject in project OpenAM by OpenRock.
the class PolicyManager method getPolicyUsingRealmSubject.
Policy getPolicyUsingRealmSubject(String subjectName) throws PolicyException, SSOException {
Policy policy = null;
Set policyNames = getPolicyNames();
for (Iterator policyIter = policyNames.iterator(); policyIter.hasNext(); ) {
String policyName = (String) policyIter.next();
Policy p = getPolicy(policyName);
Set subjectNames = p.getSubjectNames();
if (subjectNames.contains(subjectName)) {
Subject subject = p.getSubject(subjectName);
if (subject instanceof SharedSubject) {
policy = p;
break;
}
}
}
return policy;
}
Aggregations