use of com.sun.identity.sm.AttributeSchema in project OpenAM by OpenRock.
the class SMDiscoveryServiceModelImpl method getDiscoEntry.
/**
* Returns resource offering entry stored in the model map for a given
* type.
*
* @param dynamic value to indicate if it is a dynamic or not.
* @return resource offering entry stored in the model map for a given
* type.
*/
public Set getDiscoEntry(boolean dynamic) {
Set set = null;
if (dynamic) {
// TO FIX
} else {
ServiceSchemaManager mgr = getServiceSchemaManager();
try {
ServiceSchema schema = mgr.getSchema(SchemaType.GLOBAL);
AttributeSchema as = schema.getAttributeSchema(AMAdminConstants.DISCOVERY_SERVICE_NAME_BOOTSTRAP_RES_OFF);
set = as.getDefaultValues();
} catch (SMSException e) {
debug.error("SMDiscoveryServiceModelImpl.getDiscoEntry", e);
}
}
return set;
}
use of com.sun.identity.sm.AttributeSchema in project OpenAM by OpenRock.
the class SCModelBase method getAttributeValues.
private Map getAttributeValues(ServiceSchema schema, Set attributes) {
Map values = new HashMap(attributes.size() * 2);
for (Iterator x = attributes.iterator(); x.hasNext(); ) {
String attributeName = (String) x.next();
AttributeSchema as = (AttributeSchema) schema.getAttributeSchema(attributeName);
if (as != null) {
AttributeSchema.Type type = as.getType();
if ((type == AttributeSchema.Type.MULTIPLE_CHOICE) || (type == AttributeSchema.Type.SINGLE_CHOICE)) {
Map m = new HashMap(4);
m.put(AMAdminConstants.CHOICES, AMAdminUtils.toSet(as.getChoiceValues()));
m.put(AMAdminConstants.VALUES, as.getDefaultValues());
values.put(as.getName(), m);
} else {
values.put(as.getName(), as.getDefaultValues());
}
}
}
return (values == null) ? Collections.EMPTY_MAP : values;
}
use of com.sun.identity.sm.AttributeSchema in project OpenAM by OpenRock.
the class AMClientCapData method getSchemaMap.
/**
* Cache for the attribute schemas.
*/
private static synchronized Map getSchemaMap() {
if (schemaMap == null) {
Set set = clientSchema.getAttributeSchemas();
schemaMap = new HashMap();
Iterator itr = set.iterator();
while (itr.hasNext()) {
AttributeSchema prop = (AttributeSchema) itr.next();
String name = prop.getName();
schemaMap.put(name, prop);
}
}
return schemaMap;
}
use of com.sun.identity.sm.AttributeSchema in project OpenAM by OpenRock.
the class EntitiesModelImpl method getAttributeValues.
/**
* Returns attribute values of an entity object.
*
* @param universalId Universal ID of the entity.
* @param bCreate true for creation page
* @return attribute values of an entity object.
* @throws AMConsoleException if object cannot located.
*/
public Map getAttributeValues(String universalId, boolean bCreate) throws AMConsoleException {
String[] param = { universalId, "*" };
logEvent("ATTEMPT_READ_IDENTITY_ATTRIBUTE_VALUE", param);
try {
AMIdentity amid = IdUtils.getIdentity(getUserSSOToken(), universalId);
Map tempMap = new CaseInsensitiveHashMap();
tempMap.putAll(amid.getAttributes());
validateUserStatusEntry(tempMap);
Map values = new HashMap();
String agentType = null;
boolean webJ2EEagent = false;
Set agentTypes = amid.getAttribute("AgentType");
if ((agentTypes != null) && !agentTypes.isEmpty()) {
agentType = (String) agentTypes.iterator().next();
webJ2EEagent = agentType.equals(AgentConfiguration.AGENT_TYPE_J2EE) || agentType.equals(AgentConfiguration.AGENT_TYPE_WEB) || agentType.equals(AgentConfiguration.AGENT_TYPE_AGENT_AUTHENTICATOR);
}
Set attributeSchemas = getAttributeSchemas(amid.getType().getName(), agentType, bCreate);
Set attributeNames = new HashSet();
for (Iterator iter = attributeSchemas.iterator(); iter.hasNext(); ) {
AttributeSchema as = (AttributeSchema) iter.next();
String name = as.getName();
if (!tempMap.containsKey(name)) {
values.put(name, Collections.EMPTY_SET);
} else {
if (webJ2EEagent && name.equals(AGENT_ATTRIBUTE_LIST)) {
Set newValues = new HashSet();
Set temp = (Set) tempMap.get(name);
for (Iterator i = temp.iterator(); i.hasNext(); ) {
String val = (String) i.next();
if (val.startsWith(AGENT_ROOT_URL)) {
val = val.substring(AGENT_ROOT_URL.length());
}
newValues.add(val);
}
values.put(name, newValues);
} else {
values.put(name, tempMap.get(name));
}
}
attributeNames.add(name);
}
for (Iterator iter = values.keySet().iterator(); iter.hasNext(); ) {
String name = (String) iter.next();
if (!attributeNames.contains(name)) {
iter.remove();
}
}
logEvent("SUCCEED_READ_IDENTITY_ATTRIBUTE_VALUE", param);
return values;
} catch (IdRepoException e) {
String[] paramsEx = { universalId, "*", getErrorString(e) };
logEvent("IDM_EXCEPTION_READ_IDENTITY_ATTRIBUTE_VALUE", paramsEx);
debug.warning("EntitiesModelImpl.getAttributeValues", e);
throw new AMConsoleException(getErrorString(e));
} catch (SMSException e) {
String[] paramsEx = { universalId, "*", getErrorString(e) };
logEvent("SMS_EXCEPTION_READ_IDENTITY_ATTRIBUTE_VALUE", paramsEx);
debug.warning("EntitiesModelImpl.getAttributeValues", e);
throw new AMConsoleException(getErrorString(e));
} catch (SSOException e) {
String[] paramsEx = { universalId, "*", getErrorString(e) };
logEvent("SSO_EXCEPTION_READ_IDENTITY_ATTRIBUTE_VALUE", paramsEx);
debug.warning("EntitiesModelImpl.getAttributeValues", e);
throw new AMConsoleException(getErrorString(e));
}
}
use of com.sun.identity.sm.AttributeSchema in project OpenAM by OpenRock.
the class EntitiesModelImpl method hasI18nKeys.
private boolean hasI18nKeys(Set attributeSchemes) {
boolean has = false;
for (Iterator i = attributeSchemes.iterator(); (i.hasNext() && !has); ) {
AttributeSchema as = (AttributeSchema) i.next();
String i18nKey = as.getI18NKey();
has = (i18nKey != null) && (i18nKey.length() > 0);
}
return has;
}
Aggregations