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));
}
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;
}
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);
}
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;
}
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);
}
}
Aggregations