use of com.sun.identity.sm.SMSException in project OpenAM by OpenRock.
the class TabControllerBase method updateStatus.
protected void updateStatus() {
boolean status = false;
SSOToken adminSSOToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
try {
ServiceSchemaManager mgr = new ServiceSchemaManager(AMAdminConstants.ADMIN_CONSOLE_SERVICE, adminSSOToken);
ServiceSchema schema = mgr.getSchema(SchemaType.GLOBAL);
AttributeSchema as = schema.getAttributeSchema(getConfigAttribute());
Set defaultValue = as.getDefaultValues();
if ((defaultValue != null) && !defaultValue.isEmpty()) {
String val = (String) defaultValue.iterator().next();
status = (val != null) && val.equals("true");
}
} catch (SMSException e) {
AMModelBase.debug.error("TabControllerBase.updateStatus", e);
} catch (SSOException e) {
AMModelBase.debug.error("TabControllerBase.updateStatus", e);
}
visible = status;
}
use of com.sun.identity.sm.SMSException in project OpenAM by OpenRock.
the class SubConfigMeta method deleteSubConfigurations.
/**
* Deletes sub configurations.
*
* @param names Set of sub configuration names that are to be deleted.
* @throws AMConsoleException if sub configurations cannot be deleted.
*/
public void deleteSubConfigurations(Set names) throws AMConsoleException {
String curName = null;
try {
if (parentConfig != null) {
String[] params = new String[3];
params[0] = serviceName;
params[1] = parentConfig.getComponentName();
for (Iterator iter = names.iterator(); iter.hasNext(); ) {
curName = (String) iter.next();
params[2] = curName;
amModel.logEvent("ATTEMPT_DELETE_GLOBAL_SUB_CONFIGURATION", params);
parentConfig.removeSubConfig(curName);
removeFromSubConfigList(curName);
amModel.logEvent("SUCCEED_DELETE_GLOBAL_SUB_CONFIGURATION", params);
}
}
} catch (SSOException e) {
String[] paramsEx = { serviceName, parentConfig.getComponentName(), curName, amModel.getErrorString(e) };
amModel.logEvent("SSO_EXCEPTION_DELETE_GLOBAL_SUB_CONFIGURATION", paramsEx);
throw new AMConsoleException(amModel.getErrorString(e));
} catch (SMSException e) {
String[] paramsEx = { serviceName, parentConfig.getComponentName(), curName, amModel.getErrorString(e) };
amModel.logEvent("SMS_EXCEPTION_DELETE_GLOBAL_SUB_CONFIGURATION", paramsEx);
throw new AMConsoleException(amModel.getErrorString(e));
}
}
use of com.sun.identity.sm.SMSException in project OpenAM by OpenRock.
the class SubConfigMeta method setParentId.
public void setParentId(String parentId) {
if (validInstance()) {
resetMeta();
try {
getCorrespondingSchema(parentId);
getSupportedGlobalSubSchema();
if ((globalSubSchemaNames != null) && !globalSubSchemaNames.isEmpty()) {
creatableGlobalSubSchemas = new HashSet();
creatableGlobalSubSchemas.addAll(globalSubSchemaNames);
getSubConfigurationsFromConfig();
}
} catch (SSOException e) {
AMModelBase.debug.error("SubConfigMeta.getParentId", e);
} catch (SMSException e) {
AMModelBase.debug.error("SubConfigMeta.getParentId", e);
}
}
}
use of com.sun.identity.sm.SMSException in project OpenAM by OpenRock.
the class OathDevicesResource method actionCollection.
/**
* {@inheritDoc}
*/
@Override
public Promise<ActionResponse, ResourceException> actionCollection(Context context, ActionRequest request) {
try {
//could be admin
final AMIdentity identity = getUserIdFromUri(context);
final AuthenticatorOathService realmOathService = oathServiceFactory.create(getRealm(context));
switch(request.getAction()) {
case SKIP:
try {
final boolean setValue = request.getContent().get(VALUE).asBoolean();
realmOathService.setUserSkipOath(identity, setValue ? AuthenticatorOathService.SKIPPABLE : AuthenticatorOathService.NOT_SKIPPABLE);
return newResultPromise(newActionResponse(JsonValueBuilder.jsonValue().build()));
} catch (SSOException | IdRepoException e) {
debug.error("OathDevicesResource :: SKIP action - Unable to set value in user store.", e);
return new InternalServerErrorException().asPromise();
}
case CHECK:
try {
final Set resultSet = identity.getAttribute(realmOathService.getSkippableAttributeName());
boolean result = false;
if (CollectionUtils.isNotEmpty(resultSet)) {
String tmp = (String) resultSet.iterator().next();
int resultInt = Integer.valueOf(tmp);
if (resultInt == AuthenticatorOathService.SKIPPABLE) {
result = true;
}
}
return newResultPromise(newActionResponse(JsonValueBuilder.jsonValue().put(RESULT, result).build()));
} catch (SSOException | IdRepoException e) {
debug.error("OathDevicesResource :: CHECK action - Unable to read value from user store.", e);
return new InternalServerErrorException().asPromise();
}
case //sets their 'skippable' selection to default (NOT_SET) and deletes their profiles attribute
RESET:
try {
realmOathService.setUserSkipOath(identity, AuthenticatorOathService.NOT_SET);
realmOathService.removeAllUserDevices(identity);
return newResultPromise(newActionResponse(JsonValueBuilder.jsonValue().put(RESULT, true).build()));
} catch (SSOException | IdRepoException e) {
debug.error("OathDevicesResource :: Action - Unable to reset identity attributes", e);
return new InternalServerErrorException().asPromise();
}
default:
return new NotSupportedException().asPromise();
}
} catch (SMSException e) {
debug.error("OathDevicesResource :: Action - Unable to communicate with the SMS.", e);
return new InternalServerErrorException().asPromise();
} catch (SSOException | InternalServerErrorException e) {
debug.error("OathDevicesResource :: Action - Unable to retrieve identity data from request context", e);
return new InternalServerErrorException().asPromise();
}
}
use of com.sun.identity.sm.SMSException in project OpenAM by OpenRock.
the class AMOrganizationImpl method createGroup.
protected AMGroup createGroup(String name, Map attributes, Map serviceNameAndAttrs, int type) throws AMException, SSOException {
String groupDN = AMNamingAttrManager.getNamingAttr(GROUP) + "=" + name + "," + super.entryDN;
AMObjectImpl groupImpl;
switch(type) {
case AMObject.STATIC_GROUP:
groupImpl = new AMStaticGroupImpl(super.token, groupDN);
break;
case AMObject.DYNAMIC_GROUP:
groupImpl = new AMDynamicGroupImpl(super.token, groupDN);
break;
case AMObject.ASSIGNABLE_DYNAMIC_GROUP:
groupImpl = new AMAssignableDynamicGroupImpl(super.token, groupDN);
break;
default:
throw new UnsupportedOperationException();
}
if (serviceNameAndAttrs != null && !serviceNameAndAttrs.isEmpty()) {
Set serviceNames = serviceNameAndAttrs.keySet();
Set registered = dsServices.getRegisteredServiceNames(null, entryDN);
Iterator it = serviceNames.iterator();
while (it.hasNext()) {
String tmpS = (String) it.next();
if (!registered.contains(tmpS)) {
Object[] args = { tmpS };
throw new AMException(AMSDKBundle.getString("459", args, super.locale), "459", args);
}
}
Set objectClasses = null;
if ((serviceNames != null) && (!serviceNames.isEmpty())) {
objectClasses = AMServiceUtils.getServiceObjectClasses(token, serviceNames);
Set userOCs = (Set) attributes.get("objectclass");
objectClasses = AMCommonUtils.combineOCs(userOCs, objectClasses);
}
it = serviceNames.iterator();
while (it.hasNext()) {
String thisService = (String) it.next();
Map sAttrMap = (Map) serviceNameAndAttrs.get(thisService);
// validate the attributes and add pick the defaults.
try {
ServiceSchemaManager ssm = new ServiceSchemaManager(thisService, token);
ServiceSchema ss = ssm.getSchema(SchemaType.GROUP);
sAttrMap = ss.validateAndInheritDefaults(sAttrMap, true);
sAttrMap = AMCommonUtils.removeEmptyValues(sAttrMap);
groupImpl.setAttributes(sAttrMap);
} catch (SMSException se) {
debug.error("AMGroupContainerImpl.createStaticGroup: " + "Data validation failed.. ", se);
}
Object[] args = { thisService };
throw new AMException(AMSDKBundle.getString("976", args, super.locale), "976", args);
}
if (objectClasses != null && !objectClasses.isEmpty()) {
groupImpl.setAttribute("objectclass", objectClasses);
}
}
groupImpl.setAttributes(attributes);
groupImpl.create();
return ((AMGroup) groupImpl);
}
Aggregations