Search in sources :

Example 11 with ServiceNotFoundException

use of com.sun.identity.sm.ServiceNotFoundException in project OpenAM by OpenRock.

the class SmsCollectionProvider method updateInstance.

/**
     * Updates a child instance of config. The parent config referenced by the request path is found, and
     * the config is updated using the resourceId.
     * {@inheritDoc}
     */
@Override
public Promise<ResourceResponse, ResourceException> updateInstance(Context context, String resourceId, UpdateRequest request) {
    JsonValue content = request.getContent();
    String realm = realmFor(context);
    try {
        Map<String, Set<String>> attrs = converter.fromJson(realm, content);
        ServiceConfigManager scm = getServiceConfigManager(context);
        ServiceConfig config = parentSubConfigFor(context, scm);
        ServiceConfig node = checkedInstanceSubConfig(context, resourceId, config);
        node.setAttributes(attrs);
        JsonValue result = getJsonValue(realm, node);
        return newResultPromise(newResourceResponse(resourceId, String.valueOf(result.hashCode()), result));
    } catch (ServiceNotFoundException e) {
        debug.warning("::SmsCollectionProvider:: ServiceNotFoundException on update", e);
        return new NotFoundException("Unable to update SMS config: " + e.getMessage()).asPromise();
    } catch (SMSException e) {
        debug.warning("::SmsCollectionProvider:: SMSException on update", e);
        return new InternalServerErrorException("Unable to update SMS config: " + e.getMessage()).asPromise();
    } catch (SSOException e) {
        debug.warning("::SmsCollectionProvider:: SSOException on update", e);
        return new InternalServerErrorException("Unable to update SMS config: " + e.getMessage()).asPromise();
    } catch (ResourceException e) {
        return e.asPromise();
    }
}
Also used : TreeSet(java.util.TreeSet) Set(java.util.Set) ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) ServiceNotFoundException(com.sun.identity.sm.ServiceNotFoundException) JsonValue(org.forgerock.json.JsonValue) NotFoundException(org.forgerock.json.resource.NotFoundException) ServiceNotFoundException(com.sun.identity.sm.ServiceNotFoundException) InternalServerErrorException(org.forgerock.json.resource.InternalServerErrorException) SSOException(com.iplanet.sso.SSOException) ResourceException(org.forgerock.json.resource.ResourceException) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager)

Example 12 with ServiceNotFoundException

use of com.sun.identity.sm.ServiceNotFoundException in project OpenAM by OpenRock.

the class UpgradeOAuth2ProviderStep method initialize.

@Override
public void initialize() throws UpgradeException {
    final SSOToken token = getAdminToken();
    try {
        scm = new ServiceConfigManager(OAUTH2_PROVIDER, token);
        ssm = new ServiceSchemaManager(OAUTH2_PROVIDER, token);
        findUpgradableProviders();
    } catch (ServiceNotFoundException e) {
        //When upgrading from 10.0.x and before there is no OAuth2 service, so we expect this exception in this case
        DEBUG.message("OAuth2Provider service not found. Nothing to upgrade", e);
    } catch (Exception e) {
        DEBUG.error("An error occurred while trying to create Service Config and Schema Managers.", e);
        throw new UpgradeException("Unable to create Service Config and Schema Managers.", e);
    }
}
Also used : UpgradeException(org.forgerock.openam.upgrade.UpgradeException) SSOToken(com.iplanet.sso.SSOToken) ServiceNotFoundException(com.sun.identity.sm.ServiceNotFoundException) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager) UpgradeException(org.forgerock.openam.upgrade.UpgradeException) ServiceNotFoundException(com.sun.identity.sm.ServiceNotFoundException)

Example 13 with ServiceNotFoundException

use of com.sun.identity.sm.ServiceNotFoundException in project OpenAM by OpenRock.

the class UpgradeOAuth2AuthModulesStep method initialize.

@Override
public void initialize() throws UpgradeException {
    try {
        ServiceConfigManager scm = new ServiceConfigManager(SERVICE_NAME, getAdminToken());
        for (String realm : getRealmNames()) {
            ServiceConfig realmConfig = scm.getOrganizationConfig(realm, null);
            for (String moduleName : (Set<String>) realmConfig.getSubConfigNames()) {
                ServiceConfig moduleConfig = realmConfig.getSubConfig(moduleName);
                Map<String, Set<?>> attributes = getAttributes(moduleConfig);
                check(attributes, ACCOUNT_MAPPER_PROPERTY, DEFAULT_ACCOUNT_MAPPER, realm, moduleName);
                check(attributes, ATTRIBUTE_MAPPER_PROPERTY, DEFAULT_ATTRIBUTE_MAPPER, realm, moduleName);
            }
        }
    } catch (ServiceNotFoundException e) {
        // When upgrading from 9.5.x and before there is no OAuth2 auth modules, so we expect this exception in this case
        DEBUG.message("OAuth2 auth modules not found. Nothing to upgrade", e);
    } catch (Exception ex) {
        DEBUG.error("An error occurred while trying to look for upgradable OAuth2 auth modules", ex);
        throw new UpgradeException("Unable to retrieve OAuth2 auth modules", ex);
    }
}
Also used : UpgradeException(org.forgerock.openam.upgrade.UpgradeException) Set(java.util.Set) ServiceConfig(com.sun.identity.sm.ServiceConfig) ServiceNotFoundException(com.sun.identity.sm.ServiceNotFoundException) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager) UpgradeException(org.forgerock.openam.upgrade.UpgradeException) ServiceNotFoundException(com.sun.identity.sm.ServiceNotFoundException)

Example 14 with ServiceNotFoundException

use of com.sun.identity.sm.ServiceNotFoundException in project OpenAM by OpenRock.

the class AMOrgTemplateImpl method delete.

/**
     * Deletes this tempate.
     * 
     * @param recursive
     *            is not used.
     * @throws AMException
     *             if there is an internal problem with AM Store.
     * @throws SSOException
     *             if the sign-on is no longer valid.
     */
public void delete(boolean recursive) throws AMException, SSOException {
    modAttributes = new HashMap();
    try {
        ServiceConfigManager scm = new ServiceConfigManager(serviceName, token);
        scm.removeOrganizationConfiguration(orgDN, null, false);
    } catch (ServiceNotFoundException ex) {
        Object[] args = { serviceName };
        throw new AMException(AMSDKBundle.getString("481", args), "481", args);
    } catch (SMSException ex) {
        Object[] args = { serviceName };
        throw new AMException(AMSDKBundle.getString("913", args), "913", args);
    }
}
Also used : HashMap(java.util.HashMap) SMSException(com.sun.identity.sm.SMSException) ServiceNotFoundException(com.sun.identity.sm.ServiceNotFoundException) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager)

Example 15 with ServiceNotFoundException

use of com.sun.identity.sm.ServiceNotFoundException in project OpenAM by OpenRock.

the class SMSEnhancedFlatFileObject method getSubEntries.

/**
     * Real routine to get sub entries, used by subEntries() and 
     * schemaSubEntries(). 
     *
     * @throws ServiceNotFoundException if the configuration object is 
     * not found.
     * @throws SchemaException if a sub directory name is not in the 
     * expected "ou=..." format.
     */
protected Set getSubEntries(String objName, String filter, String sidFilter, boolean isSubConfig, int numOfEntries, boolean sortResults, boolean ascendingOrder) throws SMSException {
    String objKey = objName.toLowerCase();
    Set subentries = null;
    // wait indefinitely for the read lock.
    mRWLock.readRequest();
    try {
        SMSFlatFileTreeNode node = root.getChild(objKey);
        if (node == null) {
            String errmsg = "SMSEnhancedFlatFileObject.getSubEntries: " + objName + " : not found in objects map.";
            mDebug.warning(errmsg);
            throw new ServiceNotFoundException(errmsg);
        }
        // Create file filter for filter and sid filter.
        NodeNameFilter subEntNodeFilter = new NodeNameFilter(filter);
        NodeNameFilter sidNameFilter = getSidNodeFilter(sidFilter, isSubConfig);
        // Create set for return, use sorted set if sortResults is true.
        if (sortResults) {
            subentries = new CaseInsensitiveTreeSet(ascendingOrder);
        } else {
            subentries = new CaseInsensitiveHashSet();
        }
        // Set all entries that match filter, and that match 
        // sunserviceid/sunxmlkeyvalye if sidFilter was not null.
        Set subEntries = node.searchChildren(subEntNodeFilter, false);
        int numEntriesAdded = 0;
        int sz = subEntries.size();
        boolean done = false;
        for (Iterator i = subEntries.iterator(); i.hasNext() && !done; ) {
            SMSFlatFileTreeNode n = (SMSFlatFileTreeNode) i.next();
            String nodeDN = n.getName();
            boolean accept = (sidNameFilter == null);
            if (!accept) {
                Set sids = n.searchChildren(sidNameFilter, false);
                accept = (sids != null) && !sids.isEmpty();
            }
            if (accept) {
                int idx = nodeDN.indexOf('=');
                if ((idx == -1) || (idx == (nodeDN.length() - 1))) {
                    String errmsg = "SMSEnhancedFlatFileObject.getSubEntries: " + "Invalid sub entry name found: " + nodeDN;
                    mDebug.error(errmsg);
                    throw new SchemaException(errmsg);
                }
                String subentryname = FileNameDecoder.decode(nodeDN.substring(idx + 1));
                subentries.add(subentryname);
                numEntriesAdded++;
                // stop if number of entries requested has been reached.
                // if sort results, need to get the whole list first.
                done = !sortResults && (numOfEntries > 0) && (numEntriesAdded == numOfEntries);
            }
        }
        if (sortResults && (numOfEntries > 0)) {
            while ((numEntriesAdded - numOfEntries) > 0) {
                Object l = ((CaseInsensitiveTreeSet) subentries).last();
                subentries.remove(l);
                numEntriesAdded--;
            }
        }
    } finally {
        mRWLock.readDone();
    }
    return subentries;
}
Also used : CaseInsensitiveHashSet(com.sun.identity.common.CaseInsensitiveHashSet) SchemaException(com.sun.identity.sm.SchemaException) CaseInsensitiveHashSet(com.sun.identity.common.CaseInsensitiveHashSet) HashSet(java.util.HashSet) CaseInsensitiveTreeSet(com.sun.identity.common.CaseInsensitiveTreeSet) Set(java.util.Set) ServiceNotFoundException(com.sun.identity.sm.ServiceNotFoundException) Iterator(java.util.Iterator) CaseInsensitiveTreeSet(com.sun.identity.common.CaseInsensitiveTreeSet)

Aggregations

ServiceNotFoundException (com.sun.identity.sm.ServiceNotFoundException)24 Set (java.util.Set)10 SMSException (com.sun.identity.sm.SMSException)8 ServiceConfigManager (com.sun.identity.sm.ServiceConfigManager)8 CaseInsensitiveHashSet (com.sun.identity.common.CaseInsensitiveHashSet)6 ServiceConfig (com.sun.identity.sm.ServiceConfig)6 HashSet (java.util.HashSet)6 CaseInsensitiveTreeSet (com.sun.identity.common.CaseInsensitiveTreeSet)5 File (java.io.File)5 Properties (java.util.Properties)5 ServiceSchemaManager (com.sun.identity.sm.ServiceSchemaManager)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4 InternalServerErrorException (org.forgerock.json.resource.InternalServerErrorException)4 ResourceException (org.forgerock.json.resource.ResourceException)4 SSOException (com.iplanet.sso.SSOException)3 SSOToken (com.iplanet.sso.SSOToken)3 CaseInsensitiveProperties (com.sun.identity.common.CaseInsensitiveProperties)3 JsonValue (org.forgerock.json.JsonValue)3 UpgradeException (org.forgerock.openam.upgrade.UpgradeException)3