Search in sources :

Example 61 with ServiceSchema

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

the class ClientResourceTest method setUp.

@BeforeTest
public void setUp() throws SMSException {
    mockManager = mock(ClientResourceManager.class);
    ServiceSchemaManager mockSchemaManager = mock(ServiceSchemaManager.class);
    ServiceSchema mockSchema = mock(ServiceSchema.class);
    mockSubSchema = mock(ServiceSchema.class);
    Mockito.doReturn(mockSchema).when(mockSchemaManager).getOrganizationSchema();
    Mockito.doReturn(mockSubSchema).when(mockSchema).getSubSchema(anyString());
    resource = new ClientResource(mockManager, mock(CTSPersistentStore.class), mockSchemaManager, mock(OAuth2AuditLogger.class), mock(Debug.class));
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager) BeforeTest(org.testng.annotations.BeforeTest)

Example 62 with ServiceSchema

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

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

the class ConfigureData method modifySchemaDefaultValues.

private void modifySchemaDefaultValues(String serviceName, SchemaType schemaType, String subSchema, Map values) throws SMSException, SSOException, IOException {
    ServiceSchema ss = getServiceSchema(serviceName, schemaType, subSchema);
    ss.setAttributeDefaults(values);
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema)

Example 64 with ServiceSchema

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

the class AgentConfiguration method getAgentAttributeSchema.

/**
     * Returns attribute schema of a given agent type.
     *
     * @param name Name of attribute schema.
     * @param agentTypeName Name of agent type.
     * @return attribute schema of a given agent type.
     * @throws SSOException if the Single Sign On token is invalid or has
     *         expired.
     * @throws SMSException if there are errors in service management layers.
     */
public static AttributeSchema getAgentAttributeSchema(String name, String agentTypeName) throws SMSException, SSOException {
    AttributeSchema as = null;
    ServiceSchema ss = getOrganizationSchema();
    if (ss != null) {
        ServiceSchema ssType = ss.getSubSchema(agentTypeName);
        as = ssType.getAttributeSchema(name);
    }
    return as;
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) AttributeSchema(com.sun.identity.sm.AttributeSchema)

Example 65 with ServiceSchema

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

the class RegisterAuthModule 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 authModule = getStringOptionValue(AUTH_MODULE);
    ServiceSchema ss = getServiceSchema(ISAuthConstants.AUTH_SERVICE_NAME, null, "Global");
    IOutput outputWriter = getOutputWriter();
    try {
        String[] params = { ISAuthConstants.AUTH_SERVICE_NAME };
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_REGISTER_AUTH_MODULE", params);
        Map attrValues = ss.getAttributeDefaults();
        Set values = (Set) attrValues.get(AUTH_AUTHENTICATOR_ATTR);
        if ((values == null) || values.isEmpty()) {
            values = new HashSet(2);
        }
        values.add(authModule);
        ss.setAttributeDefaults(AUTH_AUTHENTICATOR_ATTR, values);
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_REGISTER_AUTH_MODULE", params);
        outputWriter.printlnMessage(getResourceString("register-auth-module-succeeded"));
    } catch (SSOException e) {
        String[] args = { ISAuthConstants.AUTH_SERVICE_NAME, e.getMessage() };
        debugError("RegisterAuthModule.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_REGISTER_AUTH_MODULE", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SMSException e) {
        String[] args = { ISAuthConstants.AUTH_SERVICE_NAME, e.getMessage() };
        debugError("RegisterAuthModule.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_REGISTER_AUTH_MODULE", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) Set(java.util.Set) HashSet(java.util.HashSet) SMSException(com.sun.identity.sm.SMSException) IOutput(com.sun.identity.cli.IOutput) CLIException(com.sun.identity.cli.CLIException) SSOException(com.iplanet.sso.SSOException) Map(java.util.Map) HashSet(java.util.HashSet)

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