Class AuthUtil

java.lang.Object
com.skava.auth.util.AuthUtil

public final class AuthUtil extends Object
This is a Utility class for Authorization model which contains validator and helper methods used in this service.
Author:
Infosys Equinox
  • Method Details

    • getUserId

      public static Long getUserId()

      getUserId.

      This will return authentication principle(userid)
      Returns:
      a Long object. Identifier of the user by parsing the authorization token.
    • isValidString

      public static boolean isValidString(String input)
      Parameters:
      input - a String object.
      Returns:
      Boolean object.
    • isValidLong

      public static boolean isValidLong(Long input)
      Parameters:
      input - a String object.
      Returns:
      Boolean object.
    • isObjectValid

      public static boolean isObjectValid(Object input)
      Parameters:
      input - a Object object.
      Returns:
      a Boolean object.
    • getMatcherOfFilter

      public static Matcher getMatcherOfFilter(String patternStr, String patternSplitStr, String filter)
      This method will Creates a matcher that will match the given input against given pattern.
      Parameters:
      patternStr - a String object.
      patternSplitStr - a String object.
      filter - a String object.
      Returns:
      a Matcher object.
    • isValidCollectionId

      public static boolean isValidCollectionId(Long collectionId)
      This method is used to validate the collection identifier.
      Parameters:
      collectionId - a Long object.
      Returns:
      a Boolean object. a collection identifier validation result.
    • isBusinessIdValid

      public static boolean isBusinessIdValid(Long businessId)

      isValidBusinessId

      This method is used to validate the collection identifier.
      Parameters:
      businessId - a Long object.
      Returns:
      a Boolean object. a collection identifier validation result.
    • isInstanceLevelBusinessId

      public static boolean isInstanceLevelBusinessId(Long businessId)

      iInstanceLevelBusinessId

      This method is used to validate the collection identifier.
      Parameters:
      businessId - a Long object.
      Returns:
      a Boolean object. a collection identifier validation result.
    • getCollectionStatus

      public static CollectionStatus getCollectionStatus(CollectionVO request)

      validateCollectionStatus

      Parameters:
      request - a CollectionVO object.
      Returns:
      a CollectionStatus object.
    • isCollectionNameValid

      public static boolean isCollectionNameValid(String collectionName)
      Parameters:
      collectionName - a String object.
      Returns:
      a Boolean object.
    • isDescriptionValid

      public static boolean isDescriptionValid(String description)
      Parameters:
      description - a String object.
      Returns:
      a Boolean object.
    • getCollectionProperties

      public static Set<CollectionProperty> getCollectionProperties(Collection collection, List<CollectionPropertyVO> requestProperties, List<CollectionAttribute> attributes, org.springframework.context.MessageSource messageSource)
      Parameters:
      collection - a Collection object.
      requestProperties - a List of CollectionPropertyVO objects.
      attributes - a List of CollectionAttribute objects.
      messageSource - a MessageSource object.
      Returns:
      a Set of CollectionProperty objects.
    • getUpdatedCollectionProperties

      public static Set<CollectionProperty> getUpdatedCollectionProperties(Collection collection, List<CollectionPropertyVO> requestProperties, List<CollectionAttribute> attributes, org.springframework.context.MessageSource messageSource)
      Parameters:
      collection - a Collection object.
      requestProperties - a List of CollectionPropertyVO objects.
      attributes - a List of CollectionAttribute objects.
      messageSource - a MessageSource object.
      Returns:
      a Set of CollectionProperty objects.
    • getPropertyValue

      public static String getPropertyValue(CollectionAttribute attribute, CollectionPropertyVO requestProperty)
      Parameters:
      attribute - a CollectionAttribute object.
      requestProperty - a CollectionPropertyVO object.
      Returns:
      a String object.
    • isCollectionPropertyAndAttributeEquals

      public static boolean isCollectionPropertyAndAttributeEquals(CollectionAttribute attribute, CollectionPropertyVO property)
      Parameters:
      attribute - a CollectionAttribute object.
      property - a CollectionPropertyVO object.
      Returns:
      a Boolean object.
    • isCollectionPropertyHaveValidValue

      public static boolean isCollectionPropertyHaveValidValue(CollectionPropertyVO property)
      Parameters:
      property - a CollectionPropertyVO object.
      Returns:
      a Boolean object.
    • isBearerTokenValid

      public static boolean isBearerTokenValid(String[] tokenData, Long userId)
      This method used to validate the bearer token based on the given user information.
      Parameters:
      tokenData - an Array of String objects.
      userId - a Long object.
      Returns:
      Boolean object.
    • decryptBearerToken

      public static String[] decryptBearerToken(org.springframework.security.crypto.encrypt.TextEncryptor textEncryptor, String token)
    • getPossibleValues

      public static List<String> getPossibleValues(CollectionAttribute attribute)
      Parameters:
      attribute - a CollectionAttribute object.
      Returns:
      a List of String objects.
    • isPossibleValuesAvailable

      public static boolean isPossibleValuesAvailable(CollectionAttributeType attributeType)
      Parameters:
      attributeType - a CollectionAttributeType object.
      Returns:
      a Boolean object.
    • isUserIdValid

      public static boolean isUserIdValid(Long userId)
    • isClientIdValid

      public static boolean isClientIdValid(String clientId)
    • isRoleNameValid

      public static boolean isRoleNameValid(String roleName)
    • hasSelfAccess

      public static boolean hasSelfAccess(Long collectionId, Matcher valuesMatcher, int userCount, com.skava.core.auth.AuthTokenHandler authTokenHandler)
      Parameters:
      collectionId - a Long object.
      valuesMatcher - a Matcher object.
      userCount - a Integer object.
      authTokenHandler - a AuthTokenHandler object.
      Returns:
      a Boolean object.
    • hasSelfClientAccess

      public static boolean hasSelfClientAccess(Long collectionId, Matcher valuesMatcher, int clientCount, com.skava.core.auth.AuthTokenHandler authTokenHandler)
      Parameters:
      collectionId - a Long object.
      valuesMatcher - a Matcher object.
      clientCount - a Integer object.
      authTokenHandler - a AuthTokenHandler object.
      Returns:
      a Boolean object.
    • getCurrentMilliseconds

      public static long getCurrentMilliseconds()
      This method will return the current milliseconds using Calendar object.
      Returns:
      long time in milliseconds
    • isClientBearerTokenValid

      public static boolean isClientBearerTokenValid(String[] tokenData, String clientId)
      This method used to validate the bearer token based on the given client information.
      Parameters:
      tokenData - an Array of String objects.
      clientId - a String object.
      Returns:
      Boolean object.