Search in sources :

Example 96 with ServiceSchemaManager

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

the class ApplicationCacheAfterRealmChangeTest method setOrgAlias.

private void setOrgAlias(boolean flag) throws SMSException, SSOException {
    ServiceSchemaManager ssm = new ServiceSchemaManager(PolicyConfig.POLICY_CONFIG_SERVICE, adminToken);
    ServiceSchema global = ssm.getSchema(SchemaType.GLOBAL);
    Set<String> values = new HashSet<String>();
    values.add(Boolean.toString(flag));
    global.setAttributeDefaults("sun-am-policy-config-org-alias-mapped-resources-enabled", values);
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager) HashSet(java.util.HashSet)

Example 97 with ServiceSchemaManager

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

the class DelegationUtils method getRevisionNumber.

/** 
     * gets the Delegation Service revision number
     * @return the revision number of the delegation service.
     * 
     */
static int getRevisionNumber() {
    if (revisionNum == 0) {
        try {
            ServiceSchemaManager ssm = new ServiceSchemaManager(DelegationManager.DELEGATION_SERVICE, DelegationManager.getAdminToken());
            revisionNum = ssm.getRevisionNumber();
            if (debug.messageEnabled()) {
                debug.message("DelegationUtils.getRevisionNumber(): " + "Delegation Service revision number is " + revisionNum);
            }
        } catch (SMSException sme) {
            debug.error("DelegationUtils.getRevisionNumber(): " + "Unable to get Delegation revision number", sme);
        } catch (SSOException ssoe) {
            debug.error("DelegationUtils.getRevisionNumber(): " + "Unable to get Delegation revision number", ssoe);
        }
    }
    return revisionNum;
}
Also used : SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager)

Example 98 with ServiceSchemaManager

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

the class ConfigFedMonitoring method getSAML1TPs.

private void getSAML1TPs() {
    String classMethod = "ConfigFedMonitoring.getSAML1TPs: ";
    try {
        // get SAML service attributes
        Map attributeSchemas = new HashMap();
        ServiceSchemaManager svcSchMgr = new ServiceSchemaManager("iPlanetAMSAMLService", ssoToken);
        Set schemaTypes = svcSchMgr.getSchemaTypes();
        for (Iterator it = schemaTypes.iterator(); it.hasNext(); ) {
            SchemaType type = (SchemaType) it.next();
            ServiceSchema schema = svcSchMgr.getSchema(type);
            if (schema != null) {
                String curSchemaType = type.getType();
                Set asch = schema.getAttributeSchemas();
                for (Iterator iu = asch.iterator(); iu.hasNext(); ) {
                    AttributeSchema as = (AttributeSchema) iu.next();
                    String i18n = as.getI18NKey();
                    if ((i18n != null) && (i18n.trim().length() > 0)) {
                        attributeSchemas.put(as.getName(), as);
                    }
                }
            }
        }
        // get the trusted partners 
        StringBuffer cotsb = new StringBuffer(classMethod + "SAML1.x Trusted Partners:\n");
        AttributeSchema as = (AttributeSchema) attributeSchemas.get("iplanet-am-saml-partner-urls");
        Set orgValues = (Set) as.getDefaultValues();
        int ovsize = orgValues.size();
        if (debug.messageEnabled()) {
            cotsb.append("  has ").append(ovsize).append(" entries:\n");
        }
        List s1List = new ArrayList(ovsize);
        if (ovsize > 0) {
            for (Iterator iu = orgValues.iterator(); iu.hasNext(); ) {
                String prtn = (String) iu.next();
                StringTokenizer st = new StringTokenizer(prtn, "|");
                int numtoks = st.countTokens();
                if (debug.messageEnabled()) {
                    cotsb.append("  #tokens = ").append(numtoks).append("\n");
                }
                String xx = null;
                while (st.hasMoreTokens()) {
                    prtn = st.nextToken();
                    StringTokenizer st2 = new StringTokenizer(prtn, "=");
                    if (st2.countTokens() == 2) {
                        String st3 = st2.nextToken();
                        xx = st2.nextToken();
                        if (st3.equalsIgnoreCase("PARTNERNAME")) {
                            if (debug.messageEnabled()) {
                                cotsb.append("  **got PARTNERNAME**\n");
                            }
                            s1List.add(xx);
                        }
                    }
                }
                if (debug.messageEnabled()) {
                    cotsb.append("    ").append(xx).append("\n");
                }
            }
        }
        if (debug.messageEnabled()) {
            debug.message(cotsb.toString());
        }
        // send SAML1.x trusted partners list, s1List, to the Agent
        Agent.saml1TPConfig(s1List);
    } catch (SSOException e) {
        debug.error(classMethod + "sso ex getting saml1.x: " + e.getMessage());
    } catch (SMSException e) {
        debug.error(classMethod + "sms ex getting saml1.x: " + e.getMessage());
    }
}
Also used : Set(java.util.Set) HashMap(java.util.HashMap) SMSException(com.sun.identity.sm.SMSException) ArrayList(java.util.ArrayList) SSOException(com.iplanet.sso.SSOException) SchemaType(com.sun.identity.sm.SchemaType) ServiceSchema(com.sun.identity.sm.ServiceSchema) StringTokenizer(java.util.StringTokenizer) Iterator(java.util.Iterator) AttributeSchema(com.sun.identity.sm.AttributeSchema) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager)

Example 99 with ServiceSchemaManager

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

the class DelegationManager method loadDelegationPlugin.

/**
     * Loads the default implementation of DelegationInterface
     */
static synchronized DelegationInterface loadDelegationPlugin() throws DelegationException {
    if (pluginInstance == null) {
        try {
            // get super admin user token
            SSOToken privilegedToken = getAdminToken();
            ServiceSchemaManager ssm = new ServiceSchemaManager(DELEGATION_SERVICE, privilegedToken);
            ServiceSchema globalSchema = ssm.getGlobalSchema();
            if (globalSchema != null) {
                Map attributeDefaults = globalSchema.getAttributeDefaults();
                if (attributeDefaults != null) {
                    subjectIdTypes.addAll((Set) attributeDefaults.get(SUBJECT_ID_TYPES));
                }
            }
            if (debug.messageEnabled()) {
                debug.message("Configured Subject ID Types: " + subjectIdTypes);
            }
            Set pluginNames = ssm.getPluginSchemaNames(DELEGATION_PLUGIN_INTERFACE, null);
            if (pluginNames == null) {
                throw new DelegationException(ResBundleUtils.rbName, "no_plugin_specified", null, null);
            }
            if (debug.messageEnabled()) {
                debug.message("pluginNames=" + pluginNames);
            }
            // for the time being, only support one plugin
            Iterator it = pluginNames.iterator();
            if (it.hasNext()) {
                String pluginName = (String) it.next();
                PluginSchema ps = ssm.getPluginSchema(pluginName, DELEGATION_PLUGIN_INTERFACE, null);
                if (ps == null) {
                    throw new DelegationException(ResBundleUtils.rbName, "no_plugin_specified", null, null);
                }
                String className = ps.getClassName();
                if (debug.messageEnabled()) {
                    debug.message("Plugin class name:" + className);
                }
                pluginInstance = (DelegationInterface) Class.forName(className).newInstance();
                pluginInstance.initialize(privilegedToken, null);
                if (debug.messageEnabled()) {
                    debug.message("Successfully created " + "a delegation plugin instance");
                }
            } else {
                throw new DelegationException(ResBundleUtils.rbName, "no_plugin_specified", null, null);
            }
        } catch (Exception e) {
            debug.error("Unable to get an instance of plugin " + "for delegation", e);
            pluginInstance = null;
            throw new DelegationException(e);
        }
    }
    return pluginInstance;
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) SSOToken(com.iplanet.sso.SSOToken) Set(java.util.Set) CaseInsensitiveHashSet(com.sun.identity.common.CaseInsensitiveHashSet) HashSet(java.util.HashSet) PluginSchema(com.sun.identity.sm.PluginSchema) Iterator(java.util.Iterator) Map(java.util.Map) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager) SMSException(com.sun.identity.sm.SMSException) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException)

Example 100 with ServiceSchemaManager

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

the class FederationPlugin method setAuthModules.

private void setAuthModules(SSOToken adminSSOToken) {
    try {
        ServiceSchemaManager mgr = new ServiceSchemaManager("iPlanetAMAuthService", adminSSOToken);
        ServiceSchema ss = mgr.getSchema(SchemaType.GLOBAL);
        Map values = ss.getAttributeDefaults();
        Set modules = (Set) values.get("iplanet-am-auth-authenticators");
        modules.add("com.sun.identity.authentication.modules.federation.Federation");
        modules.add("com.sun.identity.authentication.modules.sae.SAE");
        ss.setAttributeDefaults(values);
    } catch (SSOException e) {
        e.printStackTrace();
        throw new RuntimeException(e);
    } catch (SMSException e) {
        e.printStackTrace();
        throw new RuntimeException(e);
    }
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) Set(java.util.Set) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) Map(java.util.Map) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager)

Aggregations

ServiceSchemaManager (com.sun.identity.sm.ServiceSchemaManager)209 SMSException (com.sun.identity.sm.SMSException)146 ServiceSchema (com.sun.identity.sm.ServiceSchema)131 SSOException (com.iplanet.sso.SSOException)119 Set (java.util.Set)87 HashSet (java.util.HashSet)60 Map (java.util.Map)56 HashMap (java.util.HashMap)49 AttributeSchema (com.sun.identity.sm.AttributeSchema)46 SSOToken (com.iplanet.sso.SSOToken)43 Iterator (java.util.Iterator)40 CLIException (com.sun.identity.cli.CLIException)33 BeforeTest (org.testng.annotations.BeforeTest)27 AfterTest (org.testng.annotations.AfterTest)26 Test (org.testng.annotations.Test)26 CLIRequest (com.sun.identity.cli.CLIRequest)25 Parameters (org.testng.annotations.Parameters)18 ServiceConfigManager (com.sun.identity.sm.ServiceConfigManager)15 TreeSet (java.util.TreeSet)12 ByteString (org.forgerock.opendj.ldap.ByteString)11