use of com.iplanet.sso.SSOException 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.iplanet.sso.SSOException in project OpenAM by OpenRock.
the class AMOrganizationalUnitImpl method getOrgTypeAttributes.
/**
* Protected method to be used to obtain organization attribute values for a
* given serviceName and attribute name. Returns a null value if a template
* value or default value for the attribute does not exist.
*/
protected Set getOrgTypeAttributes(String serviceName, String attrName) throws SSOException {
Set attrValues = null;
try {
AMTemplate amTemplate = getTemplate(serviceName, AMTemplate.ORGANIZATION_TEMPLATE);
attrValues = amTemplate.getAttribute(attrName);
if (debug.messageEnabled()) {
debug.message("AMOrganizationImpl." + "getOrgTypeAttributes(): " + "obtained from org template " + serviceName + " : " + attrName + "\n" + super.entryDN + " : " + attrValues);
}
} catch (AMException ame) {
// Get default Service attribues
try {
Map defaultValues = AMServiceUtils.getServiceConfig(token, ADMINISTRATION_SERVICE, SchemaType.ORGANIZATION);
attrValues = (Set) defaultValues.get(attrName);
if (debug.messageEnabled()) {
debug.message("AMOrganizationImpl." + "getOrgTypeAttributes(): " + "obtained from org defaults " + serviceName + " : " + attrName + "\n" + super.entryDN + " : " + attrValues);
}
} catch (Exception se) {
debug.warning("AMOrganizationImpl." + "getOrgTypeAttributes(): " + "Error encountered in retrieving " + "default org attrs for", se);
}
}
return attrValues;
}
use of com.iplanet.sso.SSOException in project OpenAM by OpenRock.
the class SessionService method isSuperUser.
/**
* Returns true if the user is super user
*
* @param uuid the uuid of the login user
*/
public boolean isSuperUser(String uuid) {
boolean isSuperUser = false;
try {
// Get the AMIdentity Object for super user
AMIdentity adminUserId = null;
String adminUser = SystemProperties.get(Constants.AUTHENTICATION_SUPER_USER);
if (adminUser != null) {
adminUserId = new AMIdentity(dsameAdminTokenProvider.getAdminToken(), adminUser, IdType.USER, "/", null);
}
//Get the AMIdentity Object for login user
AMIdentity user = IdUtils.getIdentity(dsameAdminTokenProvider.getAdminToken(), uuid);
//Check for the equality
isSuperUser = adminUserId.equals(user);
} catch (SSOException ssoe) {
sessionDebug.error("SessionService.isSuperUser: Cannot get the admin token for this operation.");
} catch (IdRepoException idme) {
sessionDebug.error("SessionService.isSuperUser: Cannot get the user identity.");
}
if (sessionDebug.messageEnabled()) {
sessionDebug.message("SessionService.isSuperUser: " + isSuperUser);
}
return isSuperUser;
}
use of com.iplanet.sso.SSOException in project OpenAM by OpenRock.
the class AuthUtils method getGlobalAttributes.
/**
* Returns <code>Map</code> attributes
*
* @param serviceName Service Name
* @return <code>Map</code> of global attributes.
*/
public static Map getGlobalAttributes(String serviceName) {
Map attrs = null;
try {
SSOToken dUserToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
ServiceSchemaManager scm = new ServiceSchemaManager(serviceName, dUserToken);
ServiceSchema schema = scm.getGlobalSchema();
if (schema != null) {
attrs = schema.getAttributeDefaults();
}
} catch (SMSException smsExp) {
utilDebug.error("AuthUtils.getGlobalAttributes: SMS Error", smsExp);
} catch (SSOException ssoExp) {
utilDebug.error("AuthUtils.getGlobalAttributes: SSO Error", ssoExp);
}
if (utilDebug.messageEnabled()) {
utilDebug.message("AuthUtils.getGlobalAttributes: attrs=" + attrs);
}
return attrs;
}
use of com.iplanet.sso.SSOException in project OpenAM by OpenRock.
the class DeleteDataStores method handleRequest.
/**
* Handles request.
*
* @param rc Request Context.
* @throws CLIException if request cannot be processed.
*/
public void handleRequest(RequestContext rc) throws CLIException {
super.handleRequest(rc);
ldapLogin();
SSOToken adminSSOToken = getAdminSSOToken();
String realm = getStringOptionValue(IArgument.REALM_NAME);
List names = (List) rc.getOption(DatastoreOptions.DATASTORE_NAMES);
validateRealm(realm);
String[] params = { realm, names.toString() };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_DELETE_DATASTORES", params);
try {
ServiceConfigManager svcCfgMgr = new ServiceConfigManager(IdConstants.REPO_SERVICE, adminSSOToken);
ServiceConfig cfg = svcCfgMgr.getOrganizationConfig(realm, null);
if (cfg != null) {
for (Iterator i = names.iterator(); i.hasNext(); ) {
cfg.removeSubConfig((String) i.next());
}
if (names.size() > 1) {
getOutputWriter().printlnMessage(getResourceString("datastore-delete-datastores-succeeded"));
} else {
getOutputWriter().printlnMessage(getResourceString("datastore-delete-datastore-succeeded"));
}
} else {
getOutputWriter().printlnMessage(getResourceString("datastore-delete-datastore-not-found"));
}
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEEDED_DELETE_DATASTORES", params);
} catch (SMSException e) {
debugError("DeleteDataStores.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_DELETE_DATASTORES", params);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SSOException e) {
debugError("DeleteDataStores.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_DELETE_DATASTORES", params);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
Aggregations