use of org.wso2.carbon.identity.entitlement.endpoint.resources.models.EntitledAttributesResponseModel in project carbon-identity-framework by wso2.
the class DecisionResource method getEntitledAttributes.
/**
* API endpoint for returning entitled attributes for a give set of parameters
*
* @return EntitledAttributesResponse object
*/
@POST
@Path("entitled-attribs")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "Get entitled attributes for a given set of parameters", response = EntitledAttributesResponseModel.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Entitled Attributes response", response = EntitledAttributesResponseModel.class), @ApiResponse(code = 40010, message = EntitlementEndpointConstants.ERROR_UNAUTHORIZED_MESSAGE, response = ExceptionBean.class), @ApiResponse(code = 40020, message = EntitlementEndpointConstants.ERROR_REQUEST_PARSE_MESSAGE, response = ExceptionBean.class), @ApiResponse(code = 40010, message = EntitlementEndpointConstants.ERROR_RESPONSE_READ_MESSAGE, response = ExceptionBean.class) })
public EntitledAttributesResponseModel getEntitledAttributes(@ApiParam(value = "Request Media Type", required = true) @HeaderParam(EntitlementEndpointConstants.ACCEPT_HEADER) String format, @ApiParam(value = "Authentication Type", required = true) @HeaderParam(EntitlementEndpointConstants.AUTHENTICATION_TYPE_HEADER) String authMechanism, @ApiParam(value = "Add HTTP Basic Authorization", required = true) @HeaderParam(EntitlementEndpointConstants.AUTHORIZATION_HEADER) String authorization, @ApiParam(value = "Response Media Type", required = true) @HeaderParam(EntitlementEndpointConstants.CONTENT_TYPE_HEADER) String contentType, @ApiParam(value = "Entitled Attributes Model", required = true) EntitledAttributesRequestModel request) throws Exception {
if (request.getSubjectName() == null) {
log.error("Invalid input data - either the user name or role name should be non-null");
throw new RequestParseException(40022, "Invalid input data - either the user name or role name should be non-null");
}
PolicySearch policySearch = EntitlementEngine.getInstance().getPolicySearch();
EntitledResultSetDTO resultsSet = policySearch.getEntitledAttributes(request.getSubjectName(), request.getResourceName(), request.getSubjectId(), request.getAction(), request.isEnableChildSearch());
EntitledAttributesResponseModel response = new EntitledAttributesResponseModel();
response.setEntitledResultSetDTO(resultsSet);
return response;
}
Aggregations