use of org.wso2.carbon.identity.oauth.dcr.model.RegistrationRequest in project carbon-identity-framework by wso2.
the class UserRegistrationClient method registerUser.
public Response registerUser(SelfRegistrationRequest registrationRequest, Map<String, String> headers) {
SelfUserRegistrationResource selfUserRegistrationResource = IdentityManagementEndpointUtil.create(url, SelfUserRegistrationResource.class, IdentityManagementServiceUtil.getInstance().getJSONProvider(), null, headers);
Response responseObj = selfUserRegistrationResource.registerUser(registrationRequest);
return responseObj;
}
use of org.wso2.carbon.identity.oauth.dcr.model.RegistrationRequest in project identity-inbound-auth-oauth by wso2-extensions.
the class DCRProcessorTest method getInstanceType.
@DataProvider(name = "instanceTypeprovider")
public Object[][] getInstanceType() throws FrameworkClientException {
RegistrationRequest registrationRequest = mock(RegistrationRequest.class);
UnregistrationRequest unregistrationRequest = mock(UnregistrationRequest.class);
return new Object[][] { { "RegistrationRequest", registrationRequest }, { "UnregistrationRequest", unregistrationRequest } };
}
use of org.wso2.carbon.identity.oauth.dcr.model.RegistrationRequest in project identity-inbound-auth-oauth by wso2-extensions.
the class RegistrationHandler method handle.
@Override
public IdentityResponse.IdentityResponseBuilder handle(DCRMessageContext dcrMessageContext) throws DCRException {
if (log.isDebugEnabled()) {
log.debug("Request processing started by RegistrationRequestProcessor.");
}
RegistrationResponse.DCRRegisterResponseBuilder dcrRegisterResponseBuilder = null;
RegistrationRequest registerRequest = (RegistrationRequest) dcrMessageContext.getIdentityRequest();
RegistrationRequestProfile registrationRequestProfile = registerRequest.getRegistrationRequestProfile();
registrationRequestProfile.setTenantDomain(registerRequest.getTenantDomain());
RegistrationResponseProfile registrationResponseProfile = DCRManagementService.getInstance().registerOAuthApplication(registrationRequestProfile);
dcrRegisterResponseBuilder = new RegistrationResponse.DCRRegisterResponseBuilder();
dcrRegisterResponseBuilder.setRegistrationResponseProfile(registrationResponseProfile);
return dcrRegisterResponseBuilder;
}
use of org.wso2.carbon.identity.oauth.dcr.model.RegistrationRequest in project identity-inbound-auth-oauth by wso2-extensions.
the class DCRProcessorTest method testProcessWithException.
@Test(dataProvider = "instanceType&ErrorcodeProvider")
public void testProcessWithException(String request, Object identityRequest, String errorCode) throws Exception {
mockHandlerManager = mock(HandlerManager.class);
mockStatic(HandlerManager.class);
when(HandlerManager.getInstance()).thenReturn(mockHandlerManager);
DCRMessageContext dcrMessageContext = mock(DCRMessageContext.class);
whenNew(DCRMessageContext.class).withArguments(identityRequest).thenReturn(dcrMessageContext);
if (request.equals("RegistrationRequest")) {
RegistrationHandler registrationHandler = mock(RegistrationHandler.class);
when(mockHandlerManager.getRegistrationHandler(dcrMessageContext)).thenReturn(registrationHandler);
if (errorCode.isEmpty()) {
doThrow(new DCRException("")).when(registrationHandler).handle(dcrMessageContext);
} else {
doThrow(new DCRException(errorCode, "")).when(registrationHandler).handle(dcrMessageContext);
}
try {
dcrProcessor.process((RegistrationRequest) identityRequest);
fail("Expected exception IdentityException not thrown by process method");
} catch (IdentityException ex) {
if (errorCode.isEmpty()) {
assertEquals(ex.getErrorCode(), ErrorCodes.BAD_REQUEST.toString());
} else {
assertEquals(ex.getErrorCode(), errorCode);
}
}
} else if (request.equals("UnregistrationRequest")) {
UnRegistrationHandler unRegistrationHandler = mock(UnRegistrationHandler.class);
when(mockHandlerManager.getUnRegistrationHandler(dcrMessageContext)).thenReturn(unRegistrationHandler);
if (errorCode.isEmpty()) {
doThrow(new DCRException("")).when(unRegistrationHandler).handle(dcrMessageContext);
} else {
doThrow(new DCRException(errorCode, "")).when(unRegistrationHandler).handle(dcrMessageContext);
}
try {
dcrProcessor.process((UnregistrationRequest) identityRequest);
fail("Expected exception IdentityException not thrown by registerOAuthApplication");
} catch (IdentityException ex) {
if (errorCode.isEmpty()) {
assertEquals(ex.getMessage(), ErrorCodes.BAD_REQUEST.toString());
} else {
assertEquals(ex.getMessage(), errorCode);
}
}
}
}
use of org.wso2.carbon.identity.oauth.dcr.model.RegistrationRequest in project identity-inbound-auth-oauth by wso2-extensions.
the class DCRProcessor method process.
@Override
public IdentityResponse.IdentityResponseBuilder process(IdentityRequest identityRequest) throws DCRException {
if (log.isDebugEnabled()) {
log.debug("Request processing started by DCRProcessor.");
}
DCRMessageContext dcrMessageContext = new DCRMessageContext(identityRequest);
IdentityResponse.IdentityResponseBuilder identityResponseBuilder = null;
if (identityRequest instanceof RegistrationRequest) {
identityResponseBuilder = registerOAuthApplication(dcrMessageContext);
} else if (identityRequest instanceof UnregistrationRequest) {
identityResponseBuilder = unRegisterOAuthApplication(dcrMessageContext);
}
return identityResponseBuilder;
}
Aggregations