Package org.cyclos.impl.system
Class CaptchaServiceImpl
- java.lang.Object
-
- org.cyclos.impl.AbstractServerComponent
-
- org.cyclos.impl.AbstractNetworkedServerComponent
-
- org.cyclos.impl.BaseServiceImpl
-
- org.cyclos.impl.system.CaptchaServiceImpl
-
- All Implemented Interfaces:
CaptchaServiceLocal,Service,CaptchaService
@Service public class CaptchaServiceImpl extends BaseServiceImpl implements CaptchaServiceLocal
Implementation forCaptchaService
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCaptchaServiceImpl.RecaptchaResponse
-
Field Summary
-
Fields inherited from class org.cyclos.impl.AbstractNetworkedServerComponent
authHandler, conversionHandler, customFieldValueHandler, entityManagerHandler, groupsHandler, productsHandler, restBeanPropertyMapping, userLocatorHandler
-
Fields inherited from class org.cyclos.impl.AbstractServerComponent
accountHandler, configurationHandler, dataTranslationHandler, notificationHandler, profileFieldHandler, transactionHandler, translationHandler
-
-
Constructor Summary
Constructors Constructor Description CaptchaServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringgenerate(String previousChallenge)Generates a new internal captcha challenge, returning it's identifierStringgetText(String id)Returns the text for the internal captcha challenge with the given identifiervoidinitialize()booleanisValid(String id, String text)Returns whether the given internal captcha challenge is validSerializableInputStreamreadImage(String id, BasicGroupVO basicGroupVO, DimensionsDTO dimensions)Returns the image which corresponds to the given internal captcha id and using the background defined for the specified groupprotected voidregisterNetworkMappings(NetworkPathRegistry networkPathRegistry)Needs to be overridden by subclasses to register the path up to the networkvoidremove(String id)Removes the given internal captcha challenge with the given idvoidremoveInternalCaptcha(CaptchaConfiguration configuration, CaptchaResponseDTO response)Removes the captcha only if provider isCaptchaProvider.INTERNALand the response is not null.
Otherwise it's a no-op.booleanverify(CaptchaConfiguration configuration, CaptchaResponseDTO captcha)Returns whether the given captcha response and challenge are correct.-
Methods inherited from class org.cyclos.impl.BaseServiceImpl
initializeNetworkMappings
-
Methods inherited from class org.cyclos.impl.AbstractNetworkedServerComponent
canManage, checkManagesUser, checkPermission, checkRelatesToUser, checkValue, clearAlreadyValidated, getBaseEntityManagerHandler, getConfiguration, getLoggedBasicUser, getLoggedUser, getProducts, getTranslatedName, getTranslatedValue, hasPermission, hasValue, inSameNetwork, inSameNetworkOrGlobal, isAdmin, isAlreadyValidated, isBroker, isGlobalAdmin, isGlobalAdminInNetwork, isGuest, isLoggedIn, isMember, isMemberOnly, isNetworkAdmin, isOperator, isRelatedToUser, isSystem, isUserManager, isUserManagerOf, message, message, permission, permission, permissionOptionalValue, permissionOptionalValue, setAlreadyValidated, toDate, toDateTime, validate
-
Methods inherited from class org.cyclos.impl.AbstractServerComponent
dataTranslationProxy, dataTranslationProxy, delete, detach, doDataTranslationProxy, find, flush, from, getApplicationContext, getFormatter, getFormatter, getFormatter, getLogger, getRemoteAddress, getSessionData, mailContentBuilder, message, message, persist, processBatch, processBatch, refresh, remove, selectFrom, subQuery, update
-
-
-
-
Method Detail
-
generate
public String generate(String previousChallenge) throws FrameworkException
Description copied from interface:CaptchaServiceGenerates a new internal captcha challenge, returning it's identifier- Specified by:
generatein interfaceCaptchaService- Throws:
FrameworkException
-
getText
public String getText(String id) throws FrameworkException
Description copied from interface:CaptchaServiceLocalReturns the text for the internal captcha challenge with the given identifier- Specified by:
getTextin interfaceCaptchaServiceLocal- Throws:
FrameworkException
-
initialize
@PostConstruct public void initialize()
-
isValid
public boolean isValid(String id, String text) throws FrameworkException
Description copied from interface:CaptchaServiceReturns whether the given internal captcha challenge is valid- Specified by:
isValidin interfaceCaptchaService- Throws:
FrameworkException
-
readImage
public SerializableInputStream readImage(String id, BasicGroupVO basicGroupVO, DimensionsDTO dimensions) throws FrameworkException
Description copied from interface:CaptchaServiceReturns the image which corresponds to the given internal captcha id and using the background defined for the specified group- Specified by:
readImagein interfaceCaptchaService- Throws:
FrameworkException
-
remove
public void remove(String id) throws FrameworkException
Description copied from interface:CaptchaServiceRemoves the given internal captcha challenge with the given id- Specified by:
removein interfaceCaptchaService- Throws:
FrameworkException
-
removeInternalCaptcha
public void removeInternalCaptcha(CaptchaConfiguration configuration, CaptchaResponseDTO response)
Description copied from interface:CaptchaServiceLocalRemoves the captcha only if provider isCaptchaProvider.INTERNALand the response is not null.
Otherwise it's a no-op.- Specified by:
removeInternalCaptchain interfaceCaptchaServiceLocal
-
verify
public boolean verify(CaptchaConfiguration configuration, CaptchaResponseDTO captcha)
Description copied from interface:CaptchaServiceLocalReturns whether the given captcha response and challenge are correct. Clients should assume that this can be called only once per challenge.
Internal captchas are only removed when the user is registered, the forgot password OTP is sent or the voucher PIN is resend. See usages of
CaptchaServiceLocal.removeInternalCaptcha(CaptchaConfiguration, CaptchaResponseDTO)for such cases. However, with reCAPTCHA we can only check each challenge once.- Specified by:
verifyin interfaceCaptchaServiceLocal
-
registerNetworkMappings
protected void registerNetworkMappings(NetworkPathRegistry networkPathRegistry)
Description copied from class:BaseServiceImplNeeds to be overridden by subclasses to register the path up to the network- Specified by:
registerNetworkMappingsin classBaseServiceImpl
-
-