Package com.avoka.fc.core.service.impl
Class GoogleTwoFactorAuthenticationService
- java.lang.Object
-
- com.avoka.fc.core.service.BaseService
-
- com.avoka.fc.core.service.CayenneService
-
- com.avoka.fc.core.service.impl.GoogleTwoFactorAuthenticationService
-
- All Implemented Interfaces:
IServiceDefinitionAware
,ITwoFactorAuthenticationService
public class GoogleTwoFactorAuthenticationService extends CayenneService implements ITwoFactorAuthenticationService, IServiceDefinitionAware
Provides a service verifying a Google Authenticator token.- Since:
- 4.2.0
-
-
Field Summary
-
Fields inherited from interface com.avoka.fc.core.service.ITwoFactorAuthenticationService
PROPERTY_END_OF_GRACE_PERIOD
-
-
Constructor Summary
Constructors Constructor Description GoogleTwoFactorAuthenticationService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Date
getEndOfGracePeriod()
Return the date after which users can no longer log on without providing a correct token.String
getIssuer()
Return the issuer string identifying the organization that users are setting up Google Authenticator accounts with.ServiceDefinition
getServiceDefinition()
Return the service definition for the service.boolean
isInGracePeriod()
Return whether users can currently log on without providing a token prior to having enrolled.boolean
isValid(Object securityToken, UserAccount userAccount, HttpServletRequest request)
Checks additional authentication factors (not including the password) for a user.void
sendEnrolmentEmail(UserAccount userAccount, Portal portal)
Send an email with enrolment instructions to the given user.void
sendResetEmail(UserAccount userAccount, Portal portal)
Send an email with instructions on how to apply a new key to the given user.void
setEndOfGracePeriod(Date endOfGracePeriod)
Set the date after which users can no longer log on without providing a correct token.void
setIssuer(String issuer)
Set the issuer string identifying the organization that users are setting up Google Authenticator accounts with.void
setServiceDefinition(ServiceDefinition serviceDefinition)
Set the service definition for the service.-
Methods inherited from class com.avoka.fc.core.service.CayenneService
commitChanges, deleteObject, deleteObjects, findObject, getDataContext, getDataDomain, getObjectForPK, getObjectStore, newObject, performNamedQuery, performNamedQuery, performNamedQuery, performNonSelectingQuery, performNonSelectingQuery, performNonSelectingQuery, performNonSelectingQuery, performQuery, performQuery, refetchEntity, refetchObject, registerNewObject, rollbackChanges, toMap, toMap
-
Methods inherited from class com.avoka.fc.core.service.BaseService
getLogger
-
-
-
-
Method Detail
-
isValid
public boolean isValid(Object securityToken, UserAccount userAccount, HttpServletRequest request)
Checks additional authentication factors (not including the password) for a user.- Specified by:
isValid
in interfaceITwoFactorAuthenticationService
- Parameters:
securityToken
- the one-time password produced by Google Authenticator, provided as a StringuserAccount
- the user accountrequest
- the HTTP servlet request- Returns:
- true if the additional authentication factors were verified successfully, false otherwise
-
sendEnrolmentEmail
public void sendEnrolmentEmail(UserAccount userAccount, Portal portal)
Send an email with enrolment instructions to the given user.- Specified by:
sendEnrolmentEmail
in interfaceITwoFactorAuthenticationService
- Parameters:
userAccount
- the user to enrol (required)portal
- the portal (required)
-
sendResetEmail
public void sendResetEmail(UserAccount userAccount, Portal portal)
Send an email with instructions on how to apply a new key to the given user.- Specified by:
sendResetEmail
in interfaceITwoFactorAuthenticationService
- Parameters:
userAccount
- the user (required)portal
- the portal (required)
-
getEndOfGracePeriod
public Date getEndOfGracePeriod()
Return the date after which users can no longer log on without providing a correct token. If not set, no grace period is being used.- Specified by:
getEndOfGracePeriod
in interfaceITwoFactorAuthenticationService
- Returns:
- the end of the grace period
-
setEndOfGracePeriod
public void setEndOfGracePeriod(Date endOfGracePeriod)
Set the date after which users can no longer log on without providing a correct token. If set to null or a date in the past, no grace period is being used.- Parameters:
endOfGracePeriod
- the end 0f the grace period
-
isInGracePeriod
public boolean isInGracePeriod()
Return whether users can currently log on without providing a token prior to having enrolled.- Specified by:
isInGracePeriod
in interfaceITwoFactorAuthenticationService
- Returns:
- whether a grace period is currently active
-
getIssuer
public String getIssuer()
Return the issuer string identifying the organization that users are setting up Google Authenticator accounts with.- Returns:
- the issuer string
-
setIssuer
public void setIssuer(String issuer)
Set the issuer string identifying the organization that users are setting up Google Authenticator accounts with.- Parameters:
issuer
- the new issuer string
-
getServiceDefinition
public ServiceDefinition getServiceDefinition()
Return the service definition for the service.- Specified by:
getServiceDefinition
in interfaceIServiceDefinitionAware
- Returns:
- the service definition for the service.
- See Also:
IServiceDefinitionAware#gsetServiceDefinition()
-
setServiceDefinition
public void setServiceDefinition(ServiceDefinition serviceDefinition)
Set the service definition for the service.- Specified by:
setServiceDefinition
in interfaceIServiceDefinitionAware
- Parameters:
serviceDefinition
- the service definition for the service.- See Also:
IServiceDefinitionAware.setServiceDefinition(ServiceDefinition)
-
-