Search in sources :

Example 6 with OrganizationConfigManager

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

the class ApplicationCacheAfterRealmChangeTest method cleanup.

@AfterClass
public void cleanup() throws Exception {
    if (!migrated) {
        return;
    }
    OrganizationConfigManager ocm = new OrganizationConfigManager(adminToken, "/");
    String subRealm = SUB_REALM.substring(1);
    ocm.deleteSubOrganization(subRealm, true);
    setOrgAlias(false);
}
Also used : OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) AfterClass(org.testng.annotations.AfterClass)

Example 7 with OrganizationConfigManager

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

the class CanBeDeletedAppTest method setup.

@BeforeClass
public void setup() throws Exception {
    if (!migrated) {
        return;
    }
    OrganizationConfigManager ocm = new OrganizationConfigManager(adminToken, "/");
    String subRealm = SUB_REALM.substring(1);
    ocm.createSubOrganization(subRealm, Collections.EMPTY_MAP);
    createAppl();
    createPrivilege();
    createApplicationPrivilege();
}
Also used : OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) BeforeClass(org.testng.annotations.BeforeClass)

Example 8 with OrganizationConfigManager

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

the class AgentMigration71 method migrate22AgentsToFAM80.

public static void migrate22AgentsToFAM80() {
    try {
        // Assuming upgrade scripts imported the OpenSSO
        // AgentService.xml,
        // migrate agents from existing DIT (AM 6.x/AM 7.x to OpenSSO
        // Enterprise 8.0.
        SSOToken token = getSSOToken();
        // First get all the sub realms
        OrganizationConfigManager ocmGet = new OrganizationConfigManager(token, "/");
        Set getSet = new HashSet();
        getSet.add(SMSEntry.getRootSuffix());
        Set orgSet = ocmGet.getSubOrganizationNames();
        if (!orgSet.isEmpty()) {
            getSet.addAll(orgSet);
        }
        System.out.println(IdRepoBundle.getString(IdRepoErrorCode.MIGRATION_START));
        Object[] args = { getSet.toString() };
        System.out.println(IdRepoBundle.getString(IdRepoErrorCode.MIGRATION_GETTING_SUBREALMS, args));
        String p = IdConstants.AGENTREPO_PLUGIN;
        Class thisClass = Class.forName(p);
        IdRepo thisPlugin = (IdRepo) thisClass.newInstance();
        // identities from IdRepo node.
        for (Iterator items = getSet.iterator(); items.hasNext(); ) {
            String realm = (String) items.next();
            AMIdentityRepository idRepo = new AMIdentityRepository(token, realm);
            IdSearchResults results = idRepo.searchIdentities(IdType.AGENT, "*", new IdSearchControl());
            Iterator it = results.getSearchResults().iterator();
            while (it.hasNext()) {
                AMIdentity iden = (AMIdentity) it.next();
                String idName = iden.getName();
                Object[] args1 = { idName };
                System.out.println(IdRepoBundle.getString(IdRepoErrorCode.MIGRATION_IDNAME, args1));
                Map attrs = iden.getAttributes();
                attrs.remove("cn");
                attrs.remove("dn");
                attrs.remove("objectclass");
                attrs.remove("sunidentityserverdevicetype");
                attrs.remove("sunidentityserverdeviceversion");
                attrs.remove("uid");
                if (attrs.containsKey("sunidentityserverdevicestatus")) {
                    // To match the schema in OpenSSO's
                    // AgentService.xml
                    Set dSet = (Set) attrs.get("sunidentityserverdevicestatus");
                    attrs.remove("sunidentityserverdevicestatus");
                    attrs.put("sunIdentityServerDeviceStatus", dSet);
                }
                Object[] args2 = { attrs.toString() };
                System.out.println(IdRepoBundle.getString(IdRepoErrorCode.MIGRATION_AGENT_ATTRIBUTES, args2));
                thisPlugin.create(token, IdType.AGENTONLY, idName, attrs);
            }
        // Now upgrade scripts should reset the revision number of 
        // idRepoService.xml from 20 to 30 to add the AgentRepo 
        // as IdRepo Plugin and to display these migrated agents
        // under 'Configuration/Agents' tab.
        }
        System.out.println(IdRepoBundle.getString(IdRepoErrorCode.MIGRATION_COMPLETED));
    } catch (Exception ex2) {
        System.out.println(IdRepoBundle.getString(IdRepoErrorCode.MIGRATION_TO_FAM80_FAILED));
        ex2.printStackTrace();
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) Set(java.util.Set) HashSet(java.util.HashSet) SSOException(com.iplanet.sso.SSOException) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) Iterator(java.util.Iterator) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Example 9 with OrganizationConfigManager

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

the class FedSystemProperties method get.

/**
     * Returns system properties.
     *
     * @param key Key to the properties.
     */
@Override
public String get(String key) {
    String value = null;
    if (isServerMode()) {
        AttributeStruct ast = attributeMap.get(key);
        if (ast != null) {
            value = PropertiesFinder.getProperty(key, ast);
        }
    }
    if (key.startsWith(METADATA_SIGNING_KEY)) {
        //this will be true for both the key alias and the password
        int idx = key.indexOf('[');
        String attribute = key.substring(0, idx);
        String realm = key.substring(idx + 1, key.length() - 1);
        try {
            OrganizationConfigManager orgMgr = new OrganizationConfigManager(AccessController.doPrivileged(AdminTokenAction.getInstance()), realm);
            Map<String, Set<String>> svcAttrs = orgMgr.getServiceAttributes("sunFAMSAML2Configuration");
            return CollectionHelper.getMapAttr(svcAttrs, attribute);
        } catch (SMSException smse) {
            Debug.getInstance("libSAML2").error("Unable to retrieve " + attribute + " from realm: " + realm, smse);
            return null;
        }
    }
    return value != null ? value : getPropertyValue(key);
}
Also used : Set(java.util.Set) SMSException(com.sun.identity.sm.SMSException) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) AttributeStruct(com.sun.identity.common.AttributeStruct)

Example 10 with OrganizationConfigManager

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

the class PeerOrgReferral 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;
    if (debug.messageEnabled()) {
        debug.message("PeerOrgReferral.getValidValues():entering");
    }
    try {
        Set orgSet = (Set) _configurationMap.get(PolicyManager.ORGANIZATION_NAME);
        if ((orgSet == null) || (orgSet.isEmpty())) {
            debug.error("PeerOrgReferral.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);
        String fullOrgName = orgConfigManager.getOrganizationName();
        if (debug.messageEnabled()) {
            debug.message("PeerOrgReferral.getValidValues():fullOrgName=" + fullOrgName);
        }
        OrganizationConfigManager parentOrgConfig = orgConfigManager.getParentOrgConfigManager();
        String fullParentOrgName = parentOrgConfig.getOrganizationName();
        Set subOrgNames = parentOrgConfig.getSubOrganizationNames(pattern, //get only first level children
        false);
        if (!fullOrgName.equals(fullParentOrgName) && (subOrgNames != null) && !subOrgNames.isEmpty()) {
            Iterator subOrgsIter = subOrgNames.iterator();
            while (subOrgsIter.hasNext()) {
                String subOrgName = (String) subOrgsIter.next();
                OrganizationConfigManager subOrgManager = parentOrgConfig.getSubOrgConfigManager(subOrgName);
                if (subOrgManager != null) {
                    String fullSubOrgName = subOrgManager.getOrganizationName();
                    if (!fullOrgName.equals(fullSubOrgName)) {
                        values.add(fullSubOrgName);
                    }
                }
            }
        }
        if (debug.messageEnabled()) {
            debug.message("PeerOrgReferral.getValidValues():returning=" + values);
        }
    } catch (SMSException smse) {
        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)

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