Search in sources :

Example 81 with ServiceSchema

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

the class SetAttributeSchemaStartRange 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 schemaType = getStringOptionValue(IArgument.SCHEMA_TYPE);
    String serviceName = getStringOptionValue(IArgument.SERVICE_NAME);
    String subSchemaName = getStringOptionValue(IArgument.SUBSCHEMA_NAME);
    String attributeSchemaName = getStringOptionValue(IArgument.ATTRIBUTE_SCHEMA);
    String range = getStringOptionValue(ARGUMENT_RANGE);
    ServiceSchema ss = getServiceSchema();
    IOutput outputWriter = getOutputWriter();
    try {
        String[] params = { serviceName, schemaType, subSchemaName, attributeSchemaName, range };
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_SET_ATTRIBUTE_SCHEMA_START_RANGE", params);
        AttributeSchema attrSchema = ss.getAttributeSchema(attributeSchemaName);
        if (attrSchema == null) {
            String[] args = { serviceName, schemaType, subSchemaName, attributeSchemaName, range, "attribute schema does not exist" };
            attributeSchemaNoExist(attributeSchemaName, "FAILED_SET_ATTRIBUTE_SCHEMA_START_RANGE", args);
        }
        attrSchema.setStartRange(range);
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_SET_ATTRIBUTE_SCHEMA_START_RANGE", params);
        outputWriter.printlnMessage(MessageFormat.format(getResourceString("attribute-schema-set-start-range-succeed"), (Object[]) params));
    } catch (SSOException e) {
        String[] args = { serviceName, schemaType, subSchemaName, attributeSchemaName, range, e.getMessage() };
        debugError("SetAttributeSchemaStartRange.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_SET_ATTRIBUTE_SCHEMA_START_RANGE", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SMSException e) {
        String[] args = { serviceName, schemaType, subSchemaName, attributeSchemaName, range, e.getMessage() };
        debugError("SetAttributeSchemaStartRange.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_SET_ATTRIBUTE_SCHEMA_START_RANGE", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) SMSException(com.sun.identity.sm.SMSException) IOutput(com.sun.identity.cli.IOutput) AttributeSchema(com.sun.identity.sm.AttributeSchema) CLIException(com.sun.identity.cli.CLIException) SSOException(com.iplanet.sso.SSOException)

Example 82 with ServiceSchema

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

the class SmsResourceProvider method parentSubConfigFor.

/**
     * Gets the ServiceConfig parent of the parent of the config being addressed by the current request.
     * @param context The request context, from which the path variables can be retrieved.
     * @param scm The {@link com.sun.identity.sm.ServiceConfigManager}. See {@link #getServiceConfigManager(Context)}.
     * @return The ServiceConfig that was found.
     * @throws SMSException From downstream service manager layer.
     * @throws SSOException From downstream service manager layer.
     */
protected ServiceConfig parentSubConfigFor(Context context, ServiceConfigManager scm) throws SMSException, SSOException {
    String name = null;
    Map<String, String> uriTemplateVariables = context.asContext(UriRouterContext.class).getUriTemplateVariables();
    if (hasInstanceName) {
        name = uriTemplateVariables.get("name");
    }
    ServiceConfig config = type == SchemaType.GLOBAL ? scm.getGlobalConfig(name) : scm.getOrganizationConfig(realmFor(context), null);
    for (int i = 0; i < subSchemaPath.size() - 1; i++) {
        ServiceSchema schema = subSchemaPath.get(i);
        String pathFragment = schema.getResourceName();
        if (pathFragment == null || "USE-PARENT".equals(pathFragment)) {
            pathFragment = schema.getName();
        }
        if (uriPath.contains("{" + pathFragment + "}")) {
            pathFragment = uriTemplateVariables.get(pathFragment);
        }
        config = config.getSubConfig(pathFragment);
    }
    return config;
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) ServiceConfig(com.sun.identity.sm.ServiceConfig) UriRouterContext(org.forgerock.http.routing.UriRouterContext)

Example 83 with ServiceSchema

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

the class ConfigMonitoring method getMonServiceAttrs.

private int getMonServiceAttrs() {
    String classMethod = "ConfigMonitoring.getMonServiceAttrs: ";
    try {
        ServiceSchemaManager schemaManager = new ServiceSchemaManager("iPlanetAMMonitoringService", ssoToken);
        ServiceSchema smsMonSchema = schemaManager.getGlobalSchema();
        Map monAttrs = smsMonSchema.getAttributeDefaults();
        boolean monEna = Boolean.valueOf(CollectionHelper.getMapAttr(monAttrs, "iplanet-am-monitoring-enabled")).booleanValue();
        if (!monEna) {
            if (debug.warningEnabled()) {
                debug.warning(classMethod + "monitoring is disabled");
            }
            return -1;
        }
        boolean httpEna = Boolean.valueOf(CollectionHelper.getMapAttr(monAttrs, "iplanet-am-monitoring-http-enabled")).booleanValue();
        int httpPort = Integer.valueOf(CollectionHelper.getMapAttr(monAttrs, "iplanet-am-monitoring-http-port"));
        String authFilePath = CollectionHelper.getMapAttr(monAttrs, "iplanet-am-monitoring-authfile-path");
        int rmiPort = Integer.valueOf(CollectionHelper.getMapAttr(monAttrs, "iplanet-am-monitoring-rmi-port"));
        boolean rmiEna = Boolean.valueOf(CollectionHelper.getMapAttr(monAttrs, "iplanet-am-monitoring-rmi-enabled")).booleanValue();
        int snmpPort = Integer.valueOf(CollectionHelper.getMapAttr(monAttrs, "iplanet-am-monitoring-snmp-port"));
        boolean snmpEna = Boolean.valueOf(CollectionHelper.getMapAttr(monAttrs, "iplanet-am-monitoring-snmp-enabled")).booleanValue();
        int policyWindow = Integer.valueOf(CollectionHelper.getMapAttr(monAttrs, "iplanet-am-monitoring-policy-window"));
        int sessionWindow = Integer.valueOf(CollectionHelper.getMapAttr(monAttrs, "iplanet-am-monitoring-session-window"));
        if (debug.messageEnabled()) {
            debug.message(classMethod + "\n" + "     monitoring enabled = " + monEna + "\n" + "     monitoring auth filepath = " + authFilePath + "\n" + "     httpPort = " + httpPort + "\n" + "     httpPort enabled = " + httpEna + "\n" + "     rmiPort = " + rmiPort + "\n" + "     rmiPort enabled = " + rmiEna + "\n" + "     snmpPort = " + snmpPort + "\n" + "     snmpPort enabled = " + snmpEna + "\n" + "     policy eval window size = " + policyWindow + "\n" + "     session eval window size = " + sessionWindow + "\n");
        }
        SSOServerMonConfig sMonInfo = new SSOServerMonConfig.SSOServerMonInfoBuilder(monEna).htmlPort(httpPort).htmlAuthFile(authFilePath).snmpPort(snmpPort).rmiPort(rmiPort).monHtmlEnabled(httpEna).monRmiEnabled(rmiEna).monSnmpEnabled(snmpEna).policyWindowSize(policyWindow).sessionWindowSize(sessionWindow).build();
        int i = Agent.startAgent(sMonInfo);
        if (i != 0) {
            if (debug.warningEnabled()) {
                debug.warning(classMethod + "Monitoring Agent not started (" + i + ")");
            }
            return (i);
        }
    } catch (Exception ex) {
        debug.error(classMethod + "error reading Monitoring attributes: ", ex);
        return (Agent.MON_READATTRS_PROBLEM);
    }
    return 0;
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) SSOServerMonConfig(com.sun.identity.monitoring.SSOServerMonConfig) HashMap(java.util.HashMap) Map(java.util.Map) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager) IdRepoException(com.sun.identity.idm.IdRepoException) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) AMConfigurationException(com.sun.identity.authentication.config.AMConfigurationException)

Example 84 with ServiceSchema

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

the class PropertiesFinder method getProperty.

public static String getProperty(String propertyName, AttributeStruct ast) {
    String value = null;
    SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
    try {
        ServiceSchemaManager ssm = new ServiceSchemaManager(ast.serviceName, adminToken);
        if (ssm.getRevisionNumber() >= ast.revisionNumber) {
            ServiceSchema ss = ssm.getGlobalSchema();
            if (ss != null) {
                AttributeSchema as = ss.getAttributeSchema(ast.attributeName);
                if (as != null) {
                    Set values = as.getDefaultValues();
                    if ((values != null) && !values.isEmpty()) {
                        value = (String) values.iterator().next();
                    }
                }
            }
        }
    } catch (SSOException ex) {
    // ignore: Service may not be present.
    } catch (SMSException ex) {
    // ignore: Service may not be present.
    }
    return value;
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) SSOToken(com.iplanet.sso.SSOToken) Set(java.util.Set) SMSException(com.sun.identity.sm.SMSException) AttributeSchema(com.sun.identity.sm.AttributeSchema) SSOException(com.iplanet.sso.SSOException) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager)

Example 85 with ServiceSchema

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

the class ShowConfigurations method handleRequest.

/**
     * Services a Commandline Request.
     *
     * @param rc Request Context.
     * @throws CLIException if the request cannot serviced.
     */
@Override
public void handleRequest(RequestContext rc) throws CLIException {
    super.handleRequest(rc);
    ldapLogin();
    writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_SHOW_ENTITLEMENT_SVC", null);
    try {
        ServiceSchemaManager ssm = new ServiceSchemaManager(EntitlementService.SERVICE_NAME, getAdminSSOToken());
        ServiceSchema gss = ssm.getGlobalSchema();
        Map<String, Set<String>> defaults = gss.getAttributeDefaults();
        getOutputWriter().printlnMessage(FormatUtils.printAttributeValues(getResourceString("get-attr-values-of-entitlement-service"), defaults));
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEEDED_SHOW_ENTITLEMENT_SVC", null);
    } catch (SMSException e) {
        String[] paramExs = { e.getMessage() };
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "FAILED_SHOW_ENTITLEMENT_SVC", paramExs);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SSOException e) {
        String[] paramExs = { e.getMessage() };
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "FAILED_SHOW_ENTITLEMENT_SVC", paramExs);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) Set(java.util.Set) SMSException(com.sun.identity.sm.SMSException) CLIException(com.sun.identity.cli.CLIException) SSOException(com.iplanet.sso.SSOException) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager)

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