Search in sources :

Example 96 with OrganizationConfigManager

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

the class RealmResourceOfferingModelImpl method setRealmDiscoEntry.

/**
     * Set resource offering entry.
     *
     * @param realm Realm Name.
     * @param smData Resource offering entry.
     * @throws AMConsoleException if entry cannot be set.
     */
public void setRealmDiscoEntry(String realm, SMDiscoveryServiceData smData) throws AMConsoleException {
    String[] params = { realm, AMAdminConstants.DISCOVERY_SERVICE };
    logEvent("ATTEMPT_MODIFY_SERVICE_UNDER_REALM", params);
    Map map = new HashMap(2);
    map.put(AMAdminConstants.DISCOVERY_SERVICE_NAME_DYNAMIC_DISCO_ENTRIES, smData.getDiscoveryEntries());
    try {
        AMIdentityRepository repo = new AMIdentityRepository(getUserSSOToken(), realm);
        AMIdentity realmIdentity = repo.getRealmIdentity();
        Set servicesFromIdRepo = realmIdentity.getAssignedServices();
        if (servicesFromIdRepo.contains(AMAdminConstants.DISCOVERY_SERVICE)) {
            realmIdentity.modifyService(AMAdminConstants.DISCOVERY_SERVICE, map);
        } else {
            OrganizationConfigManager orgCfgMgr = new OrganizationConfigManager(getUserSSOToken(), realm);
            orgCfgMgr.modifyService(AMAdminConstants.DISCOVERY_SERVICE, map);
        }
        logEvent("SUCCEED_MODIFY_SERVICE_UNDER_REALM", params);
    } catch (SSOException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realm, AMAdminConstants.DISCOVERY_SERVICE, strError };
        logEvent("SSO_EXCEPTION_MODIFY_SERVICE_UNDER_REALM", paramsEx);
        throw new AMConsoleException(strError);
    } catch (IdRepoException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realm, AMAdminConstants.DISCOVERY_SERVICE, strError };
        logEvent("IDREPO_EXCEPTION_MODIFY_SERVICE_UNDER_REALM", paramsEx);
        throw new AMConsoleException(strError);
    } catch (SMSException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realm, AMAdminConstants.DISCOVERY_SERVICE, strError };
        logEvent("SMS_EXCEPTION_MODIFY_SERVICE_UNDER_REALM", paramsEx);
        throw new AMConsoleException(strError);
    }
}
Also used : Set(java.util.Set) HashMap(java.util.HashMap) SMSException(com.sun.identity.sm.SMSException) AMIdentity(com.sun.identity.idm.AMIdentity) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) AMIdentityRepository(com.sun.identity.idm.AMIdentityRepository) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map)

Example 97 with OrganizationConfigManager

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

the class ServicesModelImpl method unassignServices.

/**
     * Unassigns services from realm.
     *
     * @param realmName Name of Realm.
     * @param names Names of services that are to be unassigned.
     * @throws AMConsoleException if services cannot be unassigned.
     */
public void unassignServices(String realmName, Set names) throws AMConsoleException {
    if ((names != null) && !names.isEmpty()) {
        if ((realmName == null) || (realmName.trim().length() == 0)) {
            realmName = "/";
        }
        String[] params = new String[2];
        params[0] = realmName;
        String curServiceName = "";
        try {
            OrganizationConfigManager scm = new OrganizationConfigManager(getUserSSOToken(), realmName);
            AMIdentityRepository repo = new AMIdentityRepository(getUserSSOToken(), realmName);
            AMIdentity realmIdentity = repo.getRealmIdentity();
            Set realmServices = realmIdentity.getAssignedServices();
            for (Iterator iter = names.iterator(); iter.hasNext(); ) {
                String name = (String) iter.next();
                curServiceName = name;
                params[1] = name;
                logEvent("ATTEMPT_UNASSIGN_SERVICE_FROM_REALM", params);
                if (realmServices.contains(name)) {
                    realmIdentity.unassignService(name);
                } else {
                    scm.unassignService(name);
                }
                logEvent("SUCCEED_UNASSIGN_SERVICE_FROM_REALM", params);
            }
        } catch (SMSException e) {
            String strError = getErrorString(e);
            String[] paramsEx = { realmName, curServiceName, strError };
            logEvent("SMS_EXCEPTION_UNASSIGN_SERVICE_FROM_REALM", paramsEx);
            throw new AMConsoleException(strError);
        } catch (SSOException e) {
            String strError = getErrorString(e);
            String[] paramsEx = { realmName, curServiceName, strError };
            logEvent("SSO_EXCEPTION_UNASSIGN_SERVICE_FROM_REALM", paramsEx);
            throw new AMConsoleException(strError);
        } catch (IdRepoException e) {
            String strError = getErrorString(e);
            String[] paramsEx = { realmName, curServiceName, strError };
            logEvent("IDREPO_EXCEPTION_UNASSIGN_SERVICE_FROM_REALM", paramsEx);
            throw new AMConsoleException(strError);
        }
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) SMSException(com.sun.identity.sm.SMSException) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) AMIdentity(com.sun.identity.idm.AMIdentity) AMIdentityRepository(com.sun.identity.idm.AMIdentityRepository) Iterator(java.util.Iterator) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 98 with OrganizationConfigManager

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

the class ServicesModelImpl method getAssignedServiceNames.

/**
     * Returns a map of assigned service name to its localized name under a
     * realm.
     *
     * @param realmName Name of Realm.
     * @return a map of assigned service name to its localized name under a
     *         realm.
     * @throws AMConsoleException if service names cannot be obtained.
     */
public Map getAssignedServiceNames(String realmName) throws AMConsoleException {
    String[] param = { realmName };
    logEvent("ATTEMPT_GET_ASSIGNED_SERVICE_OF_REALM", param);
    try {
        OrganizationConfigManager orgCfgMgr = new OrganizationConfigManager(getUserSSOToken(), realmName);
        Set names = orgCfgMgr.getAssignedServices();
        if ((names == null) || names.isEmpty()) {
            names = new HashSet();
        }
        getIdentityServices(realmName, names);
        /*
             * Need to use adminSSOToken because policy admin does not
             * have the correct privileges.
             */
        AMAuthenticationManager mgr = new AMAuthenticationManager(adminSSOToken, realmName);
        AMAdminUtils.removeAllCaseIgnore(names, mgr.getAuthenticationServiceNames());
        removeNonDisplayableServices(names, SUPPORTED_SCHEMA_TYPE);
        // remove auth configuration service too
        names.remove(AMAdminConstants.AUTH_CONFIG_SERVICE);
        names.remove(AMAdminConstants.CORE_AUTH_SERVICE);
        /*
            Creation and edit of instances of the Rest/Soap STS services handled by the STS tab.
             */
        names.remove(AMAdminConstants.REST_STS_SERVICE);
        names.remove(AMAdminConstants.SOAP_STS_SERVICE);
        logEvent("SUCCEED_GET_ASSIGNED_SERVICE_OF_REALM", param);
        return mapNameToDisplayName(names);
    } catch (AMConfigurationException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realmName, strError };
        logEvent("CONFIGURATION_EXCEPTION_GET_ASSIGNED_SERVICE_OF_REALM", paramsEx);
        throw new AMConsoleException(strError);
    } catch (SMSException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realmName, strError };
        logEvent("SMS_EXCEPTION_GET_ASSIGNED_SERVICE_OF_REALM", paramsEx);
        throw new AMConsoleException(strError);
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) SMSException(com.sun.identity.sm.SMSException) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) AMConfigurationException(com.sun.identity.authentication.config.AMConfigurationException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashSet(java.util.HashSet) AMAuthenticationManager(com.sun.identity.authentication.config.AMAuthenticationManager)

Example 99 with OrganizationConfigManager

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

the class ServicesModelImpl method getAssignableServiceNames.

/**
     * Returns a map of service name to its display name that can be assigned
     * to a realm.
     *
     * @param realmName Name of Realm.
     * @return a map of service name to its display name that can be assigned
     * to a realm.
     * @throws AMConsoleException if service names cannot be obtained.
     */
public Map getAssignableServiceNames(String realmName) throws AMConsoleException {
    String[] param = { realmName };
    logEvent("ATTEMPT_GET_ASSIGNABLE_SERVICE_OF_REALM", param);
    try {
        OrganizationConfigManager orgCfgMgr = new OrganizationConfigManager(getUserSSOToken(), realmName);
        Set names = orgCfgMgr.getAssignableServices();
        addIdentityUnassignedServices(realmName, names);
        names.removeAll(orgCfgMgr.getAssignedServices());
        AMAuthenticationManager mgr = new AMAuthenticationManager(getUserSSOToken(), realmName);
        AMAdminUtils.removeAllCaseIgnore(names, mgr.getAuthenticationServiceNames());
        removeNonDisplayableServices(names, SUPPORTED_SCHEMA_TYPE);
        names.remove(AMAdminConstants.CORE_AUTH_SERVICE);
        /*
            Creation and edit of instances of the Rest/Soap STS services handled by the STS tab.
             */
        names.remove(AMAdminConstants.REST_STS_SERVICE);
        names.remove(AMAdminConstants.SOAP_STS_SERVICE);
        logEvent("SUCCEED_GET_ASSIGNABLE_SERVICE_OF_REALM", param);
        return mapNameToDisplayName(names);
    } catch (AMConfigurationException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realmName, strError };
        logEvent("CONFIGURATION_EXCEPTION_GET_ASSIGNABLE_SERVICE_OF_REALM", paramsEx);
        if (debug.warningEnabled()) {
            debug.warning("ServicesModel.getAssignableServiceNames " + strError);
        }
        throw new AMConsoleException("no.properties");
    } catch (SMSException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realmName, strError };
        logEvent("SMS_EXCEPTION_GET_ASSIGNABLE_SERVICE_OF_REALM", paramsEx);
        throw new AMConsoleException(strError);
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) SMSException(com.sun.identity.sm.SMSException) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) AMConfigurationException(com.sun.identity.authentication.config.AMConfigurationException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) AMAuthenticationManager(com.sun.identity.authentication.config.AMAuthenticationManager)

Example 100 with OrganizationConfigManager

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

the class RMRealmModelImpl method createSubRealm.

/**
     * Creates sub realm.
     *
     * @param parentRealm Parent realm name.
     * @param name Name of new sub realm.
     * @param attrValues Map of attribute name to a set of attribute values.
     * @throws AMConsoleException if sub realm cannot be created.
     */
public void createSubRealm(String parentRealm, String name, Map attrValues) throws AMConsoleException {
    if ((parentRealm == null) || (parentRealm.length() == 0)) {
        parentRealm = "/";
    }
    String[] params = { parentRealm, name };
    logEvent("ATTEMPT_CREATE_REALM", params);
    try {
        OrganizationConfigManager orgMgr = new OrganizationConfigManager(getUserSSOToken(), parentRealm);
        Map map = mapAttributeValuesToServiceName(attrValues);
        orgMgr.createSubOrganization(name, map);
        logEvent("SUCCEED_CREATE_REALM", params);
    } catch (SMSException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { parentRealm, name, strError };
        logEvent("SMS_EXCEPTION_CREATE_REALM", paramsEx);
        throw new AMConsoleException(strError);
    }
}
Also used : SMSException(com.sun.identity.sm.SMSException) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

OrganizationConfigManager (com.sun.identity.sm.OrganizationConfigManager)144 SMSException (com.sun.identity.sm.SMSException)87 Set (java.util.Set)79 HashSet (java.util.HashSet)54 SSOException (com.iplanet.sso.SSOException)50 Map (java.util.Map)48 HashMap (java.util.HashMap)40 SSOToken (com.iplanet.sso.SSOToken)33 IdRepoException (com.sun.identity.idm.IdRepoException)32 Iterator (java.util.Iterator)28 AMIdentity (com.sun.identity.idm.AMIdentity)23 CLIException (com.sun.identity.cli.CLIException)21 AMIdentityRepository (com.sun.identity.idm.AMIdentityRepository)20 ServiceConfig (com.sun.identity.sm.ServiceConfig)17 IOutput (com.sun.identity.cli.IOutput)15 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)15 List (java.util.List)10 ForbiddenException (org.forgerock.json.resource.ForbiddenException)9 BadRequestException (org.forgerock.json.resource.BadRequestException)8 InternalServerErrorException (org.forgerock.json.resource.InternalServerErrorException)8