Class SecurityUtils

java.lang.Object
systems.dennis.auth.client.utils.SecurityUtils
All Implemented Interfaces:
systems.dennis.shared.annotations.security.ISecurityUtils<Long>

@Service public class SecurityUtils extends Object implements systems.dennis.shared.annotations.security.ISecurityUtils<Long>
  • Method Details

    • mask

      public static String mask(String token)
      Masks a string withing half of its symbols
      Parameters:
      token - a String to mask
      Returns:
      a masked string
    • isAdmin

      public boolean isAdmin()
      Specified by:
      isAdmin in interface systems.dennis.shared.annotations.security.ISecurityUtils<Long>
    • hasRole

      public boolean hasRole(String role)
      Specified by:
      hasRole in interface systems.dennis.shared.annotations.security.ISecurityUtils<Long>
    • getUserLanguage

      public String getUserLanguage()
      Specified by:
      getUserLanguage in interface systems.dennis.shared.annotations.security.ISecurityUtils<Long>
    • removeLocalAuthorization

      public void removeLocalAuthorization()
    • get

      public UserTokenDTO get() throws systems.dennis.shared.exceptions.AuthorizationNotFoundException
      Throws:
      systems.dennis.shared.exceptions.AuthorizationNotFoundException
    • getUserDataId

      public Long getUserDataId()
      Specified by:
      getUserDataId in interface systems.dennis.shared.annotations.security.ISecurityUtils<Long>
    • checkSubscription

      public void checkSubscription(List<String> possibleSubscriptions)
    • tokenFromHeader

      public UserTokenDTO tokenFromHeader() throws systems.dennis.shared.exceptions.AuthorizationNotFoundException
      Throws:
      systems.dennis.shared.exceptions.AuthorizationNotFoundException
    • generateSecretKey

      public String generateSecretKey()
    • get2factorBarCodeForUser

      public Auth2FactorEnabled get2factorBarCodeForUser(LoginPasswordService loginPasswordService)
    • getLoginData

      public LoginPassword getLoginData(LoginPasswordService service)
    • getGoogleAuthenticatorBarCode

      public String getGoogleAuthenticatorBarCode(String secretKey, String account, String issuer)
    • getTOTPCode

      public String getTOTPCode(LoginPasswordService service, String login)
    • getTOTPCode

      public String getTOTPCode(LoginPassword lp)
    • getTokenFromRequest

      public systems.dennis.shared.entity.TokenData getTokenFromRequest() throws systems.dennis.shared.exceptions.AuthorizationNotFoundException
      Returns a token from request
      Returns:
      string value or null
      Throws:
      systems.dennis.shared.exceptions.AuthorizationNotFoundException
    • getTokenOrThrow

      public systems.dennis.shared.entity.TokenData getTokenOrThrow() throws systems.dennis.shared.exceptions.AuthorizationNotFoundException, systems.dennis.shared.exceptions.AuthorizationNotFoundException
      Returns:
      Throws:
      systems.dennis.shared.exceptions.AuthorizationNotFoundException
    • userOrThrow

      public UserData userOrThrow() throws systems.dennis.shared.exceptions.AuthorizationNotFoundException
      Throws:
      systems.dennis.shared.exceptions.AuthorizationNotFoundException
    • roles

      public List<String> roles() throws systems.dennis.shared.exceptions.AuthorizationNotFoundException
      Throws:
      systems.dennis.shared.exceptions.AuthorizationNotFoundException
    • roleExists

      public boolean roleExists(String... roles) throws systems.dennis.shared.exceptions.AuthorizationNotFoundException
      Throws:
      systems.dennis.shared.exceptions.AuthorizationNotFoundException
    • roleExistsOrThrow

      public void roleExistsOrThrow(String... roles) throws systems.dennis.shared.exceptions.AuthorizationNotFoundException
      Throws:
      systems.dennis.shared.exceptions.AuthorizationNotFoundException
    • anyRole

      public boolean anyRole()
    • isMe

      public void isMe(Long id)
    • getToken

      public systems.dennis.shared.entity.TokenData getToken()
      Specified by:
      getToken in interface systems.dennis.shared.annotations.security.ISecurityUtils<Long>
    • isMy

      public void isMy(Object item)
      Specified by:
      isMy in interface systems.dennis.shared.annotations.security.ISecurityUtils<Long>
    • isMePswrd

      public void isMePswrd(Long id, systems.dennis.shared.config.WebContext.LocalWebContext context)