java.lang.Object
com.predic8.membrane.core.interceptor.authentication.session.NumericTokenProvider
com.predic8.membrane.core.interceptor.authentication.session.EmailTokenProvider
All Implemented Interfaces:
TokenProvider

public class EmailTokenProvider extends NumericTokenProvider
Description

The emailTokenProvider randomly generates a 6-digit token after the user entered her correct password.

The token is then sent to the user via email. The user's attribute email is used as the recipient email address. If this attribute has not been provided by the user data provider, the login attempt fails.

The email is sent using the SMTP protocol via the smtpHost. Optionally, ssl and smptPort can be set to configure the type of connection. Optionally, smtpUser and smtpPassword can be used to use sender authentification.

The email is assembled using sender, recipient, subject and body. All of these values may contain properties in the form of ${propertyname}.

The properties will be replaced by the corresponding user attributes set by the user data provider, or token will be replaced by the numeric token value.

Explanation
A token provider sending a randomly generated numeric token to the user via email.
  • Constructor Details

    • EmailTokenProvider

      public EmailTokenProvider()
  • Method Details

    • init

      public void init(Router router)
    • requestToken

      public void requestToken(Map<String,String> userAttributes)
    • isSimulate

      public boolean isSimulate()
    • setSimulate

      public void setSimulate(boolean simulate)
      Description
      don't actually send emails, if set to true
    • getRecipient

      public String getRecipient()
    • setRecipient

      public void setRecipient(String recipient)
      Description
      the recipient email address (templated)
    • getBody

      public String getBody()
    • setBody

      public void setBody(String body)
      Description
      the email body (templated)
    • getSender

      public String getSender()
    • setSender

      public void setSender(String sender)
      Description
      the sender email address (templated)
    • getSubject

      public String getSubject()
    • setSubject

      public void setSubject(String subject)
      Description
      the email subject (templated)
    • getSmtpHost

      public String getSmtpHost()
    • setSmtpHost

      public void setSmtpHost(String smtpHost)
      Description
      SMTP host
    • getSmtpUser

      public String getSmtpUser()
    • setSmtpUser

      public void setSmtpUser(String smtpUser)
      Default
      don't authenticate
      Description
      SMTP user to use for sender authentication
    • getSmtpPort

      public int getSmtpPort()
    • setSmtpPort

      public void setSmtpPort(int smtpPort)
      Default
      25
      Description
      the SMTP port to use
    • getSmtpPassword

      public String getSmtpPassword()
    • setSmtpPassword

      public void setSmtpPassword(String smtpPassword)
      Description
      the SMTP password to use for sender authentication
    • isSsl

      public boolean isSsl()
    • setSsl

      public void setSsl(boolean ssl)
      Default
      true
      Description
      whether to use SMTP over SSL