Search in sources :

Example 61 with ServiceSchemaManager

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

the class ConfigureData method getServiceSchema.

private ServiceSchema getServiceSchema(String serviceName, SchemaType schemaType, String subSchema) throws SMSException, SSOException {
    ServiceSchemaManager ssm = new ServiceSchemaManager(serviceName, ssoToken);
    ServiceSchema ss = ssm.getSchema(schemaType);
    if (subSchema != null) {
        boolean done = false;
        StringTokenizer st = new StringTokenizer(subSchema, "/");
        while (st.hasMoreTokens() && !done) {
            String str = st.nextToken();
            if (str != null) {
                ss = ss.getSubSchema(str);
                if (ss == null) {
                    throw new RuntimeException("SubSchema" + str + "does not exist");
                }
            } else {
                done = true;
            }
        }
    }
    return ss;
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) StringTokenizer(java.util.StringTokenizer) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager)

Example 62 with ServiceSchemaManager

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

the class AgentConfiguration method getServiceResourceBundle.

public static ResourceBundle getServiceResourceBundle(Locale locale) throws SMSException, SSOException {
    SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
    ServiceSchemaManager ssm = new ServiceSchemaManager(IdConstants.AGENT_SERVICE, adminToken);
    String rbName = ssm.getI18NFileName();
    return ResourceBundle.getBundle(rbName, locale);
}
Also used : SSOToken(com.iplanet.sso.SSOToken) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager)

Example 63 with ServiceSchemaManager

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

the class AddPluginInterface method handleRequest.

/**
     * Services a Commandline Request.
     *
     * @param rc Request Context.
     * @throws CLIException if the request cannot serviced.
     */
public void handleRequest(RequestContext rc) throws CLIException {
    super.handleRequest(rc);
    ldapLogin();
    String serviceName = getStringOptionValue(IArgument.SERVICE_NAME);
    String i18nKey = getStringOptionValue(ARGUMENT_I18N_KEY);
    String interfaceName = getStringOptionValue(ARGUMENT_INTERFACE_NAME);
    String pluginName = getStringOptionValue(ARGUMENT_PLUGIN_NAME);
    ServiceSchemaManager ssm = getServiceSchemaManager();
    IOutput outputWriter = getOutputWriter();
    try {
        String[] params = { serviceName, pluginName };
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_ADD_PLUGIN_INTERFACE", params);
        ssm.addPluginInterface(pluginName, interfaceName, i18nKey);
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_ADD_PLUGIN_INTERFACE", params);
        outputWriter.printlnMessage(MessageFormat.format(getResourceString("add-plugin-interface-succeed"), (Object[]) params));
    } catch (SSOException e) {
        String[] args = { serviceName, pluginName, e.getMessage() };
        debugError("AddPluginInterface.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_PLUGIN_INTERFACE", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SMSException e) {
        String[] args = { serviceName, pluginName, e.getMessage() };
        debugError("AddPluginInterface.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_PLUGIN_INTERFACE", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : SMSException(com.sun.identity.sm.SMSException) IOutput(com.sun.identity.cli.IOutput) CLIException(com.sun.identity.cli.CLIException) SSOException(com.iplanet.sso.SSOException) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager)

Example 64 with ServiceSchemaManager

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

the class DeleteService method deletePolicyRule.

private void deletePolicyRule(RequestContext rc, String serviceName, SSOToken adminSSOToken) throws CLIException, SMSException, SSOException {
    IOutput outputWriter = getOutputWriter();
    List listDelPolicyRule = (List) rc.getOption(ARGUMENT_DELETE_POLICY_RULE);
    if (listDelPolicyRule != null) {
        ServiceSchemaManager ssm = new ServiceSchemaManager(serviceName, adminSSOToken);
        if (ssm == null) {
            if (isVerbose()) {
                outputWriter.printlnMessage(getResourceString("delete-service-no-policy-rules"));
            }
        } else {
            if (ssm.getPolicySchema() == null) {
                if (isVerbose()) {
                    outputWriter.printlnMessage(getResourceString("delete-service-no-policy-schema"));
                }
            } else {
                if (isVerbose()) {
                    outputWriter.printlnMessage(getResourceString("delete-service-delete-policy-rules"));
                }
                processCleanPolicies(serviceName, adminSSOToken);
            }
        }
    }
}
Also used : IOutput(com.sun.identity.cli.IOutput) List(java.util.List) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager)

Example 65 with ServiceSchemaManager

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

the class AMCommonNameGenerator method getAttributeSchemaExactNames.

private Map getAttributeSchemaExactNames(String idType) throws SMSException, SSOException, IdRepoException {
    Map mapping = new HashMap();
    String serviceName = IdUtils.getServiceName(IdUtils.getType(idType));
    if (serviceName != null) {
        ServiceSchemaManager svcSchemaMgr = new ServiceSchemaManager(serviceName, adminSSOToken);
        ServiceSchema svcSchema = svcSchemaMgr.getSchema(idType);
        Set attributeSchemas = (svcSchema != null) ? svcSchema.getAttributeSchemas() : Collections.EMPTY_SET;
        for (Iterator i = attributeSchemas.iterator(); i.hasNext(); ) {
            AttributeSchema as = (AttributeSchema) i.next();
            String name = as.getName();
            mapping.put(name.toLowerCase(), name);
        }
    }
    return mapping;
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) Iterator(java.util.Iterator) AttributeSchema(com.sun.identity.sm.AttributeSchema) HashMap(java.util.HashMap) 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