Class SecurityService

java.lang.Object
com.wavemaker.runtime.security.SecurityService

@Service public class SecurityService extends Object
The Security Service provides interfaces to access authentication and authorization information in the system.
  • Constructor Details

    • SecurityService

      public SecurityService()
  • Method Details

    • getTenantId

      @Deprecated public static int getTenantId()
      Deprecated.
      This method is deprecated. You can set custom attributes in successhandlers.
    • isSecurityEnabled

      public boolean isSecurityEnabled()
      Checks whether the security is enabled or not. It returns true if it is enable, else, false.
      Returns:
      true if the security is enabled; otherwise, false.
    • getLoginConfig

      public com.wavemaker.app.security.models.LoginConfig getLoginConfig()
    • isAuthenticated

      public boolean isAuthenticated()
      Checks whether the user has been authenticated or not depending on authentication object.
      Returns:
      true if the user was authenticated; otherwise, false.
    • getClientAttributes

      public Map<String,Object> getClientAttributes()
    • getAllAttributes

      public Map<String,Object> getAllAttributes()
    • addAttribute

      public boolean addAttribute(String key, Object value, Attribute.AttributeScope attributeScope)
    • getLoggedInUser

      public WMCurrentUser getLoggedInUser()
      Get Current LoggedIn User. If security is enabled and user is authenticated then other fields like userId, userName, tenantId, userRoles etc are also set, otherwise, only securityEnabled value is set.
      Returns:
      WMCurrentUser type.
    • getUserName

      public String getUserName()
      Returns the user name of the principal in the current security context. If the UserDetails obtained from authentication is an instance of WMUserDetails,then user's long name is returned from WMUserDetails, else returns the username from authentication Object. Second case happens when services like ldap are used to authenticate
      Returns:
      The user name.
    • getUserId

      public String getUserId()
      Returns the user id of the principal in the current security context, otherwise, it returns name of the authenticated user..
      Returns:
      String value, which will contain userId.
    • getUserRoles

      public String[] getUserRoles()
      If authentication is null then it returns empty String array. If not then it will retrieve the authority and process the roleName in the spring format before returning and then return.
      Returns:
      String array with roles or empty depending on authentication object.
    • getUserLandingPage

      public String getUserLandingPage()
      If authentication is null then it returns empty String array. If not then it will retrieve the authority and process the roleName in the spring format before returning and then return.
      Returns:
      String array with roles or empty depending on authentication object.
    • getLoginTime

      public long getLoginTime()
      It returns Login Time of the current user when userDetail object in current security context is not null, otherwise, it returns 0.
      Returns:
      login tine in milliseconds (long value).
    • getRoles

      public List<String> getRoles()
    • getSecurityInfo

      public SecurityInfo getSecurityInfo()
    • getAppSecurityInfo

      public SecurityInfo getAppSecurityInfo()
    • generateUserAccessToken

      public Token generateUserAccessToken()
    • ssoLogin

      public void ssoLogin()