use of com.sun.identity.sm.AttributeSchema in project OpenAM by OpenRock.
the class PropertyXMLBuilderBase method buildAttributeSchemaTypeXML.
protected void buildAttributeSchemaTypeXML(AttributeSchema as, StringBuffer xml, AMModel model, ResourceBundle serviceBundle, boolean addSubSection) {
String tagClassName = getTagClassName(as);
if (tagClassName != null) {
String name = getAttributeNameForPropertyXML(as);
boolean editableList = tagClassName.equals(TAGNAME_EDITABLE_LIST);
boolean orderedList = tagClassName.equals(TAGNAME_ORDERED_LIST);
boolean unorderedList = tagClassName.equals(TAGNAME_UNORDERED_LIST);
boolean mapList = tagClassName.equals(TAGNAME_MAP_LIST);
boolean globalMapList = tagClassName.equals(TAGNAME_GLOBAL_MAP_LIST);
AttributeSchema.Type type = as.getType();
AttributeSchema.UIType uitype = as.getUIType();
boolean addremovelist = type.equals(AttributeSchema.Type.MULTIPLE_CHOICE) && (uitype != null) && uitype.equals(AttributeSchema.UIType.ADDREMOVELIST);
boolean listTyped = editableList || orderedList || unorderedList || mapList || globalMapList || addremovelist;
if (listTyped && addSubSection) {
/*
* create a subsection without a title to hold the
* editable list component.
*/
xml.append(SUBSECTION_DUMMY_START_TAG);
}
if (needRequiredTag(as)) {
xml.append(PROPERTY_REQUIRED_START_TAG);
} else {
xml.append(PROPERTY_START_TAG);
}
addLabel(as, xml, serviceBundle);
if (addremovelist) {
xml.append(GROUP_START_TAG).append(PROPERTY_START_TAG);
appendAddRemoveListComponent(as, xml, serviceBundle);
addremovelist = true;
} else {
//need to handle link specially.
if (tagClassName.equals(TAGNAME_BUTTON)) {
String editString = model.getLocalizedString("label.edit");
Object[] pLink = { "'" + name + "'", editString };
xml.append(MessageFormat.format(COMPONENT_BUTTON_START_TAG, pLink));
} else if (tagClassName.equals(TAGNAME_HREF)) {
String editString = model.getLocalizedString("label.edit");
Object[] pLink = { PropertyTemplate.PARAM_ATTR_NAME + "=" + name + "&" + PropertyTemplate.PARAM_PROPERTIES_VIEW_BEAN_URL + "=" + as.getPropertiesViewBeanURL(), "linkLabel" + name, editString };
xml.append(MessageFormat.format(COMPONENT_LINK_START_TAG, pLink));
} else if (tagClassName.equals(TAGNAME_CHECKBOX)) {
Object[] param = { name, tagClassName, model.getLocalizedString("label.Enable") };
xml.append(MessageFormat.format(COMPONENT_BOOLEAN_START_TAG, param));
} else if (listTyped) {
/*
* putting the editable list component wihin a group tag
* to help isolate the list box and text box together on the
* page. Otherwise the list component blends in with other
* components on the page.
*/
Object[] param = { name, model.getLocalizedString("label.current.value"), model.getLocalizedString("label.new.value") };
xml.append(GROUP_START_TAG).append(PROPERTY_START_TAG);
if (editableList) {
xml.append(MessageFormat.format(COMPONENT_EDITABLE_LIST_START_TAG, param));
} else if (orderedList) {
xml.append(MessageFormat.format(COMPONENT_ORDERED_LIST_START_TAG, param));
} else if (unorderedList) {
xml.append(MessageFormat.format(COMPONENT_UNORDERED_LIST_START_TAG, param));
} else if (mapList) {
xml.append(MessageFormat.format(COMPONENT_MAP_LIST_START_TAG, param));
appendChoiceValues(as, xml, model, serviceBundle);
} else if (globalMapList) {
xml.append(MessageFormat.format(COMPONENT_GLOBAL_MAP_LIST_START_TAG, param));
}
} else {
Object[] param = { name, tagClassName };
xml.append(MessageFormat.format(COMPONENT_START_TAG, param));
/*
* if its a textarea component add the no localize attribute
* set the size of the text field based on its syntax
*/
if (tagClassName.equals(TAGNAME_TEXTFIELD)) {
Object[] pSize = { getStringFieldSize(as) };
xml.append(MessageFormat.format(TEXTBOX_SIZE_TAG, pSize));
xml.append(NON_LOCALIZED_FIELD);
xml.append(NO_AUTO_SUBMIT);
} else if (tagClassName.equals(TAGNAME_TEXTAREA)) {
final Map<String, String> sizeMap = getTextAreaSize(as);
if (!sizeMap.isEmpty()) {
Object[] textAreaSize = { sizeMap.get("columns"), sizeMap.get("rows") };
xml.append(MessageFormat.format(TEXTAREA_SIZE_TAG, textAreaSize));
}
xml.append(NON_LOCALIZED_FIELD);
} else if (tagClassName.equals(TAGNAME_PASSWORD)) {
xml.append(NO_AUTO_SUBMIT);
}
appendChoiceValues(as, xml, model, serviceBundle);
}
xml.append(COMPONENT_END_TAG);
}
if (type.equals(AttributeSchema.Type.MULTIPLE_CHOICE)) {
if ((uitype == null) || !uitype.equals(AttributeSchema.UIType.ADDREMOVELIST)) {
appendMultipleChoiceCheckboxes(as, xml, serviceBundle);
}
}
appendDateMarker(as, xml);
getInlineHelp(as, xml, serviceBundle);
xml.append(PROPERTY_END_TAG);
// close off the group and subsection tags for the editable list
if (listTyped) {
xml.append(GROUP_END_TAG).append("<p>").append(PROPERTY_END_TAG);
if (addSubSection) {
xml.append(SUBSECTION_END_TAG);
}
}
}
}
use of com.sun.identity.sm.AttributeSchema in project OpenAM by OpenRock.
the class PropertyXMLBuilderBase method getTagClassName.
static String getTagClassName(AttributeSchema as) {
String tagClassName = null;
AttributeSchema.UIType uitype = as.getUIType();
if (uitype != null) {
String val = (String) mapUITypeToName.get(uitype);
try {
tagClassName = properties.getString(val);
} catch (MissingResourceException e) {
// do nothing
}
}
AttributeSchema.Type type = as.getType();
String valType = (String) mapTypeToName.get(type);
if ((tagClassName == null) && (valType != null)) {
try {
tagClassName = properties.getString(valType);
} catch (MissingResourceException e) {
// do nothing
}
}
if (tagClassName == null) {
AttributeSchema.Syntax syntax = as.getSyntax();
String valSyntax = (String) mapSyntaxToName.get(syntax);
if (valSyntax != null) {
try {
tagClassName = properties.getString(valType + "." + valSyntax);
} catch (MissingResourceException e) {
// do nothing
}
}
}
// last try
if (tagClassName == null) {
try {
tagClassName = properties.getString(valType + ".whatever");
} catch (MissingResourceException e) {
// do nothing
}
}
if ((tagClassName != null) && (tagClassName.trim().length() == 0)) {
tagClassName = null;
}
return tagClassName;
}
use of com.sun.identity.sm.AttributeSchema in project OpenAM by OpenRock.
the class PropertyXMLBuilderBase method removeAttributeSchemaWithoutI18nKey.
/**
* Removes attribute schema that does not have <code>i18nKey</code>.
*
* @param attributeSchemas Set of Attribute Schemas.
*/
public static void removeAttributeSchemaWithoutI18nKey(Set attributeSchemas) {
for (Iterator iter = attributeSchemas.iterator(); iter.hasNext(); ) {
AttributeSchema as = (AttributeSchema) iter.next();
String i18n = as.getI18NKey();
if ((i18n == null) || (i18n.trim().length() == 0)) {
iter.remove();
}
}
}
use of com.sun.identity.sm.AttributeSchema in project OpenAM by OpenRock.
the class AMCrypt method decryptPasswords.
public static Map decryptPasswords(Map attributes, ServiceSchema serviceSchema) {
if (serviceSchema == null || attributes == null) {
return attributes;
}
Iterator iter = attributes.keySet().iterator();
while (iter.hasNext()) {
String attributeName = (String) (iter.next());
AttributeSchema as = serviceSchema.getAttributeSchema(attributeName);
if (as != null && (as.getSyntax().equals(AttributeSchema.Syntax.PASSWORD) || as.getSyntax().equals(AttributeSchema.Syntax.ENCRYPTED_PASSWORD))) {
Set valueSet = (Set) (attributes.get(attributeName));
if (valueSet != null) {
HashSet tmpValueSet = new HashSet(valueSet);
valueSet.clear();
Iterator valIter = tmpValueSet.iterator();
while (valIter.hasNext()) {
String value = (String) valIter.next();
if (value != null) {
value = (String) AccessController.doPrivileged(new DecodeAction(value));
}
valueSet.add(value);
}
}
}
}
return attributes;
}
use of com.sun.identity.sm.AttributeSchema in project OpenAM by OpenRock.
the class AMCrypt method encryptPasswords.
public static Map encryptPasswords(Map attributes, ServiceSchema serviceSchema) {
if (serviceSchema == null || attributes == null) {
return attributes;
}
Iterator iter = attributes.keySet().iterator();
while (iter.hasNext()) {
String attributeName = (String) (iter.next());
AttributeSchema as = serviceSchema.getAttributeSchema(attributeName);
if (as != null && (as.getSyntax().equals(AttributeSchema.Syntax.PASSWORD) || as.getSyntax().equals(AttributeSchema.Syntax.ENCRYPTED_PASSWORD))) {
Set valueSet = (Set) (attributes.get(attributeName));
if (valueSet != null) {
HashSet tmpValueSet = new HashSet(valueSet);
valueSet.clear();
Iterator valIter = tmpValueSet.iterator();
while (valIter.hasNext()) {
String value = (String) valIter.next();
if (value != null) {
value = (String) AccessController.doPrivileged(new EncodeAction(value));
}
valueSet.add(value);
}
}
}
}
return attributes;
}
Aggregations