Search in sources :

Example 66 with OrganizationConfigManager

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

the class RealmResourceOfferingModelImpl method assignService.

/**
     * Assigns service to a realm.
     *
     * @param realm Realm Name.
     * @throws AMConsoleException if values cannot be set.
     */
public void assignService(String realm) throws AMConsoleException {
    String[] params = { realm, AMAdminConstants.DISCOVERY_SERVICE };
    try {
        AMIdentityRepository repo = new AMIdentityRepository(getUserSSOToken(), realm);
        AMIdentity realmIdentity = repo.getRealmIdentity();
        Set servicesFromIdRepo = realmIdentity.getAssignableServices();
        if (servicesFromIdRepo.contains(AMAdminConstants.DISCOVERY_SERVICE)) {
            realmIdentity.assignService(AMAdminConstants.DISCOVERY_SERVICE, Collections.EMPTY_MAP);
        } else {
            OrganizationConfigManager orgCfgMgr = new OrganizationConfigManager(getUserSSOToken(), realm);
            orgCfgMgr.assignService(AMAdminConstants.DISCOVERY_SERVICE, Collections.EMPTY_MAP);
        }
    } catch (SSOException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realm, AMAdminConstants.DISCOVERY_SERVICE, strError };
        logEvent("SSO_EXCEPTION_ASSIGN_SERVICE_TO_REALM", paramsEx);
        throw new AMConsoleException(strError);
    } catch (IdRepoException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realm, AMAdminConstants.DISCOVERY_SERVICE, strError };
        logEvent("IDREPO_EXCEPTION_ASSIGN_SERVICE_TO_REALM", paramsEx);
        throw new AMConsoleException(strError);
    } catch (SMSException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realm, AMAdminConstants.DISCOVERY_SERVICE, strError };
        logEvent("SMS_EXCEPTION_ASSIGN_SERVICE_TO_REALM", paramsEx);
        throw new AMConsoleException(strError);
    }
}
Also used : Set(java.util.Set) 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)

Example 67 with OrganizationConfigManager

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

the class ServicesProfileModelImpl method getAttributeValues.

/**
     * Returns attribute values of the service profile.
     *
     * @return attribute values of the service profile.
     */
public Map getAttributeValues() {
    Map map = null;
    String[] params = { currentRealm, serviceName, "*" };
    logEvent("ATTEMPT_GET_ATTR_VALUE_OF_SERVICE_UNDER_REALM", params);
    try {
        AMIdentityRepository repo = new AMIdentityRepository(getUserSSOToken(), currentRealm);
        AMIdentity realmIdentity = repo.getRealmIdentity();
        Set servicesFromIdRepo = realmIdentity.getAssignedServices();
        if (servicesFromIdRepo.contains(serviceName)) {
            map = realmIdentity.getServiceAttributes(serviceName);
        } else {
            OrganizationConfigManager orgCfgMgr = new OrganizationConfigManager(getUserSSOToken(), currentRealm);
            map = orgCfgMgr.getServiceAttributes(serviceName);
        }
        logEvent("SUCCEED_GET_ATTR_VALUE_OF_SERVICE_UNDER_REALM", params);
    } catch (SSOException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { currentRealm, serviceName, strError };
        logEvent("SSO_EXCEPTION_GET_ATTR_VALUE_OF_SERVICE_UNDER_REALM", paramsEx);
        debug.error("ServicesProfileModelImpl.getAttributeValues", e);
    } catch (IdRepoException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { currentRealm, serviceName, strError };
        logEvent("IDREPO_EXCEPTION_GET_ATTR_VALUE_OF_SERVICE_UNDER_REALM", paramsEx);
        debug.error("ServicesProfileModelImpl.getAttributeValues", e);
    } catch (SMSException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { currentRealm, serviceName, strError };
        logEvent("SMS_EXCEPTION_GET_ATTR_VALUE_OF_SERVICE_UNDER_REALM", paramsEx);
        debug.error("ServicesProfileModelImpl.getAttributeValues", e);
    }
    return (map != null) ? map : Collections.EMPTY_MAP;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) 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) Map(java.util.Map)

Example 68 with OrganizationConfigManager

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

the class IDRepoModelImpl method createOrganizationConfig.

private ServiceConfig createOrganizationConfig(String realmName, String idRepoType) throws AMConsoleException {
    try {
        OrganizationConfigManager orgCfgMgr = new OrganizationConfigManager(getUserSSOToken(), realmName);
        Map attrValues = getDefaultAttributeValues();
        return orgCfgMgr.addServiceConfig(IdConstants.REPO_SERVICE, attrValues);
    } catch (SMSException e) {
        throw new AMConsoleException(getErrorString(e));
    }
}
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)

Example 69 with OrganizationConfigManager

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

the class RMRealmModelImpl method getPropertyXML.

private void getPropertyXML(StringBuffer buff, boolean readonly) throws AMConsoleException {
    try {
        OrganizationConfigManager orgMgr = new OrganizationConfigManager(adminSSOToken, "/");
        Set serviceSchemas = orgMgr.getServiceSchemas();
        for (Iterator iter = serviceSchemas.iterator(); iter.hasNext(); ) {
            MultiServicesPropertyXMLBuilder xmlBuilder = new MultiServicesPropertyXMLBuilder((ServiceSchema) iter.next(), this);
            xmlBuilder.setAllAttributeReadOnly(readonly);
            buff.append(xmlBuilder.getXML(false));
        }
    } catch (SSOException e) {
        debug.error("RMRealmModelImpl.getPropertyXML", e);
    } catch (SMSException e) {
        debug.error("RMRealmModelImpl.getPropertyXML", e);
    }
}
Also used : Set(java.util.Set) MultiServicesPropertyXMLBuilder(com.sun.identity.console.property.MultiServicesPropertyXMLBuilder) SMSException(com.sun.identity.sm.SMSException) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) Iterator(java.util.Iterator) SSOException(com.iplanet.sso.SSOException)

Example 70 with OrganizationConfigManager

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

the class RMRealmModelImpl method setAttributeValues.

/**
     * Set attribute values.
     *
     * @param name Name of Realm.
     * @param attributeValues Map of attribute name to set of values.
     * @throws AMConsoleException if attribute values cannot be updated.
     */
public void setAttributeValues(String name, Map attributeValues) throws AMConsoleException {
    try {
        String[] param = { name };
        logEvent("ATTEMPT_SET_ATTR_VALUES_OF_REALM", param);
        OrganizationConfigManager orgMgr = new OrganizationConfigManager(getUserSSOToken(), name);
        Map map = mapAttributeValuesToServiceName(attributeValues);
        for (Iterator iter = map.keySet().iterator(); iter.hasNext(); ) {
            String serviceName = (String) iter.next();
            orgMgr.setAttributes(serviceName, (Map) map.get(serviceName));
        }
        logEvent("SUCCEED_SET_ATTR_VALUES_OF_REALM", param);
    } catch (SMSException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { name, strError };
        logEvent("SMS_EXCEPTION_SET_ATTR_VALUES_OF_REALM", paramsEx);
        throw new AMConsoleException(strError);
    }
}
Also used : SMSException(com.sun.identity.sm.SMSException) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) Iterator(java.util.Iterator) 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