use of org.wso2.charon3.core.protocol.endpoints.MeResourceManager in project charon by wso2.
the class MeResourceManagerTest method setUp.
@BeforeMethod
public void setUp() {
meResourceManager = new MeResourceManager();
abstractResourceManager = Mockito.mockStatic(AbstractResourceManager.class);
userManager = mock(UserManager.class);
abstractResourceManager.when(AbstractResourceManager::getEncoder).thenReturn(new JSONEncoder());
abstractResourceManager.when(AbstractResourceManager::getDecoder).thenReturn(new JSONDecoder());
}
use of org.wso2.charon3.core.protocol.endpoints.MeResourceManager in project identity-inbound-provisioning-scim2 by wso2-extensions.
the class MeResource method patchUser.
@PATCH
public Response patchUser(@HeaderParam(SCIMProviderConstants.CONTENT_TYPE) String inputFormat, @HeaderParam(SCIMProviderConstants.ACCEPT_HEADER) String outputFormat, @QueryParam(SCIMProviderConstants.ATTRIBUTES) String attribute, @QueryParam(SCIMProviderConstants.EXCLUDE_ATTRIBUTES) String excludedAttributes, String resourceString) {
String userId = SupportUtils.getAuthenticatedUserId();
try {
// content-type header is compulsory in post request.
if (inputFormat == null) {
String error = SCIMProviderConstants.CONTENT_TYPE + " not present in the request header";
throw new FormatNotSupportedException(error);
}
if (!isValidInputFormat(inputFormat)) {
String error = inputFormat + " is not supported.";
throw new FormatNotSupportedException(error);
}
if (!isValidOutputFormat(outputFormat)) {
String error = outputFormat + " is not supported.";
throw new FormatNotSupportedException(error);
}
// obtain the user store manager
UserManager userManager = IdentitySCIMManager.getInstance().getUserManager();
// Build Custom schema
buildCustomSchema(userManager, getTenantId());
// create charon-SCIM me resource manager and hand-over the request.
MeResourceManager meResourceManager = new MeResourceManager();
SCIMResponse response = meResourceManager.updateWithPATCH(userId, resourceString, userManager, attribute, excludedAttributes);
return SupportUtils.buildResponse(response);
} catch (CharonException e) {
return handleCharonException(e);
} catch (FormatNotSupportedException e) {
return handleFormatNotSupportedException(e);
}
}
use of org.wso2.charon3.core.protocol.endpoints.MeResourceManager in project identity-inbound-provisioning-scim2 by wso2-extensions.
the class MeResource method deleteUser.
@DELETE
public Response deleteUser(@HeaderParam(SCIMProviderConstants.ACCEPT_HEADER) String format) {
String userId = SupportUtils.getAuthenticatedUserId();
try {
// defaults to application/scim+json.
if (format == null) {
format = SCIMProviderConstants.APPLICATION_SCIM_JSON;
}
if (!isValidOutputFormat(format)) {
String error = format + " is not supported.";
throw new FormatNotSupportedException(error);
}
// obtain the user store manager
UserManager userManager = IdentitySCIMManager.getInstance().getUserManager();
// create charon-SCIM me resource manager and hand-over the request.
MeResourceManager meResourceManager = new MeResourceManager();
SCIMResponse scimResponse = meResourceManager.delete(userId, userManager);
// appropriately.
return SupportUtils.buildResponse(scimResponse);
} catch (CharonException e) {
return handleCharonException(e);
} catch (FormatNotSupportedException e) {
return handleFormatNotSupportedException(e);
}
}
use of org.wso2.charon3.core.protocol.endpoints.MeResourceManager in project identity-inbound-provisioning-scim2 by wso2-extensions.
the class MeResource method createUser.
@POST
public Response createUser(@HeaderParam(SCIMProviderConstants.CONTENT_TYPE) String inputFormat, @HeaderParam(SCIMProviderConstants.ACCEPT_HEADER) String outputFormat, @QueryParam(SCIMProviderConstants.ATTRIBUTES) String attribute, @QueryParam(SCIMProviderConstants.EXCLUDE_ATTRIBUTES) String excludedAttributes, String resourceString) {
try {
// content-type header is compulsory in post request.
if (inputFormat == null) {
String error = SCIMProviderConstants.CONTENT_TYPE + " not present in the request header";
throw new FormatNotSupportedException(error);
}
if (!isValidInputFormat(inputFormat)) {
String error = inputFormat + " is not supported.";
throw new FormatNotSupportedException(error);
}
if (!isValidOutputFormat(outputFormat)) {
String error = outputFormat + " is not supported.";
throw new FormatNotSupportedException(error);
}
// create charon-SCIM user endpoint and hand-over the request.
MeResourceManager meResourceManager = new MeResourceManager();
// obtain the user store manager
UserManager userManager = IdentitySCIMManager.getInstance().getUserManager();
// Build Custom schema
buildCustomSchema(userManager, getTenantId());
SCIMResponse response = meResourceManager.create(resourceString, userManager, attribute, excludedAttributes);
return SupportUtils.buildResponse(response);
} catch (CharonException e) {
return handleCharonException(e);
} catch (FormatNotSupportedException e) {
return handleFormatNotSupportedException(e);
}
}
use of org.wso2.charon3.core.protocol.endpoints.MeResourceManager in project identity-inbound-provisioning-scim2 by wso2-extensions.
the class MeResource method getUser.
@GET
@Produces({ MediaType.APPLICATION_JSON, SCIMProviderConstants.APPLICATION_SCIM_JSON })
public Response getUser(@HeaderParam(SCIMProviderConstants.ACCEPT_HEADER) String outputFormat, @QueryParam(SCIMProviderConstants.ATTRIBUTES) String attribute, @QueryParam(SCIMProviderConstants.EXCLUDE_ATTRIBUTES) String excludedAttributes) {
String userId = SupportUtils.getAuthenticatedUserId();
try {
if (!isValidOutputFormat(outputFormat)) {
String error = outputFormat + " is not supported.";
throw new FormatNotSupportedException(error);
}
// obtain the user store manager
UserManager userManager = IdentitySCIMManager.getInstance().getUserManager();
// Build Custom schema
buildCustomSchema(userManager, getTenantId());
// create charon-SCIM me endpoint and hand-over the request.
MeResourceManager meResourceManager = new MeResourceManager();
SCIMResponse scimResponse = meResourceManager.get(userId, userManager, attribute, excludedAttributes);
// appropriately.
return SupportUtils.buildResponse(scimResponse);
} catch (CharonException e) {
return handleCharonException(e);
} catch (FormatNotSupportedException e) {
return handleFormatNotSupportedException(e);
}
}
Aggregations