use of com.sun.identity.sm.AttributeSchema in project OpenAM by OpenRock.
the class SmsResourceProvider method addType.
private void addType(JsonValue result, String pointer, AttributeSchema attribute, ResourceBundle schemaI18n, ResourceBundle consoleI18n, Context context) {
String type = null;
AttributeSchema.Type attributeType = attribute.getType();
AttributeSchema.Syntax syntax = attribute.getSyntax();
if (attributeType == AttributeSchema.Type.LIST && (attribute.getUIType() == AttributeSchema.UIType.GLOBALMAPLIST || attribute.getUIType() == AttributeSchema.UIType.MAPLIST)) {
type = OBJECT_TYPE;
JsonValue fieldType = json(object());
if (attribute.hasChoiceValues()) {
addEnumChoices(fieldType, attribute, schemaI18n, consoleI18n, context);
} else {
fieldType.add(TYPE, STRING_TYPE);
}
result.addPermissive(new JsonPointer(pointer + "/" + PATTERN_PROPERTIES), object(field(".*", fieldType.getObject())));
} else if (attributeType == AttributeSchema.Type.LIST) {
type = ARRAY_TYPE;
result.addPermissive(new JsonPointer(pointer + "/" + ITEMS), object(field(TYPE, getTypeFromSyntax(attribute.getSyntax()))));
if (attribute.hasChoiceValues()) {
addEnumChoices(result.get(new JsonPointer(pointer + "/" + ITEMS)), attribute, schemaI18n, consoleI18n, context);
}
} else if (attributeType.equals(AttributeSchema.Type.MULTIPLE_CHOICE)) {
type = ARRAY_TYPE;
result.addPermissive(new JsonPointer(pointer + "/" + ITEMS), object(field(TYPE, getTypeFromSyntax(attribute.getSyntax()))));
addEnumChoices(result.get(new JsonPointer(pointer + "/" + ITEMS)), attribute, schemaI18n, consoleI18n, context);
} else if (attributeType.equals(AttributeSchema.Type.SINGLE_CHOICE)) {
addEnumChoices(result.get(new JsonPointer(pointer)), attribute, schemaI18n, consoleI18n, context);
} else {
type = getTypeFromSyntax(syntax);
}
if (type != null) {
result.addPermissive(new JsonPointer(pointer + "/" + TYPE), type);
}
if (AttributeSchema.Syntax.PASSWORD.equals(syntax)) {
result.addPermissive(new JsonPointer(pointer + "/" + FORMAT), PASSWORD_TYPE);
}
}
use of com.sun.identity.sm.AttributeSchema in project OpenAM by OpenRock.
the class PropertiesFinder method getProperty.
public static String getProperty(String propertyName, AttributeStruct ast) {
String value = null;
SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
try {
ServiceSchemaManager ssm = new ServiceSchemaManager(ast.serviceName, adminToken);
if (ssm.getRevisionNumber() >= ast.revisionNumber) {
ServiceSchema ss = ssm.getGlobalSchema();
if (ss != null) {
AttributeSchema as = ss.getAttributeSchema(ast.attributeName);
if (as != null) {
Set values = as.getDefaultValues();
if ((values != null) && !values.isEmpty()) {
value = (String) values.iterator().next();
}
}
}
}
} catch (SSOException ex) {
// ignore: Service may not be present.
} catch (SMSException ex) {
// ignore: Service may not be present.
}
return value;
}
use of com.sun.identity.sm.AttributeSchema in project OpenAM by OpenRock.
the class PossibleLocales method getChoiceValues.
/**
* Returns a map of locales to its localized name.
*
* @return a map of locales to its localized name.
*/
public Map getChoiceValues() {
Map map = new HashMap();
/*
* provides a blank value because preferred locale attribute value can
* be blanked.
*/
map.put("", "-");
ServiceSchemaManager mgr = getG11NServiceSchemaManager();
Set values = DEFAULT_LOCALES;
if (mgr != null) {
AttributeSchema attributeSchema = getLocaleCharsetMappingAttributeSchema(mgr);
if (attributeSchema != null) {
values = attributeSchema.getDefaultValues();
}
}
if ((values != null) && !values.isEmpty()) {
for (Iterator iter = values.iterator(); iter.hasNext(); ) {
String locale = parseLocaleCharsetValue((String) iter.next());
if ((locale != null) && (locale.length() > 0)) {
map.put(locale, locale);
}
}
}
return map;
}
use of com.sun.identity.sm.AttributeSchema in project OpenAM by OpenRock.
the class AgentConfiguration method getAttributesSchemaNames.
private static Set getAttributesSchemaNames(AMIdentity amid) throws SMSException, SSOException, IdRepoException {
Set results = new HashSet();
Set attributeSchemas = getAgentAttributeSchemas(getAgentType(amid));
if ((attributeSchemas != null) && !attributeSchemas.isEmpty()) {
for (Iterator i = attributeSchemas.iterator(); i.hasNext(); ) {
AttributeSchema as = (AttributeSchema) i.next();
results.add(as.getName());
}
}
return results;
}
use of com.sun.identity.sm.AttributeSchema in project OpenAM by OpenRock.
the class AgentConfiguration method getChoiceValues.
/**
* Returns choice values of an attribute schema.
*
* @param name Name of attribute schema.
* @param agentType Type of agent.
* @return choice values of an attribute schema.
* @throws SSOException if the Single Sign On token is invalid or has
* expired.
* @throws SMSException if there are errors in service management layers.
*/
public static Map getChoiceValues(String name, String agentType) throws SMSException, SSOException {
Map choiceValues = new HashMap();
AttributeSchema as = getAgentAttributeSchema(name, agentType);
if (as != null) {
String[] cValues = as.getChoiceValues();
if (cValues != null) {
for (int i = 0; i < cValues.length; i++) {
String v = cValues[i];
choiceValues.put(as.getChoiceValueI18NKey(v), v);
}
}
}
return choiceValues;
}
Aggregations