use of org.wso2.charon.core.client.SCIMClient in project product-is by wso2.
the class SCIMServiceProviderGroupTestCase method deleteUser.
public void deleteUser() {
ClientConfig clientConfig = new ClientConfig();
SCIMResponseHandler responseHandler = new SCIMResponseHandler();
responseHandler.setSCIMClient(scimClient);
clientConfig.handlers(new ClientHandler[] { responseHandler });
RestClient restClient = new RestClient(clientConfig);
BasicAuthInfo encodedBasicAuthInfo = SCIMUtils.getBasicAuthInfo(userInfo);
Resource userResource = restClient.resource(scim_url + "Users/" + scimUserId);
String response = userResource.header(SCIMConstants.AUTHORIZATION_HEADER, encodedBasicAuthInfo.getAuthorizationHeader()).accept(SCIMConstants.APPLICATION_JSON).delete(String.class);
}
use of org.wso2.charon.core.client.SCIMClient in project product-is by wso2.
the class SCIMServiceProviderUserTestCase method getUser.
@Test(alwaysRun = true, description = "Get SCIM user", dependsOnMethods = { "createUser" })
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.ALL })
public void getUser() {
// create a apache wink ClientHandler to intercept and identify response messages
SCIMResponseHandler responseHandler = new SCIMResponseHandler();
responseHandler.setSCIMClient(scimClient);
// set the handler in wink client config
ClientConfig clientConfig = new ClientConfig();
clientConfig.handlers(new ClientHandler[] { responseHandler });
// create a wink rest client with the above config
RestClient restClient = new RestClient(clientConfig);
BasicAuthInfo encodedBasicAuthInfo = SCIMUtils.getBasicAuthInfo(provider_userInfo);
// create resource endpoint to access a known user resource.
Resource userResource = restClient.resource(scim_url + "Users/" + scimUserId);
String response = userResource.header(SCIMConstants.AUTHORIZATION_HEADER, encodedBasicAuthInfo.getAuthorizationHeader()).contentType(SCIMConstants.APPLICATION_JSON).accept(SCIMConstants.APPLICATION_JSON).get(String.class);
// decode the response
log.info(response);
Assert.assertTrue(response.contains(""));
}
use of org.wso2.charon.core.client.SCIMClient in project product-is by wso2.
the class SCIMServiceProviderUserTestCase method createUser.
@Test(alwaysRun = true, description = "Add SCIM user")
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.ALL })
public void createUser() throws Exception {
// create SCIM client
String encodedUser = SCIMUtils.getEncodedSCIMUser(scimClient, USERNAME, "test", new String[] { "scimuser1@gmail.com", "scimuser1@wso2.com" }, "SCIMUser1", PASSWORD, "sinhala", "0772202595");
// create a apache wink ClientHandler to intercept and identify response messages
Resource userResource = SCIMUtils.getUserResource(scimClient, scim_url);
BasicAuthInfo encodedBasicAuthInfo = SCIMUtils.getBasicAuthInfo(provider_userInfo);
String response = userResource.header(SCIMConstants.AUTHORIZATION_HEADER, encodedBasicAuthInfo.getAuthorizationHeader()).contentType(SCIMConstants.APPLICATION_JSON).accept(SCIMConstants.APPLICATION_JSON).post(String.class, encodedUser);
log.info(response);
Object obj = JSONValue.parse(response);
scimUserId = ((JSONObject) obj).get("id").toString();
userMgtClient.listUsers(USERNAME, 100);
Assert.assertTrue(isUserExists());
Assert.assertNotNull(scimUserId);
}
use of org.wso2.charon.core.client.SCIMClient in project product-is by wso2.
the class SCIMUtils method getSCIMGroup.
/**
* Constructs and returns a Group instance according to the SCIM Schema.
*
* @param scimClient SCIMClient instance
* @param scimUserId SCIM User Id
* @param username Username
* @param externalID External ID of the Group
* @param displayName Display Name of the Group
* @return Group instance
* @throws CharonException
*/
public static Group getSCIMGroup(SCIMClient scimClient, String scimUserId, String username, String externalID, String displayName) throws CharonException {
Group scimGroup = scimClient.createGroup();
scimGroup.setExternalId(externalID);
scimGroup.setDisplayName(displayName);
// set group members
scimGroup.setMember(scimUserId, username);
return scimGroup;
}
use of org.wso2.charon.core.client.SCIMClient in project product-is by wso2.
the class ProvisioningTestCase method getResource.
private Resource getResource(SCIMClient scimClient, String scim_url) {
SCIMResponseHandler responseHandler = new SCIMResponseHandler();
responseHandler.setSCIMClient(scimClient);
// set the handler in wink client config
ClientConfig clientConfig = new ClientConfig();
clientConfig.handlers(new ClientHandler[] { responseHandler });
// create a wink rest client with the above config
RestClient restClient = new RestClient(clientConfig);
// create resource endpoint to access User resource
return restClient.resource(scim_url + "Users");
}
Aggregations