Search in sources :

Example 6 with ServiceSchema

use of com.sun.identity.sm.ServiceSchema 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 7 with ServiceSchema

use of com.sun.identity.sm.ServiceSchema 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 8 with ServiceSchema

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

the class EnableGenericRepoStep method perform.

@Override
public void perform() throws UpgradeException {
    try {
        ServiceSchema genericSchema = getGenericLDAPv3Schema();
        UpgradeProgress.reportStart("upgrade.genericrepo.start");
        genericSchema.setI18Nkey("a2039");
        UpgradeProgress.reportEnd("upgrade.success");
    } catch (Exception ex) {
        UpgradeProgress.reportEnd("upgrade.failed");
        DEBUG.error("An error occurred while trying to enable the generic LDAPv3 repo", ex);
        throw new UpgradeException(ex);
    }
}
Also used : UpgradeException(org.forgerock.openam.upgrade.UpgradeException) ServiceSchema(com.sun.identity.sm.ServiceSchema) SMSException(com.sun.identity.sm.SMSException) UpgradeException(org.forgerock.openam.upgrade.UpgradeException) SSOException(com.iplanet.sso.SSOException)

Example 9 with ServiceSchema

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

the class EnableGenericRepoStep method getGenericLDAPv3Schema.

private ServiceSchema getGenericLDAPv3Schema() throws SSOException, SMSException {
    ServiceSchemaManager ssm = new ServiceSchemaManager(IdConstants.REPO_SERVICE, getAdminToken());
    ServiceSchema organizationSchema = ssm.getOrganizationSchema();
    ServiceSchema genericSchema = organizationSchema.getSubSchema("LDAPv3");
    return genericSchema;
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager)

Example 10 with ServiceSchema

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

the class UpgradeOAuth2ProviderStep method findUpgradableProviders.

private void findUpgradableProviders() throws UpgradeException {
    try {
        final ServiceSchema serviceSchema = ssm.getOrganizationSchema();
        for (String realm : getRealmNames()) {
            final ServiceConfig serviceConfig = scm.getOrganizationConfig(realm, null);
            final Map<String, Set<String>> withDefaults = serviceConfig.getAttributesForRead();
            final Map<String, Set<String>> withoutDefaults = serviceConfig.getAttributesWithoutDefaultsForRead();
            final Map<String, Set<String>> withoutValidators = SMSUtils.removeValidators(withDefaults, serviceSchema);
            if (isProviderRelyingOnDefaults(withoutDefaults, withoutValidators)) {
                attributesToUpdate.put(realm, withoutValidators);
            } else if (shouldUpgradeClaims(withDefaults)) {
                attributesToUpdate.put(realm, withoutValidators);
            } else if (shouldUpgradeAlgorithmName(withoutDefaults)) {
                attributesToUpdate.put(realm, null);
            }
        }
    } catch (Exception e) {
        DEBUG.error("An error occurred while trying to look for upgradable OAuth2 Providers.", e);
        throw new UpgradeException("Unable to retrieve OAuth2 Providers.", e);
    }
}
Also used : UpgradeException(org.forgerock.openam.upgrade.UpgradeException) ServiceSchema(com.sun.identity.sm.ServiceSchema) Set(java.util.Set) HashSet(java.util.HashSet) ServiceConfig(com.sun.identity.sm.ServiceConfig) UpgradeException(org.forgerock.openam.upgrade.UpgradeException) ServiceNotFoundException(com.sun.identity.sm.ServiceNotFoundException)

Aggregations

ServiceSchema (com.sun.identity.sm.ServiceSchema)216 SMSException (com.sun.identity.sm.SMSException)152 ServiceSchemaManager (com.sun.identity.sm.ServiceSchemaManager)131 SSOException (com.iplanet.sso.SSOException)117 Set (java.util.Set)101 AttributeSchema (com.sun.identity.sm.AttributeSchema)76 HashSet (java.util.HashSet)71 Map (java.util.Map)70 HashMap (java.util.HashMap)57 Iterator (java.util.Iterator)56 CLIException (com.sun.identity.cli.CLIException)46 SSOToken (com.iplanet.sso.SSOToken)27 IOutput (com.sun.identity.cli.IOutput)26 BeforeTest (org.testng.annotations.BeforeTest)22 CLIRequest (com.sun.identity.cli.CLIRequest)21 ByteString (org.forgerock.opendj.ldap.ByteString)21 AfterTest (org.testng.annotations.AfterTest)21 Test (org.testng.annotations.Test)21 Parameters (org.testng.annotations.Parameters)18 TreeSet (java.util.TreeSet)15