Class PrivilegeController

java.lang.Object
org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
com.skava.core.security.CommonExceptionHandler
com.skava.core.errorhandler.ExceptionResponseProcessor
com.skava.auth.helper.AuthExceptionHandler
com.skava.auth.web.PrivilegeController
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.context.MessageSourceAware

@RestController @RequestMapping("/privileges") public class PrivilegeController extends AuthExceptionHandler
This class act as a controller to handle the Privilege's manipulation.
List of operations handled by this controller are
  • Privilege creation
  • Privilege retrieval by privilege identifier
  • Privilege retrieval by collection identifier and search criteria
  • Privilege update
  • Privilege delete
Version:
$Id: $Id
Author:
Infosys Equinox
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     

    Fields inherited from class com.skava.auth.helper.AuthExceptionHandler

    CONST_API_VERSION_DEFAULT, X_TOTAL_COUNT

    Fields inherited from class org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler

    logger, PAGE_NOT_FOUND_LOG_CATEGORY, pageNotFoundLogger
  • Constructor Summary

    Constructors
    Constructor
    Description
    The class constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.springframework.http.ResponseEntity<Object>
    createPrivilege(String version, Long businessId, String authToken, long storeId, PrivilegeVO privilege)
    This service is used to create privilege based on the given privilege data.
    org.springframework.http.ResponseEntity<Object>
    deletePrivilege(String version, Long businessId, String authToken, long storeId, Long privilegeId)
    This service is used to delete privilege for which privilege id given in request.
    org.springframework.http.ResponseEntity<Object>
    getAllPrivileges(String version, Long businessId, String authToken, long storeId, int page, int size, String filter)
    This service is used to get all privileges based on the offset,limit and search parameters.
    org.springframework.http.ResponseEntity<Object>
    getPrivilegeById(String version, Long businessId, String authToken, long storeId, Long privilegeId)
    This service is used to load privilege for which privilege id given in request and sent as response.
    org.springframework.http.ResponseEntity<Object>
    updatePrivilege(String version, Long businessId, String authToken, long storeId, Long privilegeId, PrivilegeVO privilegeDetails)
    This service is used to update privilege for which privilege id given in request.

    Methods inherited from class com.skava.core.errorhandler.ExceptionResponseProcessor

    getExceptionResponse, handleExceptionInternal, handleMethodArgumentNotValid

    Methods inherited from class com.skava.core.security.CommonExceptionHandler

    handleExceptionInternal, handleInternalException

    Methods inherited from class org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler

    createProblemDetail, createResponseEntity, getMessageSource, handleAsyncRequestNotUsableException, handleAsyncRequestTimeoutException, handleConversionNotSupported, handleErrorResponseException, handleException, handleHandlerMethodValidationException, handleHttpMediaTypeNotAcceptable, handleHttpMediaTypeNotSupported, handleHttpMessageNotReadable, handleHttpMessageNotWritable, handleHttpRequestMethodNotSupported, handleMaxUploadSizeExceededException, handleMethodValidationException, handleMissingPathVariable, handleMissingServletRequestParameter, handleMissingServletRequestPart, handleNoHandlerFoundException, handleNoResourceFoundException, handleServletRequestBindingException, handleTypeMismatch, setMessageSource

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • PrivilegeController

      public PrivilegeController()
      The class constructor.
  • Method Details

    • getAllPrivileges

      @GetMapping(value="", headers="x-auth-token") @PreAuthorize("hasRoleForBusinessById(\'ROLE_AUTH_ADMIN\', #businessId) or hasPrivilegeForBusinessById(\'auth/viewall/privileges\', #businessId)") @Audit(action="getPrivileges", repository="privilegeRepository") public org.springframework.http.ResponseEntity<Object> getAllPrivileges(@RequestHeader(value="x-version",required=false,defaultValue="8.19.7") @AuditField(field="VERSION") String version, @RequestParam(value="businessId",required=false) @AuditField(field="BUSINESS_ID") Long businessId, @RequestHeader(value="x-auth-token",required=false) @AuditField(field="AUTH_TOKEN") String authToken, @RequestHeader(value="x-store-id",required=false,defaultValue="0") @AuditField(field="STORE_ID") long storeId, @RequestParam(value="offset",required=false,defaultValue="0") @AuditField(field="PAGE") int page, @RequestParam(value="limit",required=false,defaultValue="100") @AuditField(field="SIZE") int size, @RequestParam(value="filter",required=false) @AuditField(field="FILTER") String filter)
      This service is used to get all privileges based on the offset,limit and search parameters. Privilege is the entity/resource of this microservice to hold authorization information for privilege based authorization.
      Parameters:
      version - It hold the value of version number of API. Using this parameter we can access the different version of the API. It is currently unused.
      businessId - a Long object. Holds a valid business identifier. A Business is typically a customer who has signed up with Infosys Equinox to launch a commerce store or a digital experience. An Infosys Equinox Commerce Instance can have multiple Businesses under which there can be multiple stores - Logical entity which binds all the services together to bring in an storefront experience.
      authToken - a String object. This field holds a valid authorization token generated using the Authorization microservice for an user. Auth token (JWT format) represents claims containing roles and privileges of the user accessing this API. JSON Web Token (JWT) is an open standard (RFC 7519) that defines a compact and self-contained way for securely transmitting information between parties as a JSON object. Since the token is a required field for this API it has to be generated before hand by invoking the /auth/sessions API provided by Authorization microservice. The output is three Base64 strings separated by dots that can be easily passed in HTML and HTTP environments, while being more compact when compared to XML-based standards such as SAML. Thus generated token has to be passed to this service and the request will be processed only if the following conditions are met:
      • Token validation against the secret key
      • Expiry time should be in the future
      • Necessary privileges are available for the user to perform the action on the subjected resource
      .
      storeId - Refers to the unique identifier of the store.
      page - a Long object. The page number to be retrieved where the size of the page must be specified by the size/offset/pageSize parameter. First page starts with value "0".
      size - a Long object. The number of documents being retrieved on the corresponding page specified by page parameter.
      filter - a String object. This field holds the simple query criteria (can be multiple) based on the available fields to limit returned results. Syntax of this parameter is FIELDNAME OP VALUE
      Example 1: field1:value, field2:value
      Example 2: field1>value
      where:
      • FIELDNAME is the entity's attribute name as represented in the response object
      • OP is the operation - Possible values includes
        • LIKE (:) - Loads everything similar (like operation) to the given value.
        • GREATERTHAN (>) - for integer values - loads rows whose column(field) value is greater than the given value
        • LESSTHAN (<) - for integer values - loads rows whose column value is lesser than the given value
      • VALUE is the value against which the operation has to be performed on the field
      Kindly note:
      • filters parameter can have multiple objects.
      • When multiple attributes are used in filter AND behavior is applied.
      Returns:
      Returns List of Privileges.
    • createPrivilege

      @PostMapping("") @ResponseStatus(CREATED) @PreAuthorize("hasRoleForBusinessById(\'ROLE_AUTH_ADMIN\', #businessId) or hasPrivilegeForBusinessById(\'auth/create/privileges\', #businessId)") @Audit(action="createPrivilege", repository="privilegeRepository") public org.springframework.http.ResponseEntity<Object> createPrivilege(@RequestHeader(value="x-version",required=false,defaultValue="8.19.7") @AuditField(field="VERSION") String version, @RequestParam(value="businessId",required=false) @AuditField(field="BUSINESS_ID") Long businessId, @RequestHeader(value="x-auth-token",required=false) @AuditField(field="AUTH_TOKEN") String authToken, @RequestHeader(value="x-store-id",required=false,defaultValue="0") @AuditField(field="STORE_ID") long storeId, @RequestBody @AuditField(field="PRIVILEGE") PrivilegeVO privilege)
      This service is used to create privilege based on the given privilege data. Privilege is the entity/resource of this microservice to hold authorization information for privilege based authorization.
      Parameters:
      version - It hold the value of version number of API. Using this parameter we can access the different version of the API. It is currently unused.
      businessId - a Long object. Holds a valid business identifier. A Business is typically a customer who has signed up with Infosys Equinox to launch a commerce store or a digital experience. An Infosys Equinox Commerce Instance can have multiple Businesses under which there can be multiple stores - Logical entity which binds all the services together to bring in an storefront experience.
      authToken - a String object. This field holds a valid authorization token generated using the Authorization microservice for an user. Auth token (JWT format) represents claims containing roles and privileges of the user accessing this API. JSON Web Token (JWT) is an open standard (RFC 7519) that defines a compact and self-contained way for securely transmitting information between parties as a JSON object. Since the token is a required field for this API it has to be generated before hand by invoking the /auth/sessions API provided by Authorization microservice. The output is three Base64 strings separated by dots that can be easily passed in HTML and HTTP environments, while being more compact when compared to XML-based standards such as SAML. Thus generated token has to be passed to this service and the request will be processed only if the following conditions are met:
      • Token validation against the secret key
      • Expiry time should be in the future
      • Necessary privileges are available for the user to perform the action on the subjected resource
      .
      storeId - Refers to the unique identifier of the store.
      privilege - Indicates Privilege request contains the entire privilege data to be created
      Returns:
      Returns Privilege which was created.
    • getPrivilegeById

      @GetMapping("/{privilegeId}") @PreAuthorize("hasRoleForBusinessById(\'ROLE_AUTH_ADMIN\', #businessId) or hasPrivilegeForBusinessById(\'auth/view/privileges\', #businessId)") @Audit(action="getPrivilege", repository="privilegeRepository") public org.springframework.http.ResponseEntity<Object> getPrivilegeById(@RequestHeader(value="x-version",required=false,defaultValue="8.19.7") @AuditField(field="VERSION") String version, @RequestParam(value="businessId",required=false) @AuditField(field="BUSINESS_ID") Long businessId, @RequestHeader(value="x-auth-token",required=false) @AuditField(field="AUTH_TOKEN") String authToken, @RequestHeader(value="x-store-id",required=false,defaultValue="0") @AuditField(field="STORE_ID") long storeId, @PathVariable("privilegeId") @AuditField(field="PRIVILEGE_ID") Long privilegeId)
      This service is used to load privilege for which privilege id given in request and sent as response. Privilege is the entity/resource of this microservice to hold authorization information for privilege based authorization.
      Parameters:
      version - It hold the value of version number of API. Using this parameter we can access the different version of the API. It is currently unused.
      businessId - a Long object. Holds a valid business identifier. A Business is typically a customer who has signed up with Infosys Equinox to launch a commerce store or a digital experience. An Infosys Equinox Commerce Instance can have multiple Businesses under which there can be multiple stores - Logical entity which binds all the services together to bring in an storefront experience.
      authToken - a String object. This field holds a valid authorization token generated using the Authorization microservice for an user. Auth token (JWT format) represents claims containing roles and privileges of the user accessing this API. JSON Web Token (JWT) is an open standard (RFC 7519) that defines a compact and self-contained way for securely transmitting information between parties as a JSON object. Since the token is a required field for this API it has to be generated before hand by invoking the /auth/sessions API provided by Authorization microservice. The output is three Base64 strings separated by dots that can be easily passed in HTML and HTTP environments, while being more compact when compared to XML-based standards such as SAML. Thus generated token has to be passed to this service and the request will be processed only if the following conditions are met:
      • Token validation against the secret key
      • Expiry time should be in the future
      • Necessary privileges are available for the user to perform the action on the subjected resource
      .
      storeId - Refers to the unique identifier of the store.
      privilegeId - Indicates privilege Id for which user attribute data to be loaded
      Returns:
      Returns Privilege based on the group attribute id given.
    • updatePrivilege

      @PutMapping("/{privilegeId}") @PreAuthorize("hasRoleForBusinessById(\'ROLE_AUTH_ADMIN\', #businessId) or hasPrivilegeForBusinessById(\'auth/update/privileges\', #businessId)") @Audit(action="replacePrivilege", repository="privilegeRepository") public org.springframework.http.ResponseEntity<Object> updatePrivilege(@RequestHeader(value="x-version",required=false,defaultValue="8.19.7") @AuditField(field="VERSION") String version, @RequestParam(value="businessId",required=false) @AuditField(field="BUSINESS_ID") Long businessId, @RequestHeader(value="x-auth-token",required=false) @AuditField(field="AUTH_TOKEN") String authToken, @RequestHeader(value="x-store-id",required=false,defaultValue="0") @AuditField(field="STORE_ID") long storeId, @PathVariable("privilegeId") @AuditField(field="PRIVILEGE_ID") Long privilegeId, @RequestBody @AuditField(field="PRIVILEGE") PrivilegeVO privilegeDetails)
      This service is used to update privilege for which privilege id given in request. Privilege is the entity/resource of this microservice to hold authorization information for privilege based authorization.
      Parameters:
      version - It hold the value of version number of API. Using this parameter we can access the different version of the API. It is currently unused.
      businessId - a Long object. Holds a valid business identifier. A Business is typically a customer who has signed up with Infosys Equinox to launch a commerce store or a digital experience. An Infosys Equinox Commerce Instance can have multiple Businesses under which there can be multiple stores - Logical entity which binds all the services together to bring in an storefront experience.
      authToken - a String object. This field holds a valid authorization token generated using the Authorization microservice for an user. Auth token (JWT format) represents claims containing roles and privileges of the user accessing this API. JSON Web Token (JWT) is an open standard (RFC 7519) that defines a compact and self-contained way for securely transmitting information between parties as a JSON object. Since the token is a required field for this API it has to be generated before hand by invoking the /auth/sessions API provided by Authorization microservice. The output is three Base64 strings separated by dots that can be easily passed in HTML and HTTP environments, while being more compact when compared to XML-based standards such as SAML. Thus generated token has to be passed to this service and the request will be processed only if the following conditions are met:
      • Token validation against the secret key
      • Expiry time should be in the future
      • Necessary privileges are available for the user to perform the action on the subjected resource
      .
      storeId - Refers to the unique identifier of the store.
      privilegeId - Indicates privilege Id for which user attribute data to be updated.
      privilegeDetails - Indicates Privilege request contains the entire privilege data to be updated.
      Returns:
      Returns Privilege based on the privilege id given.
    • deletePrivilege

      @DeleteMapping("/{privilegeId}") @PreAuthorize("hasRoleForBusinessById(\'ROLE_AUTH_ADMIN\', #businessId) or hasPrivilegeForBusinessById(\'auth/delete/privileges\', #businessId)") @Audit(action="deletePrivilege", repository="privilegeRepository") public org.springframework.http.ResponseEntity<Object> deletePrivilege(@RequestHeader(value="x-version",required=false,defaultValue="8.19.7") @AuditField(field="VERSION") String version, @RequestParam(value="businessId",required=false) @AuditField(field="BUSINESS_ID") Long businessId, @RequestHeader(value="x-auth-token",required=false) @AuditField(field="AUTH_TOKEN") String authToken, @RequestHeader(value="x-store-id",required=false,defaultValue="0") @AuditField(field="STORE_ID") long storeId, @PathVariable("privilegeId") @AuditField(field="PRIVILEGE_ID") Long privilegeId)
      This service is used to delete privilege for which privilege id given in request. Privilege is the entity/resource of this microservice to hold authorization information for privilege based authorization.
      Parameters:
      version - It hold the value of version number of API. Using this parameter we can access the different version of the API. It is currently unused.
      businessId - a Long object. Holds a valid business identifier. A Business is typically a customer who has signed up with Infosys Equinox to launch a commerce store or a digital experience. An Infosys Equinox Commerce Instance can have multiple Businesses under which there can be multiple stores - Logical entity which binds all the services together to bring in an storefront experience.
      authToken - a String object. This field holds a valid authorization token generated using the Authorization microservice for an user. Auth token (JWT format) represents claims containing roles and privileges of the user accessing this API. JSON Web Token (JWT) is an open standard (RFC 7519) that defines a compact and self-contained way for securely transmitting information between parties as a JSON object. Since the token is a required field for this API it has to be generated before hand by invoking the /auth/sessions API provided by Authorization microservice. The output is three Base64 strings separated by dots that can be easily passed in HTML and HTTP environments, while being more compact when compared to XML-based standards such as SAML. Thus generated token has to be passed to this service and the request will be processed only if the following conditions are met:
      • Token validation against the secret key
      • Expiry time should be in the future
      • Necessary privileges are available for the user to perform the action on the subjected resource
      .
      storeId - Refers to the unique identifier of the store.
      privilegeId - Indicates privilege Id for which user attribute data to be deleted.
      Returns:
      Returns Object.