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.StringQR_CODE_SERVICEService 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 TwoFactorAuthclientName(java.lang.String clientName)Change the client name fieldjava.lang.StringgenerateQRCode()Generates a URL of a QR code based on your client secretjava.awt.image.BufferedImagegenerateQRCodeAsImage()Generate your QR code as aBufferedImageinstead of a URLjava.awt.image.BufferedImagegenerateQRCodeAsImage(int width, int height)Generate your QR code as aBufferedImageinstead of a URL with a custom sizeTwoFactorAuthgenerateSecret()Generates the secret key used by Google Authenticator and your serverjava.lang.StringgetClientName()java.lang.StringgetLabel()java.lang.StringgetSecret()TwoFactorAuthlabel(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 SecretNoGeneratedExceptionGenerates a URL of a QR code based on your client secret- Returns:
- URL of a QR code image
- Throws:
SecretNoGeneratedException- Ifsecretdoes not exist
-
generateQRCodeAsImage
public java.awt.image.BufferedImage generateQRCodeAsImage() throws SecretNoGeneratedException, java.io.IOExceptionGenerate your QR code as aBufferedImageinstead of a URL- Returns:
- Your QR code image that can be scanned by Google Authenticator
- Throws:
SecretNoGeneratedException- Ifsecretdoes 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.IOExceptionGenerate your QR code as aBufferedImageinstead 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- Ifsecretdoes 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()
-
-