use of com.sun.identity.policy.Syntax in project OpenAM by OpenRock.
the class PolicyModelImpl method getReferralSyntax.
/**
* Returns syntax for a referral.
*
* @param realmName Name of Realm.
* @param referralType Name of referral type.
* @return syntax for a referral.
*/
public Syntax getReferralSyntax(String realmName, String referralType) {
Syntax syntax = Syntax.NONE;
try {
PolicyManager policyMgr = getPolicyManager(realmName);
if (policyMgr != null) {
ReferralTypeManager referralTypeMgr = policyMgr.getReferralTypeManager();
Referral referral = referralTypeMgr.getReferral(referralType);
syntax = referral.getValueSyntax(getUserSSOToken());
}
} catch (SSOException e) {
debug.warning("PolicyModelImpl.getActiveReferralTypes", e);
} catch (NameNotFoundException e) {
debug.warning("PolicyModelImpl.getActiveReferralTypes", e);
} catch (PolicyException e) {
debug.warning("PolicyModelImpl.getActiveReferralTypes", e);
} catch (AMConsoleException e) {
debug.warning("PolicyModelImpl.getReferralActionSchema", e);
}
return syntax;
}
use of com.sun.identity.policy.Syntax 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.Syntax 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.Syntax in project OpenAM by OpenRock.
the class PolicyPropertyXMLBuilderBase method buildXML.
private void buildXML(String name, StringBuffer xml) {
Syntax syntax = getPropertySyntax(name);
String tagClassName = getTagClassName(syntax);
if (tagClassName != null) {
xml.append(PROPERTY_START_TAG);
Object[] params = new String[3];
params[0] = name;
params[2] = name;
try {
params[1] = getDisplayName(name, model.getUserLocale());
} catch (PolicyException e) {
debug.warning("PropertyXMLBuilderBase.buildXML", e);
params[1] = name;
}
xml.append(MessageFormat.format(LABEL_TAG, params));
if (allAttributesReadonly) {
Object[] param = { name, STATIC_TEXT_TAG_NAME };
xml.append(MessageFormat.format(COMPONENT_START_TAG, param));
} else {
Object[] param = { name, tagClassName };
xml.append(MessageFormat.format(COMPONENT_START_TAG, param));
// localize the data unless this attribute is set to false
if (tagClassName.equals(TAGNAME_TEXTAREA)) {
xml.append(NON_LOCALIZED_FIELD);
} else if (tagClassName.equals(TAGNAME_TEXTFIELD)) {
// set the size of the text field based on its syntax
Object[] pSize = { getStringFieldSize(syntax) };
xml.append(MessageFormat.format(TEXTBOX_SIZE_TAG, pSize));
xml.append(NON_LOCALIZED_FIELD);
} else if (tagClassName.equals(TAGNAME_MULTIPLE_CHOICE)) {
xml.append(MULTIPLE_ATTRIBUTE_TAG).append(LIST_SIZE_TAG);
}
appendChoiceValues(name, syntax, xml);
}
xml.append(COMPONENT_END_TAG);
xml.append(PROPERTY_END_TAG);
}
}
use of com.sun.identity.policy.Syntax in project OpenAM by OpenRock.
the class SelectSubjectTypeViewBean method forwardToViewBean.
private void forwardToViewBean(PolicyModel model, String subjectType, String realmName) {
Syntax syntax = model.getSubjectSyntax(realmName, subjectType);
int displaySyntax = AMDisplayType.getDisplaySyntax(syntax);
SubjectAddViewBean vb = null;
switch(displaySyntax) {
case AMDisplayType.SYNTAX_TEXT:
case AMDisplayType.SYNTAX_SINGLE_CHOICE:
case AMDisplayType.SYNTAX_MULTIPLE_CHOICE:
vb = (SubjectAddViewBean) getViewBean(SubjectAddViewBean.class);
break;
default:
vb = (SubjectNoneAddViewBean) getViewBean(SubjectNoneAddViewBean.class);
break;
}
setPageSessionAttribute(SubjectOpViewBeanBase.PG_SESSION_SUBJECT_TYPE, subjectType);
passPgSessionMap(vb);
vb.forwardTo(getRequestContext());
}
Aggregations