Search in sources :

Example 6 with SMSException

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;
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) SSOToken(com.iplanet.sso.SSOToken) Set(java.util.Set) SMSException(com.sun.identity.sm.SMSException) AttributeSchema(com.sun.identity.sm.AttributeSchema) SSOException(com.iplanet.sso.SSOException) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager)

Example 7 with SMSException

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));
    }
}
Also used : SMSException(com.sun.identity.sm.SMSException) Iterator(java.util.Iterator) SSOException(com.iplanet.sso.SSOException)

Example 8 with SMSException

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);
        }
    }
}
Also used : SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) HashSet(java.util.HashSet)

Example 9 with SMSException

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();
    }
}
Also used : Set(java.util.Set) AuthenticatorOathService(org.forgerock.openam.core.rest.devices.services.AuthenticatorOathService) SMSException(com.sun.identity.sm.SMSException) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException) AMIdentity(com.sun.identity.idm.AMIdentity) InternalServerErrorException(org.forgerock.json.resource.InternalServerErrorException) NotSupportedException(org.forgerock.json.resource.NotSupportedException)

Example 10 with SMSException

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);
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) SMSException(com.sun.identity.sm.SMSException) ServiceSchema(com.sun.identity.sm.ServiceSchema) Iterator(java.util.Iterator) HashMap(java.util.HashMap) Map(java.util.Map) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager)

Aggregations

SMSException (com.sun.identity.sm.SMSException)704 SSOException (com.iplanet.sso.SSOException)525 Set (java.util.Set)272 HashSet (java.util.HashSet)200 SSOToken (com.iplanet.sso.SSOToken)185 Map (java.util.Map)166 ServiceConfig (com.sun.identity.sm.ServiceConfig)164 HashMap (java.util.HashMap)158 CLIException (com.sun.identity.cli.CLIException)149 ServiceSchema (com.sun.identity.sm.ServiceSchema)138 Iterator (java.util.Iterator)133 ServiceSchemaManager (com.sun.identity.sm.ServiceSchemaManager)131 ServiceConfigManager (com.sun.identity.sm.ServiceConfigManager)104 IOutput (com.sun.identity.cli.IOutput)96 IdRepoException (com.sun.identity.idm.IdRepoException)86 OrganizationConfigManager (com.sun.identity.sm.OrganizationConfigManager)84 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)83 AttributeSchema (com.sun.identity.sm.AttributeSchema)66 IOException (java.io.IOException)55 List (java.util.List)51