use of org.apache.wink.client.RestClient in project product-is by wso2.
the class SelfSignUpConsentTest method addPurposeCategory.
private String addPurposeCategory(String name, String description) throws JSONException {
RestClient restClient = new RestClient();
Resource piiCatResource = restClient.resource(consentEndpoint + "/" + "purpose-categories");
String addPurposeCatString = "{\"purposeCategory\": " + "\"" + name + "\"" + ", \"description\": " + "\"" + description + "\"}";
User user = new User();
user.setUserName(tenantAdminUserName);
user.setPassword(ADMIN);
String content = piiCatResource.contentType(MediaType.APPLICATION_JSON_TYPE).accept(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, getBasicAuthHeader(user)).post(String.class, addPurposeCatString);
JSONObject purpose = new JSONObject(content);
return purpose.getString("purposeCategoryId");
}
use of org.apache.wink.client.RestClient in project product-is by wso2.
the class SelfSignUpConsentTest method selfRegister.
private void selfRegister(String username, String password, String givenName, String emailAddress, String lastName, String mobile) {
String consent = getConsentReqBody(financialPurposeId, 1, username);
String selfRegisterReqBody = "{\"user\": {\"username\": \"" + username + "\",\"realm\": \"\", " + "\"password\": \"" + password + "\",\"claims\": " + "[{\"uri\": \"http://wso2.org/claims/givenname\",\"value\": \"" + givenName + "\" }," + "{\"uri\": \"http://wso2.org/claims/emailaddress\",\"value\": \"" + emailAddress + "\"}," + "{\"uri\": \"http://wso2.org/claims/lastname\",\"value\": \"" + lastName + "\"}," + "{\"uri\": \"http://wso2.org/claims/mobile\",\"value\": \"" + mobile + "\"} ] }," + "\"properties\": [{\"key\": \"consent\", \"value\": \"" + consent + "\"}]}";
RestClient restClient = new RestClient();
Resource selfRegistrationResource = restClient.resource(selfRegistrationMeEndpoint);
User user = new User();
user.setUserName(tenantAdminUserName);
user.setPassword(ADMIN);
selfRegistrationResource.contentType(MediaType.APPLICATION_JSON_TYPE).accept(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, getBasicAuthHeader(user)).post(String.class, selfRegisterReqBody);
}
use of org.apache.wink.client.RestClient in project product-is by wso2.
the class ConsentMgtTestCase method addPurposeCategory.
private JSONObject addPurposeCategory(String name, String description) {
RestClient restClient = new RestClient();
Resource piiCatResource = restClient.resource(consentEndpoint + "/" + "purpose-categories");
String addPurposeCatString = "{\"purposeCategory\": " + "\"" + name + "\"" + ", \"description\": " + "\"" + description + "\"}";
String response = piiCatResource.contentType(MediaType.APPLICATION_JSON_TYPE).accept(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, getBasicAuthHeader(userInfo)).post(String.class, addPurposeCatString);
return (JSONObject) JSONValue.parse(response);
}
use of org.apache.wink.client.RestClient in project product-is by wso2.
the class ConsentMgtTestCase method addPIICategory.
private JSONObject addPIICategory(String name, String description) {
RestClient restClient = new RestClient();
Resource piiCatResource = restClient.resource(consentEndpoint + "/" + "pii-categories");
String addPIICatString = "{\"piiCategory\": " + "\"" + name + "\"" + ", \"description\": " + "\"" + description + "\" , " + "\"sensitive\": \"" + true + "\"}";
String response = piiCatResource.contentType(MediaType.APPLICATION_JSON_TYPE).accept(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, getBasicAuthHeader(userInfo)).post(String.class, addPIICatString);
return (JSONObject) JSONValue.parse(response);
}
use of org.apache.wink.client.RestClient in project product-is by wso2.
the class SelfSignUpConsentTest method getConsent.
private String getConsent(String username, String password, String receiptId) {
log.info("Retrieving consent for username " + username + ". reciptId : " + receiptId);
RestClient restClient = new RestClient();
Resource resource = restClient.resource(consentEndpoint + "/receipts/" + receiptId);
log.info("Calling to receipt endpoint :" + consentEndpoint + "/receipts/" + receiptId);
User user = new User();
user.setUserName(username);
user.setPassword(password);
String response = resource.contentType(MediaType.APPLICATION_JSON_TYPE).accept(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, getBasicAuthHeader(user)).get(String.class);
return response;
}
Aggregations