Search in sources :

Example 26 with ServiceSchema

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

the class FederationPlugin method setSAMLSiteID.

private void setSAMLSiteID(SSOToken adminSSOToken) {
    try {
        ServiceSchemaManager mgr = new ServiceSchemaManager("iPlanetAMSAMLService", adminSSOToken);
        ServiceSchema ss = mgr.getSchema(SchemaType.GLOBAL);
        Map values = ss.getAttributeDefaults();
        Set siteIDs = (Set) values.get("iplanet-am-saml-siteid-issuername-list");
        if (siteIDs != null && !siteIDs.isEmpty()) {
            String siteID = (String) siteIDs.iterator().next();
            int idPos = siteID.indexOf("=" + ATTR_KEY_SAML_SITEID + "|");
            if (idPos != -1) {
                Map defaults = ServicesDefaultValues.getDefaultValues();
                String protocol = (String) defaults.get(SetupConstants.CONFIG_VAR_SERVER_PROTO);
                String hostname = (String) defaults.get(SetupConstants.CONFIG_VAR_SERVER_HOST);
                String port = (String) defaults.get(SetupConstants.CONFIG_VAR_SERVER_PORT);
                String encoded = SAMLSiteID.generateSourceID(protocol + "://" + hostname + ":" + port);
                siteIDs.remove(siteID);
                siteID = siteID.substring(0, idPos + 1) + encoded + siteID.substring(idPos + ATTR_KEY_SAML_SITEID.length() + 1);
                siteIDs.add(siteID);
                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)

Example 27 with ServiceSchema

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

the class SMDiscoveryServiceModelImpl method addMoreAttributeSchemasForModification.

protected void addMoreAttributeSchemasForModification(Set attributeSchemas) {
    super.addMoreAttributeSchemasForModification(attributeSchemas);
    ServiceSchemaManager mgr = getServiceSchemaManager();
    try {
        ServiceSchema global = mgr.getSchema(SchemaType.GLOBAL);
        attributeSchemas.add(global.getAttributeSchema(AMAdminConstants.DISCOVERY_SERVICE_NAME_BOOTSTRAP_RES_OFF));
    } catch (SMSException e) {
        debug.error("SMDiscoveryServiceModelImpl.addMoreAttributeSchemasForModification", e);
    }
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) SMSException(com.sun.identity.sm.SMSException) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager)

Example 28 with ServiceSchema

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

the class SMDiscoveryServiceModelImpl method getDiscoEntry.

/**
     * Returns resource offering entry stored in the model map for a given
     * type.
     *
     * @param dynamic value to indicate if it is a dynamic or not.
     * @return resource offering entry stored in the model map for a given
     * type.
     */
public Set getDiscoEntry(boolean dynamic) {
    Set set = null;
    if (dynamic) {
    // TO FIX
    } else {
        ServiceSchemaManager mgr = getServiceSchemaManager();
        try {
            ServiceSchema schema = mgr.getSchema(SchemaType.GLOBAL);
            AttributeSchema as = schema.getAttributeSchema(AMAdminConstants.DISCOVERY_SERVICE_NAME_BOOTSTRAP_RES_OFF);
            set = as.getDefaultValues();
        } catch (SMSException e) {
            debug.error("SMDiscoveryServiceModelImpl.getDiscoEntry", e);
        }
    }
    return set;
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) Set(java.util.Set) SMSException(com.sun.identity.sm.SMSException) AttributeSchema(com.sun.identity.sm.AttributeSchema) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager)

Example 29 with ServiceSchema

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

the class SCUtils method getLocalizedServiceName.

public static String getLocalizedServiceName(String serviceName, Locale locale) throws SMSException, SSOException, MissingResourceException {
    String localizedName = null;
    ServiceSchemaManager mgr = new ServiceSchemaManager(serviceName, adminSSOToken);
    ResourceBundle rb = ResourceBundle.getBundle(mgr.getI18NFileName(), locale);
    Set types = mgr.getSchemaTypes();
    if (!types.isEmpty()) {
        SchemaType type = (SchemaType) types.iterator().next();
        ServiceSchema schema = mgr.getSchema(type);
        if (schema != null) {
            String i18nKey = schema.getI18NKey();
            if ((i18nKey != null) && (i18nKey.trim().length() > 0)) {
                localizedName = rb.getString(i18nKey);
            }
        }
    }
    return localizedName;
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) Set(java.util.Set) ResourceBundle(java.util.ResourceBundle) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager) SchemaType(com.sun.identity.sm.SchemaType)

Example 30 with ServiceSchema

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

the class SCModelBase method setAttributeValues.

/** 
     * Sets the attribute values for the specified schema type.
     */
protected void setAttributeValues(SchemaType type, Map values) throws AMConsoleException {
    String serviceName = getServiceName();
    String attributeNames = AMAdminUtils.getString(values.keySet(), ",", false);
    String[] params = { serviceName, type.getType(), attributeNames };
    logEvent("ATTEMPT_SET_ATTR_VALUE_ATR_SCHEMA_SCHEMA_TYPE", params);
    try {
        ServiceSchema schema = getServiceSchemaManager().getSchema(type);
        schema.setAttributeDefaults(values);
        logEvent("SUCCEED_SET_ATTR_VALUE_ATR_SCHEMA_SCHEMA_TYPE", params);
    } catch (SSOException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { serviceName, type.getType(), attributeNames, strError };
        logEvent("SSO_EXCEPTION_SET_ATTR_VALUE_ATR_SCHEMA_SCHEMA_TYPE", paramsEx);
        throw new AMConsoleException(strError);
    } catch (SMSException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { serviceName, type.getType(), attributeNames, strError };
        logEvent("SMS_EXCEPTION_SET_ATTR_VALUE_ATR_SCHEMA_SCHEMA_TYPE", paramsEx);
        throw new AMConsoleException(strError);
    }
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

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