use of com.sun.identity.sm.SMSException in project OpenAM by OpenRock.
the class AgentsModelImpl method getAttributeValues.
/**
* Returns attribute values of an agent or agent group.
*
* @param realmName Realm where agent or agent group resides.
* @param universalId Universal ID of the agent/agent group.
* @param withInheritValues <code>true</code> to include inherited values.
* @return attribute values of an agent or agent group.
* @throws AMConsoleException if object cannot located.
*/
public Map getAttributeValues(String realmName, String universalId, boolean withInheritValues) throws AMConsoleException {
String[] param = { universalId };
logEvent("ATTEMPT_GET_AGENT_ATTRIBUTE_VALUES", param);
try {
AMIdentity amid = IdUtils.getIdentity(getUserSSOToken(), universalId);
Map values = AgentConfiguration.getAgentAttributes(amid, false);
if (withInheritValues) {
String groupId = getAgentGroupId(realmName, universalId);
if ((groupId != null) && (groupId.trim().length() > 0)) {
AMIdentity group = IdUtils.getIdentity(getUserSSOToken(), groupId);
if (!group.isExists()) {
Object[] arg = { group.getName() };
throw new AMConsoleException(MessageFormat.format(getLocalizedString("agent.group.does.not.exist"), arg));
}
Map groupValues = AgentConfiguration.getAgentAttributes(group, false);
//correctly.
for (Iterator i = groupValues.keySet().iterator(); i.hasNext(); ) {
String key = (String) i.next();
Set val = (Set) groupValues.get(key);
if (val.size() > 1) {
StringBuffer buff = new StringBuffer();
boolean bFirst = true;
for (Iterator j = val.iterator(); j.hasNext(); ) {
if (!bFirst) {
buff.append(", ");
} else {
bFirst = false;
}
buff.append((String) j.next());
}
val.clear();
val.add(buff.toString());
}
}
groupValues.putAll(values);
values = groupValues;
}
}
logEvent("SUCCEED_GET_AGENT_ATTRIBUTE_VALUES", param);
return values;
} catch (SSOException e) {
String[] paramsEx = { universalId, getErrorString(e) };
logEvent("EXCEPTION_GET_AGENT_ATTRIBUTE_VALUES", paramsEx);
throw new AMConsoleException(getErrorString(e));
} catch (SMSException e) {
String[] paramsEx = { universalId, getErrorString(e) };
logEvent("EXCEPTION_GET_AGENT_ATTRIBUTE_VALUES", paramsEx);
throw new AMConsoleException(getErrorString(e));
} catch (IdRepoException e) {
String[] paramsEx = { universalId, getErrorString(e) };
logEvent("EXCEPTION_GET_AGENT_ATTRIBUTE_VALUES", paramsEx);
throw new AMConsoleException(getErrorString(e));
}
}
use of com.sun.identity.sm.SMSException in project OpenAM by OpenRock.
the class AgentsModelImpl method getAuthenticationChains.
/**
* Returns all the authentication chains in a realm.
*
* @return all the authentication chains in a realm.
* @throws AMConsoleException if authentication chains cannot be returned.
*/
public Set getAuthenticationChains() throws AMConsoleException {
try {
Set chains = new TreeSet();
chains.addAll(AgentConfiguration.getChoiceValues("authenticationChain", "WSPAgent").keySet());
return chains;
} catch (SSOException e) {
throw new AMConsoleException(getErrorString(e));
} catch (SMSException e) {
throw new AMConsoleException(getErrorString(e));
}
}
use of com.sun.identity.sm.SMSException in project OpenAM by OpenRock.
the class AgentsModelImpl method getSTSConfigurations.
/**
* Returns map of secure token service configurations.
*
* @return map of secure token service configurations.
* @throws AMConsoleException if secure token service configurations cannot
* be returned.
*/
public Map getSTSConfigurations() {
try {
Map map = AgentConfiguration.getChoiceValues("STS", "WSCAgent");
if ((map != null) && !map.isEmpty()) {
if (rbAgent != null) {
Map localizedMap = new HashMap();
for (Iterator i = map.keySet().iterator(); i.hasNext(); ) {
String k = (String) i.next();
localizedMap.put((String) map.get(k), Locale.getString(rbAgent, k));
}
return localizedMap;
} else {
return map;
}
}
} catch (SSOException e) {
debug.error("AgentModelImpl.getSTSConfigurations", e);
} catch (SMSException e) {
debug.error("AgentModelImpl.getSTSConfigurations", e);
}
return Collections.EMPTY_MAP;
}
use of com.sun.identity.sm.SMSException in project OpenAM by OpenRock.
the class AMObjectImpl method getDefaultAcis.
/**
* Gets the aci description and DN:ACI of the role type that matches the
* permission
*
* @param permission
* Permission in the role type
* @param aciDesc
* StringBuffer to store aci description
* @return Set of DN:ACI
* @throws AMException
* if there is an internal problem with AM Store.
* @throws SSOException
* if the sign-on is no longer valid.
*/
Set getDefaultAcis(String permission, StringBuffer aciDesc) throws AMException, SSOException {
Map map;
try {
map = AMServiceUtils.getServiceConfig(token, ADMINISTRATION_SERVICE, SchemaType.GLOBAL);
} catch (SMSException smsex) {
debug.error(smsex.toString());
throw new AMException(AMSDKBundle.getString("158", locale), "158");
}
Set defaultAcis = (Set) map.get("iplanet-am-admin-console-dynamic-aci-list");
Iterator iter = defaultAcis.iterator();
String aci = null;
while (iter.hasNext()) {
String defaultAci = (String) iter.next();
if (defaultAci.startsWith(permission + "|")) {
aci = defaultAci;
break;
}
}
if (aci == null) {
throw new AMException(AMSDKBundle.getString("158", locale), "158");
}
StringTokenizer stz = new StringTokenizer(aci, "|");
if (stz.countTokens() < 3) {
throw new AMException(AMSDKBundle.getString("159", locale), "159");
}
permission = stz.nextToken();
aciDesc.append(stz.nextToken());
int index = aci.indexOf('|', permission.length() + 1);
String acis = aci.substring(index + 1);
stz = new StringTokenizer(acis, "##");
Set aciSet = new HashSet();
while (stz.hasMoreTokens()) {
aciSet.add(stz.nextToken());
}
return aciSet;
}
use of com.sun.identity.sm.SMSException in project OpenAM by OpenRock.
the class ComplianceServicesImpl method getDeletedObjectFilter.
/**
* Protected method to get the search filter to be used for searching for
* deleted objects.
*
*/
public String getDeletedObjectFilter(int objectType) throws AMException, SSOException {
Set values = new HashSet();
try {
if (gsc == null) {
ServiceSchemaManager scm = new ServiceSchemaManager(ADMINISTRATION_SERVICE, internalToken);
gsc = scm.getGlobalSchema();
}
Map attrMap = gsc.getAttributeDefaults();
if (attrMap != null)
values = (Set) attrMap.get(COMPLIANCE_SPECIAL_FILTER_ATTR);
if (debug.messageEnabled()) {
debug.message("Compliance.getDeletedObjectSearchFilter = " + values.toString());
}
} catch (SMSException ex) {
debug.error(AMSDKBundle.getString("359"), ex);
throw new AMException(AMSDKBundle.getString("359"), "359");
} catch (SSOException ex) {
debug.error(AMSDKBundle.getString("359"), ex);
throw new AMException(AMSDKBundle.getString("359"), "359");
}
String org_filter = null;
String group_filter = null;
String user_filter = null;
String def_filter = null;
String res_filter = null;
Iterator iter = values.iterator();
while (iter.hasNext()) {
String thisFilter = (String) iter.next();
if (thisFilter.startsWith("Organization=")) {
org_filter = thisFilter.substring(13);
} else if (thisFilter.startsWith("Group=")) {
group_filter = thisFilter.substring(6);
} else if (thisFilter.startsWith("User=")) {
user_filter = thisFilter.substring(5);
} else if (thisFilter.startsWith("Misc=")) {
def_filter = thisFilter.substring(5);
} else if (thisFilter.startsWith("Resource=")) {
res_filter = thisFilter.substring(9);
}
}
org_filter = (org_filter == null) ? DEFAULT_DELETED_ORG_FILTER : org_filter;
group_filter = (group_filter == null) ? DEFAULT_DELETED_GROUP_FILTER : group_filter;
user_filter = (user_filter == null) ? DEFAULT_DELETED_USER_FILTER : user_filter;
def_filter = (def_filter == null) ? DEFAULT_DELETED_OBJECT_FILTER : def_filter;
res_filter = (res_filter == null) ? DEFAULT_DELETED_RESOURCE_FILTER : res_filter;
switch(objectType) {
case AMObject.ORGANIZATION:
return (org_filter);
case AMObject.USER:
return (user_filter);
case AMObject.ASSIGNABLE_DYNAMIC_GROUP:
case AMObject.DYNAMIC_GROUP:
case AMObject.STATIC_GROUP:
case AMObject.GROUP:
return (group_filter);
case AMObject.RESOURCE:
return (res_filter);
default:
return ("(|" + org_filter + group_filter + user_filter + def_filter + res_filter + ")");
}
}
Aggregations