Class Ltpa2Token

java.lang.Object
de.sephirothj.spring.security.ltpa2.Ltpa2Token

public class Ltpa2Token extends Object
Represents an LTPA2-Token
Author:
Sephiroth
  • Field Details

    • USER_ATTRIBUTE_NAME

      public static final String USER_ATTRIBUTE_NAME
      the well-known name for the attribute containing the username
      See Also:
    • EXPIRE_ATTRIBUTE_NAME

      public static final String EXPIRE_ATTRIBUTE_NAME
      the well-known name for the attribute containing the expiration
      See Also:
  • Constructor Details

    • Ltpa2Token

      public Ltpa2Token()
  • Method Details

    • setExpire

      public void setExpire(@NonNull LocalDateTime expire)
      sets the expiration of the token
      Parameters:
      expire - the (new) expiration date
    • setExpire

      public void setExpire(@NonNull String expire)
      sets the expiration of the token
      Parameters:
      expire - the (new) expiration date in milliseconds since 01.01.1970T00:00:00Z
    • isExpired

      public boolean isExpired()
      checks if this token is expired
      Returns:
      whether the token is expired or not
    • setUser

      public void setUser(@NonNull String user)
      sets the user of the token
      Parameters:
      user - the (new) user DN
    • getAttribute

      @Nullable public String getAttribute(@NonNull String attribute)

      get the value of the specified attribute

      known attributes:

      • u: same as user
      • expire: expire
      • host
      • port
      • java.naming.provider.url
      • process.serverName
      • security.authMechOID
      • type
      Parameters:
      attribute - the name of the attribute
      Returns:
      attribute value. may be null
    • withAttribute

      @NonNull public Ltpa2Token withAttribute(@NonNull String attribute, @NonNull String value)
      sets an attribute
      Parameters:
      attribute - the name of the attribute
      value - attribute value
      Returns:
      this instance for chaining
    • toString

      public String toString()
      gets the token as serialized (tokenized) string
      Overrides:
      toString in class Object
      Returns:
      the serialized token
    • of

      @NonNull public static Ltpa2Token of(@NonNull String serializedToken)
      creates a new instance out of serialized (tokenized) token
      Parameters:
      serializedToken - a serialized LTPA2 token (unencrypted)
      Returns:
      new instance
      Throws:
      IllegalArgumentException - if the given token is empty