use of org.wso2.carbon.identity.configuration.mgt.core.model.Attribute in project identity-inbound-provisioning-scim2 by wso2-extensions.
the class UserResource method getUser.
@GET
@Path("{id}")
@Produces({ MediaType.APPLICATION_JSON, SCIMProviderConstants.APPLICATION_SCIM_JSON })
public Response getUser(@PathParam(SCIMConstants.CommonSchemaConstants.ID) String id, @HeaderParam(SCIMProviderConstants.ACCEPT_HEADER) String outputFormat, @QueryParam(SCIMProviderConstants.ATTRIBUTES) String attribute, @QueryParam(SCIMProviderConstants.EXCLUDE_ATTRIBUTES) String excludedAttributes) {
try {
if (!isValidOutputFormat(outputFormat)) {
String error = outputFormat + " is not supported.";
throw new FormatNotSupportedException(error);
}
// obtain the user store manager
UserManager userManager = IdentitySCIMManager.getInstance().getUserManager();
// create charon-SCIM user endpoint and hand-over the request.
UserResourceManager userResourceManager = new UserResourceManager();
// Build Custom schema
buildCustomSchema(userManager, getTenantId());
SCIMResponse scimResponse = userResourceManager.get(id, userManager, attribute, excludedAttributes);
// appropriately.
return SupportUtils.buildResponse(scimResponse);
} catch (CharonException e) {
return handleCharonException(e);
} catch (FormatNotSupportedException e) {
return handleFormatNotSupportedException(e);
}
}
use of org.wso2.carbon.identity.configuration.mgt.core.model.Attribute in project identity-inbound-provisioning-scim2 by wso2-extensions.
the class GroupResource method patchPermissionForGroup.
@PATCH
@Path("{id}/permissions")
@Produces({ MediaType.APPLICATION_JSON, SCIMProviderConstants.APPLICATION_SCIM_JSON })
public Response patchPermissionForGroup(@PathParam(SCIMConstants.CommonSchemaConstants.ID) String id, @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) {
// content-type header is compulsory in post request.
if (inputFormat == null) {
return handleFormatNotSupportedException(new FormatNotSupportedException("Content type: " + SCIMProviderConstants.CONTENT_TYPE + " not present in the request header"));
}
if (!isValidInputFormat(inputFormat)) {
return handleFormatNotSupportedException(new FormatNotSupportedException("Input format: " + inputFormat + " is not supported."));
}
if (!isValidOutputFormat(outputFormat)) {
return handleFormatNotSupportedException(new FormatNotSupportedException("Output format: " + outputFormat + " is not supported."));
}
Map<String, String> requestAttributes = new HashMap<>();
requestAttributes.put(SCIMProviderConstants.ID, id);
requestAttributes.put(SCIMProviderConstants.HTTP_VERB, PATCH.class.getSimpleName());
requestAttributes.put(SCIMProviderConstants.RESOURCE_STRING, resourceString);
requestAttributes.put(SCIMProviderConstants.ATTRIBUTES, PERMISSIONS);
requestAttributes.put(SCIMProviderConstants.EXCLUDE_ATTRIBUTES, excludedAttributes);
return processRequest(requestAttributes);
}
use of org.wso2.carbon.identity.configuration.mgt.core.model.Attribute 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);
}
}
use of org.wso2.carbon.identity.configuration.mgt.core.model.Attribute in project identity-inbound-provisioning-scim2 by wso2-extensions.
the class MeResource method updateUser.
@PUT
public Response updateUser(@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.updateWithPUT(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.carbon.identity.configuration.mgt.core.model.Attribute in project identity-inbound-provisioning-scim2 by wso2-extensions.
the class SupportUtils method buildCustomSchema.
/**
* This builds the custom schema for tenants.
* @param userManager
* @param tenantId
* @throws CharonException
*/
public static void buildCustomSchema(UserManager userManager, int tenantId) throws CharonException {
if (log.isDebugEnabled()) {
log.debug("Building scim2 custom attribute schema for tenant with Id: " + tenantId);
}
if (!SCIMCommonUtils.isCustomSchemaEnabled()) {
return;
}
try {
if (userManager.getCustomUserSchemaExtension() != null) {
if (log.isDebugEnabled()) {
log.debug("Scim2 custom attribute schema is found in the UserManager for tenant with Id: " + tenantId + ". Hence skip building the Extension Builder");
}
return;
}
try {
SCIMCustomSchemaProcessor scimCustomSchemaProcessor = new SCIMCustomSchemaProcessor();
List<SCIMCustomAttribute> attributes = scimCustomSchemaProcessor.getCustomAttributes(IdentityTenantUtil.getTenantDomain(tenantId), getCustomSchemaURI());
AttributeSchema attributeSchema = SCIMCustomSchemaExtensionBuilder.getInstance().buildUserCustomSchemaExtension(attributes);
SCIMCustomAttributeSchemaCache.getInstance().addSCIMCustomAttributeSchema(tenantId, attributeSchema);
} catch (InternalErrorException e) {
throw new CharonException("Error while building scim custom schema", e);
}
} catch (NotImplementedException | BadRequestException | IdentitySCIMException e) {
throw new CharonException("Error while building scim custom schema", e);
}
}
Aggregations