Search in sources :

Example 11 with ServiceSchema

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

the class LogConfigReader method newStatusIsInactive.

private boolean newStatusIsInactive() {
    SSOToken ssoToken;
    try {
        ssoToken = getSSOToken();
    } catch (SSOException ssoe) {
        debug.error("LogConfigReader:newStatusIsInactive:" + "Could not get proper SSOToken", ssoe);
        return false;
    }
    try {
        ServiceSchemaManager schemaManager = new ServiceSchemaManager("iPlanetAMLoggingService", ssoToken);
        ServiceSchema smsLogSchema = schemaManager.getGlobalSchema();
        Map sss = smsLogSchema.getAttributeDefaults();
        String key = LogConstants.LOG_STATUS_ATTR;
        String value = CollectionHelper.getMapAttr(sss, key);
        if ((value == null) || (value.length() == 0)) {
            value = "ACTIVE";
        }
        return (value.equalsIgnoreCase("INACTIVE"));
    } catch (Exception e) {
        debug.error("LogConfigReader:newStatusIsInactive:" + "error reading Log Status attribute: " + e.getMessage());
    }
    return false;
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) SSOToken(com.iplanet.sso.SSOToken) SSOException(com.iplanet.sso.SSOException) Map(java.util.Map) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager) SMSException(com.sun.identity.sm.SMSException) IOException(java.io.IOException) SSOException(com.iplanet.sso.SSOException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 12 with ServiceSchema

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

the class UserIdRepo method getOrgConfig.

static ServiceConfig getOrgConfig(SSOToken adminToken) throws SMSException, SSOException {
    ServiceConfigManager svcCfgMgr = new ServiceConfigManager(IdConstants.REPO_SERVICE, adminToken);
    ServiceConfig cfg = svcCfgMgr.getOrganizationConfig("", null);
    Map values = new HashMap();
    if (cfg == null) {
        OrganizationConfigManager orgCfgMgr = new OrganizationConfigManager(adminToken, "/");
        ServiceSchemaManager schemaMgr = new ServiceSchemaManager(IdConstants.REPO_SERVICE, adminToken);
        ServiceSchema orgSchema = schemaMgr.getOrganizationSchema();
        Set attrs = orgSchema.getAttributeSchemas();
        for (Iterator iter = attrs.iterator(); iter.hasNext(); ) {
            AttributeSchema as = (AttributeSchema) iter.next();
            values.put(as.getName(), as.getDefaultValues());
        }
        cfg = orgCfgMgr.addServiceConfig(IdConstants.REPO_SERVICE, values);
    }
    return cfg;
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) Set(java.util.Set) ServiceConfig(com.sun.identity.sm.ServiceConfig) HashMap(java.util.HashMap) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) Iterator(java.util.Iterator) AttributeSchema(com.sun.identity.sm.AttributeSchema) HashMap(java.util.HashMap) Map(java.util.Map) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager)

Example 13 with ServiceSchema

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

the class AMLogTest method setbufferSizer.

private void setbufferSizer(String statusVal, String buffSize) throws SSOException, SMSException {
    SSOToken adminSSOToken = getAdminSSOToken();
    ServiceSchemaManager mgr = new ServiceSchemaManager("iPlanetAMLoggingService", adminSSOToken);
    ServiceSchema globalSchema = mgr.getSchema(SchemaType.GLOBAL);
    {
        AttributeSchema status = globalSchema.getAttributeSchema("iplanet-am-logging-time-buffering-status");
        Set<String> set = new HashSet<String>(2);
        set.add(statusVal);
        status.setDefaultValues(set);
    }
    {
        AttributeSchema bufferSize = globalSchema.getAttributeSchema("iplanet-am-logging-buffer-size");
        Set<String> set = new HashSet<String>(2);
        set.add(buffSize);
        bufferSize.setDefaultValues(set);
    }
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) SSOToken(com.iplanet.sso.SSOToken) HashSet(java.util.HashSet) Set(java.util.Set) AttributeSchema(com.sun.identity.sm.AttributeSchema) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager)

Example 14 with ServiceSchema

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

the class SchemaTest method setAttributeAny.

@Parameters({ "subschema" })
@Test(groups = { "schema", "set-attr-any", "attribute-schema-ops", "subschema" }, dependsOnMethods = { "addAttributeSchema" })
public void setAttributeAny(String subschema) throws CLIException, SMSException, SSOException {
    Object[] params = { subschema };
    entering("setAttributeAny", params);
    String[] args = (subschema.length() == 0) ? new String[9] : new String[11];
    args[0] = "set-attr-any";
    args[1] = CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SERVICE_NAME;
    args[2] = TEST_SERVICE;
    args[3] = CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SCHEMA_TYPE;
    args[4] = "global";
    args[5] = CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.ATTRIBUTE_SCHEMA;
    args[6] = "mock-add";
    args[7] = CLIConstants.PREFIX_ARGUMENT_LONG + ModifyAttributeSchemaAny.ARGUMENT_ANY;
    args[8] = "admin";
    if (subschema.length() > 0) {
        args[9] = CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SUBSCHEMA_NAME;
        args[10] = subschema;
    }
    CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
    cmdManager.addToRequestQueue(req);
    try {
        cmdManager.serviceRequestQueue();
        ServiceSchemaManager mgr = new ServiceSchemaManager(TEST_SERVICE, getAdminSSOToken());
        ServiceSchema serviceSchema = mgr.getGlobalSchema();
        if (subschema.length() > 0) {
            serviceSchema = serviceSchema.getSubSchema(subschema);
        }
        AttributeSchema as = serviceSchema.getAttributeSchema("mock-add");
        assert (as.getAny().equals("admin"));
        exiting("setAttributeAny");
    } catch (CLIException e) {
        this.log(Level.SEVERE, "setAttributeAny", e.getMessage());
        throw e;
    } catch (SMSException e) {
        this.log(Level.SEVERE, "setAttributeAny", e.getMessage());
        throw e;
    } catch (SSOException e) {
        this.log(Level.SEVERE, "setAttributeAny", e.getMessage());
        throw e;
    }
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) SMSException(com.sun.identity.sm.SMSException) AttributeSchema(com.sun.identity.sm.AttributeSchema) CLIRequest(com.sun.identity.cli.CLIRequest) CLIException(com.sun.identity.cli.CLIException) SSOException(com.iplanet.sso.SSOException) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) AfterTest(org.testng.annotations.AfterTest)

Example 15 with ServiceSchema

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

the class SchemaTest method addAttributeSchema.

@Parameters({ "subschema" })
@Test(groups = { "schema", "add-attrs", "subschema" })
public void addAttributeSchema(String subschema) throws CLIException, SMSException, SSOException {
    Object[] params = { subschema };
    entering("addAttributeSchema", params);
    String[] args = (subschema.length() > 0) ? new String[9] : new String[7];
    args[0] = "add-attrs";
    args[1] = CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SERVICE_NAME;
    args[2] = TEST_SERVICE;
    args[3] = CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SCHEMA_TYPE;
    args[4] = "global";
    args[5] = CLIConstants.PREFIX_ARGUMENT_LONG + AddAttributeSchema.ARGUMENT_SCHEMA_FILES;
    args[6] = MOCK_DIR + "/addAttributeSchema.xml";
    if (subschema.length() > 0) {
        args[7] = CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SUBSCHEMA_NAME;
        args[8] = subschema;
    }
    CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
    cmdManager.addToRequestQueue(req);
    try {
        cmdManager.serviceRequestQueue();
        ServiceSchemaManager mgr = new ServiceSchemaManager(TEST_SERVICE, getAdminSSOToken());
        ServiceSchema serviceSchema = mgr.getGlobalSchema();
        if (subschema.length() > 0) {
            serviceSchema = serviceSchema.getSubSchema(subschema);
        }
        AttributeSchema as = serviceSchema.getAttributeSchema("mock-add");
        assert (as != null);
        exiting("addAttributeSchema");
    } catch (CLIException e) {
        this.log(Level.SEVERE, "addAttributeSchema", e.getMessage(), params);
        throw e;
    } catch (SMSException e) {
        this.log(Level.SEVERE, "addAttributeSchema", e.getMessage(), params);
        throw e;
    } catch (SSOException e) {
        this.log(Level.SEVERE, "addAttributeSchema", e.getMessage(), params);
        throw e;
    }
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) SMSException(com.sun.identity.sm.SMSException) AttributeSchema(com.sun.identity.sm.AttributeSchema) CLIRequest(com.sun.identity.cli.CLIRequest) CLIException(com.sun.identity.cli.CLIException) SSOException(com.iplanet.sso.SSOException) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) AfterTest(org.testng.annotations.AfterTest)

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