Package net.maploop.api
Class TwoFactorAuth
- java.lang.Object
-
- net.maploop.api.TwoFactorAuth
-
public class TwoFactorAuth extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
QR_CODE_SERVICE
Service used to display QR code images
-
Constructor Summary
Constructors Constructor Description TwoFactorAuth(java.lang.String clientName)
Generate a new 2FA QR code, can be used with Google Authenticator
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TwoFactorAuth
clientName(java.lang.String clientName)
Change the client name fieldjava.lang.String
generateQRCode()
Generates a URL of a QR code based on your client secretjava.awt.image.BufferedImage
generateQRCodeAsImage()
Generate your QR code as aBufferedImage
instead of a URLjava.awt.image.BufferedImage
generateQRCodeAsImage(int width, int height)
Generate your QR code as aBufferedImage
instead of a URL with a custom sizeTwoFactorAuth
generateSecret()
Generates the secret key used by Google Authenticator and your serverjava.lang.String
getClientName()
java.lang.String
getLabel()
java.lang.String
getSecret()
TwoFactorAuth
label(java.lang.String label)
Change the label displayed as the user's username in Google Authenticator
-
-
-
Field Detail
-
QR_CODE_SERVICE
public static final java.lang.String QR_CODE_SERVICE
Service used to display QR code images- See Also:
- Constant Field Values
-
-
Method Detail
-
generateQRCode
public java.lang.String generateQRCode() throws SecretNoGeneratedException
Generates a URL of a QR code based on your client secret- Returns:
- URL of a QR code image
- Throws:
SecretNoGeneratedException
- Ifsecret
does not exist
-
generateQRCodeAsImage
public java.awt.image.BufferedImage generateQRCodeAsImage() throws SecretNoGeneratedException, java.io.IOException
Generate your QR code as aBufferedImage
instead of a URL- Returns:
- Your QR code image that can be scanned by Google Authenticator
- Throws:
SecretNoGeneratedException
- Ifsecret
does not existjava.io.IOException
- If the API fails to generate the image from the URL
-
generateQRCodeAsImage
public java.awt.image.BufferedImage generateQRCodeAsImage(int width, int height) throws SecretNoGeneratedException, java.io.IOException
Generate your QR code as aBufferedImage
instead of a URL with a custom size- Parameters:
width
- Custom width of the imageheight
- Custom height of the image- Returns:
- Your QR code image that can be scanned by Google Authenticator
- Throws:
SecretNoGeneratedException
- Ifsecret
does not existjava.io.IOException
- If the API fails to generate the image from the URL
-
generateSecret
public TwoFactorAuth generateSecret()
Generates the secret key used by Google Authenticator and your server- Returns:
- Instance of this class
-
label
public TwoFactorAuth label(java.lang.String label)
Change the label displayed as the user's username in Google Authenticator- Parameters:
label
- New value of the label- Returns:
- Instance of this class
-
clientName
public TwoFactorAuth clientName(java.lang.String clientName)
Change the client name field- Parameters:
clientName
- New value of client name- Returns:
- Instance of this class
-
getClientName
public java.lang.String getClientName()
-
getLabel
public java.lang.String getLabel()
-
getSecret
public java.lang.String getSecret()
-
-