Search in sources :

Example 11 with RestClient

use of org.apache.wink.client.RestClient 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(""));
}
Also used : RestClient(org.apache.wink.client.RestClient) Resource(org.apache.wink.client.Resource) BasicAuthInfo(org.wso2.identity.integration.test.utils.BasicAuthInfo) SCIMResponseHandler(org.wso2.identity.integration.test.scim.utils.SCIMResponseHandler) ClientConfig(org.apache.wink.client.ClientConfig) SetEnvironment(org.wso2.carbon.automation.engine.annotations.SetEnvironment) Test(org.testng.annotations.Test)

Example 12 with RestClient

use of org.apache.wink.client.RestClient 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");
}
Also used : RestClient(org.apache.wink.client.RestClient) SCIMResponseHandler(org.wso2.identity.integration.test.scim.utils.SCIMResponseHandler) ClientConfig(org.apache.wink.client.ClientConfig)

Example 13 with RestClient

use of org.apache.wink.client.RestClient in project product-is by wso2.

the class TemplateManagementTestCase method addTemplate.

private JSONObject addTemplate(String templateName, String description, String templateScript) {
    ClientConfig clientConfig = new ClientConfig();
    BasicAuthSecurityHandler basicAuth = new BasicAuthSecurityHandler();
    basicAuth.setUserName(userInfo.getUserName());
    basicAuth.setPassword(userInfo.getPassword());
    clientConfig.handlers(basicAuth);
    RestClient restClient = new RestClient(clientConfig);
    Resource templateResource = restClient.resource(templateMgtEndpoint);
    String addTemplateString = "{" + "\"templateName\": \"" + templateName + "\", " + "\"description\": \"" + description + "\"," + "\"templateScript\": \"" + templateScript + "\"}";
    String response = templateResource.contentType(MediaType.APPLICATION_JSON_TYPE).accept(MediaType.APPLICATION_JSON_TYPE).post(String.class, addTemplateString);
    return (JSONObject) JSONValue.parse(response);
}
Also used : JSONObject(org.json.simple.JSONObject) BasicAuthSecurityHandler(org.apache.wink.client.handlers.BasicAuthSecurityHandler) RestClient(org.apache.wink.client.RestClient) Resource(org.apache.wink.client.Resource) ClientConfig(org.apache.wink.client.ClientConfig)

Example 14 with RestClient

use of org.apache.wink.client.RestClient in project product-is by wso2.

the class SCIMUtils method getUserResource.

/**
 * Returns the UserResource REST access point of SCIM endpoint for given user Id.
 *
 * @param scimClient SCIMClient instance
 * @param scimUrl    SCIM base endpoint URL
 * @param scimId     SCIM ID of the user resource
 * @return           UserResource REST access point client instance
 */
public static Resource getUserResource(SCIMClient scimClient, String scimUrl, String scimId) {
    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(scimUrl + "Users/" + scimId);
}
Also used : RestClient(org.apache.wink.client.RestClient) ClientConfig(org.apache.wink.client.ClientConfig)

Example 15 with RestClient

use of org.apache.wink.client.RestClient in project product-is by wso2.

the class MasterSCIMInitiator method getResource.

protected Resource getResource(SCIMClient scimClient, String skim_url, String skimId) {
    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(skim_url + "Users/" + skimId);
}
Also used : RestClient(org.apache.wink.client.RestClient) SCIMResponseHandler(org.wso2.identity.integration.test.scim.utils.SCIMResponseHandler) ClientConfig(org.apache.wink.client.ClientConfig)

Aggregations

RestClient (org.apache.wink.client.RestClient)33 Resource (org.apache.wink.client.Resource)28 ClientConfig (org.apache.wink.client.ClientConfig)21 SCIMResponseHandler (org.wso2.identity.integration.test.scim.utils.SCIMResponseHandler)16 Test (org.testng.annotations.Test)14 BasicAuthInfo (org.wso2.identity.integration.test.utils.BasicAuthInfo)13 SetEnvironment (org.wso2.carbon.automation.engine.annotations.SetEnvironment)12 JSONObject (org.json.simple.JSONObject)8 User (org.wso2.carbon.automation.engine.context.beans.User)7 BasicAuthSecurityHandler (org.apache.wink.client.handlers.BasicAuthSecurityHandler)3 JSONObject (org.json.JSONObject)2 SCIMClient (org.wso2.charon.core.client.SCIMClient)2 Group (org.wso2.charon.core.objects.Group)2 ISIntegrationTest (org.wso2.identity.integration.common.utils.ISIntegrationTest)2 RemoteException (java.rmi.RemoteException)1 JSONArray (org.json.simple.JSONArray)1 UserAdminUserAdminException (org.wso2.carbon.user.mgt.stub.UserAdminUserAdminException)1 FlaggedName (org.wso2.carbon.user.mgt.stub.types.carbon.FlaggedName)1