Search in sources :

Example 91 with OrganizationConfigManager

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

the class OpenSSOIndexStore method getParentRealms.

private Set<String> getParentRealms(String realm) throws SMSException {
    Set<String> results = new HashSet<String>();
    SSOToken adminToken = SubjectUtils.getSSOToken(superAdminSubject);
    OrganizationConfigManager ocm = new OrganizationConfigManager(adminToken, realm);
    while (true) {
        ocm = ocm.getParentOrgConfigManager();
        String name = DNMapper.orgNameToRealmName(ocm.getOrganizationName());
        results.add(name);
        if (name.equals("/")) {
            break;
        }
    }
    return results;
}
Also used : SSOToken(com.iplanet.sso.SSOToken) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) HashSet(java.util.HashSet)

Example 92 with OrganizationConfigManager

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

the class OpenSSOIndexStore method getPeerRealms.

private Set<String> getPeerRealms(String realm) throws SMSException {
    SSOToken adminToken = SubjectUtils.getSSOToken(superAdminSubject);
    OrganizationConfigManager ocm = new OrganizationConfigManager(adminToken, realm);
    OrganizationConfigManager parentOrg = ocm.getParentOrgConfigManager();
    String base = DNMapper.orgNameToRealmName(parentOrg.getOrganizationName());
    if (!base.endsWith("/")) {
        base += "/";
    }
    Set<String> results = new HashSet<String>();
    Set<String> subrealms = parentOrg.getSubOrganizationNames();
    for (String s : subrealms) {
        results.add(base + s);
    }
    results.remove(getRealm());
    return results;
}
Also used : SSOToken(com.iplanet.sso.SSOToken) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) HashSet(java.util.HashSet)

Example 93 with OrganizationConfigManager

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

the class SubOrgReferral method getValidValues.

/**Gets the valid values for this referral 
     * matching a pattern
     * @param token SSOToken
     * @param pattern a pattern to match against the value
     * @return <code>ValidValues</code> object
     * @exception SSOException if <code>SSOToken></code> is not valid
     * @exception PolicyException if unable to get the list of valid
     * names.
     */
public ValidValues getValidValues(SSOToken token, String pattern) throws SSOException, PolicyException {
    Set values = new HashSet();
    int status = ValidValues.SUCCESS;
    try {
        Set orgSet = (Set) _configurationMap.get(PolicyManager.ORGANIZATION_NAME);
        if ((orgSet == null) || (orgSet.isEmpty())) {
            OrgReferral.DEBUG.error("SubOrgReferral.getValidValues(): " + " Organization name not set");
            throw new PolicyException(ResBundleUtils.rbName, "org_name_not_set", null, null);
        }
        Iterator iter = orgSet.iterator();
        String orgName = (String) iter.next();
        OrganizationConfigManager orgConfigManager = new OrganizationConfigManager(token, orgName);
        Set subOrgNames = orgConfigManager.getSubOrganizationNames(pattern, //get only first level children
        false);
        if ((subOrgNames != null) && !subOrgNames.isEmpty()) {
            Iterator subOrgsIter = subOrgNames.iterator();
            while (subOrgsIter.hasNext()) {
                String subOrgName = (String) subOrgsIter.next();
                OrganizationConfigManager subOrgManager = orgConfigManager.getSubOrgConfigManager(subOrgName);
                if (subOrgManager != null) {
                    values.add(subOrgManager.getOrganizationName());
                }
            }
        }
        if (debug.messageEnabled()) {
            debug.message("SubOrgReferral.getValidValues():subOrgNames=" + subOrgNames);
        }
    } catch (SMSException smse) {
        OrgReferral.DEBUG.error("Can not get valid values for referral " + getReferralTypeName() + smse);
        String[] objs = { getReferralTypeName() };
        throw new PolicyException(ResBundleUtils.rbName, "can_not_get_values_for_referral", objs, smse);
    }
    return (new ValidValues(status, values));
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) PolicyException(com.sun.identity.policy.PolicyException) SMSException(com.sun.identity.sm.SMSException) ValidValues(com.sun.identity.policy.ValidValues) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) Iterator(java.util.Iterator) HashSet(java.util.HashSet)

Example 94 with OrganizationConfigManager

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

the class Gateway method initGWServletUtilsMap.

private GatewayServletUtils initGWServletUtilsMap(String orgName) {
    GatewayServletUtils utils = null;
    OrganizationConfigManager orgConfigMgr = authD.getOrgConfigManager(orgName);
    try {
        Set registeredServices = orgConfigMgr.getAssignedServices();
        Iterator iter = registeredServices.iterator();
        while (iter.hasNext()) {
            String service = (String) iter.next();
            if (service.trim().indexOf("iPlanetAMAuth") == 0) {
                int idx = service.lastIndexOf("Service");
                String module = null;
                if (idx > "iPlanetAMAuth".length()) {
                    module = service.substring("iPlanetAMAuth".length(), idx);
                } else {
                    continue;
                }
                if (authenticators.contains(module)) {
                    utils = addGWServletUtilsToMap(orgName, module);
                }
            }
        }
    } catch (Exception e) {
        debug.error("Error in GatewayServlet:initGWServletUtilsMap()");
        debug.error("", e);
    }
    return utils;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) Iterator(java.util.Iterator) ServletException(javax.servlet.ServletException) IOException(java.io.IOException)

Example 95 with OrganizationConfigManager

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

the class PolicyModelImpl method getRealmNames.

/**
     * Returns realms that have names matching with a filter.
     *
     * @param base Base realm name for this search. null indicates root
     *        suffix.
     * @param filter Filter string.
     * @return realms that have names matching with a filter.
     * @throws AMConsoleException if search fails.
     */
public Set getRealmNames(String base, String filter) throws AMConsoleException {
    if ((base == null) || (base.length() == 0)) {
        base = getStartDN();
    }
    String[] param = { base };
    logEvent("ATTEMPT_GET_REALM_NAMES", param);
    try {
        OrganizationConfigManager orgMgr = new OrganizationConfigManager(adminSSOToken, base);
        logEvent("SUCCEED_GET_REALM_NAMES", param);
        return appendBaseDN(base, orgMgr.getSubOrganizationNames(filter, true), filter, this);
    } catch (SMSException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { base, strError };
        logEvent("SMS_EXCEPTION_GET_REALM_NAMES", 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)

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