Package org.cyclos.services.access
Interface TokenService
-
- All Superinterfaces:
CRUDService<TokenDTO,TokenData,TokenDataParams>,Service
- All Known Subinterfaces:
TokenServiceLocal
- All Known Implementing Classes:
TokenServiceImpl,TokenServiceSecurity
public interface TokenService extends CRUDService<TokenDTO,TokenData,TokenDataParams>
Service for managing tokens, NFC tokens and NFC devices
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Longactivate(@NotNull TokenActionDTO dto, UserLocatorVO locator)Searches for a token with the given type and value specified in theTokenActionDTOparameter.
The token's status must beTokenStatus.UNASSIGNEDorTokenStatus.PENDING_ACTIVATIONbut assigned to the logged user or one of its operators.
If the token is unassigned then this method assigns it to the user specified by theUserLocatorVOparameter and change its status toTokenStatus.ACTIVE.
Otherwise (the token is already assigned and is pending by activation) it activates only.
This method can be used only by members (i.e.voidactivatePending(@NotNull Long tokenId)Activates an already assigned token with statusTokenStatus.PENDING_ACTIVATION.
This operation can only be done by admins/brokers over tokens of managed users or member over tokens of its operators with permission to activate the correspondingTokenPrincipalTypeVO.voidassign(@NotNull Long tokenId, @NotNull UserLocatorVO user)Assigns a pending token to a user, leaving it in pending status The token status must beTokenStatus.UNASSIGNED.SerializableInputStreambarcode(@NotNull TokenBarcodeParams params)Returns a barcode image of the tokenvoidblock(@NotNull Long tokenId)Blocks the given tokenvoidcancel(@NotNull Long tokenId)Cancels the given tokenvoidcancelNFCToken(@NotNull TokenActionDTO dto)Cancels the given NFC token.DeviceConfirmationVOcreateDeviceConfirmationForPersonalizeNFCTag(@NotNull UserLocatorVO locator, @NotNull TokenPrincipalTypeVO tokenTypeVO)Creates a new pending device confirmation for the specified user.SerializableInputStreamdeviceConfirmationBarcodeForPersonalizeNFCTag(UserLocatorVO locator, @NotNull TokenPrincipalTypeVO tokenTypeVO, DeviceConfirmationBarcodeParams params)Generates a two-dimensional barcode (QR code), only if the confirmation was not already approved nor rejected for the given payer.FileInfoexportTokens(@NotNull ExportFormatVO format, @NotNull TokenQuery query)Exports the token search results to fileInitializeNFCTagDatagetInitializeNFCTagData()Returns data with the token types available to initialize a blank NFC tag.
The available tokens to personalize the tag are returned too to allow initialization and personalization at the same time.TokensListDatagetListData(@NotNull TokenPrincipalTypeVO tokenType, @NotNull UserLocatorVO user)Returns data for listing tokens of a given type and userPersonalizeNFCTagDatagetPersonalizeNFCTagData(@NotNull TokenPrincipalTypeVO tokenType, @NotNull UserLocatorVO locator)Returns data needed to personalize a NFC tag for the specified type and user.
ThePersonalizeNFCTagData.CONFIRMATION_PASSWORD_INPUTwill be null if the logged user manages the given user.TokenSearchDatagetSearchData(TokenPrincipalTypeVO tokenType)Returns data for searching tokensInitializeNFCTagResultinitializeNFCTag(@NotNull NFCTagInitializeDTO dto)Initializes and optionally personalize a NFC tag with the given data.voidpersonalizeNFCTag(@NotNull NFCTagPersonalizeDTO dto)Personalizes a NFC tag for the given user.voidremoveDeviceConfirmationForPersonalizeNFCTag(@NotNull UserLocatorVO locator, @NotNull TokenPrincipalTypeVO tokenTypeVO, String deviceConfirmationId)Removes a device confirmation for the given user.ExternalNFCTagAuthenticateDatarequestForExternalAuthenticate(@NotNull ExternalNFCTagAuthenticateDTO dto)This method must be invoked to start a mutual authentication process between the server and the NFC tag (e.g.voidrequestNewOTPForPersonalizeNFCTag(@NotNull UserLocatorVO locator, @NotNull TokenPrincipalTypeVO tokenTypeVO, @NotNull SendMedium medium)Generates a new OTP (removing any previous password, if any) and sends it to the user by the specified medium using the confirmation password type set for theBuiltInChannel.POSchannel for the specified user.
It has the same security controls as forpersonalizeNFCTag(NFCTagPersonalizeDTO), that is the logged user must be allowed to personalize a NFC Tag for the specified user.Page<TokenVO>search(@NotNull TokenQuery query)Searches for tokens.voidsetActivationDeadline(@NotNull Long tokenId, DateTime date)Changes the token activation deadline date.voidsetExpiryDate(@NotNull Long tokenId, DateTime date)Changes the token expiry date.voidunblock(@NotNull Long tokenId)Unblocks the given tokenDeviceConfirmationVOviewDeviceConfirmationForPersonalizeNFCTag(@NotNull UserLocatorVO locator, @NotNull TokenPrincipalTypeVO tokenTypeVO, String deviceConfirmationId)Loads the details of a confirmation belonging to the given user.-
Methods inherited from interface org.cyclos.services.CRUDService
getData, getDataForNew, load, remove, removeAll, save
-
-
-
-
Method Detail
-
activate
Long activate(@NotNull @NotNull TokenActionDTO dto, UserLocatorVO locator) throws FrameworkException, MaxTokenActivationAttemptsException, InvalidTokenException
Searches for a token with the given type and value specified in theTokenActionDTOparameter.
The token's status must beTokenStatus.UNASSIGNEDorTokenStatus.PENDING_ACTIVATIONbut assigned to the logged user or one of its operators.
If the token is unassigned then this method assigns it to the user specified by theUserLocatorVOparameter and change its status toTokenStatus.ACTIVE.
Otherwise (the token is already assigned and is pending by activation) it activates only.
This method can be used only by members (i.e. not administrators) with permission to activate the correspondingTokenPrincipalTypeVO. For administrators / brokers, seeactivatePending(Long)
-
activatePending
void activatePending(@NotNull @NotNull Long tokenId) throws FrameworkExceptionActivates an already assigned token with statusTokenStatus.PENDING_ACTIVATION.
This operation can only be done by admins/brokers over tokens of managed users or member over tokens of its operators with permission to activate the correspondingTokenPrincipalTypeVO.- Throws:
FrameworkException
-
assign
void assign(@NotNull @NotNull Long tokenId, @NotNull @NotNull UserLocatorVO user) throws FrameworkExceptionAssigns a pending token to a user, leaving it in pending status The token status must beTokenStatus.UNASSIGNED.- Throws:
FrameworkException
-
barcode
SerializableInputStream barcode(@NotNull @NotNull TokenBarcodeParams params) throws FrameworkException
Returns a barcode image of the token- Throws:
FrameworkException
-
block
void block(@NotNull @NotNull Long tokenId) throws FrameworkExceptionBlocks the given token- Throws:
FrameworkException
-
cancel
void cancel(@NotNull @NotNull Long tokenId) throws FrameworkExceptionCancels the given token- Throws:
FrameworkException
-
cancelNFCToken
void cancelNFCToken(@NotNull @NotNull TokenActionDTO dto) throws FrameworkExceptionCancels the given NFC token. Admins and brokers with permissions can cancel a NFC token of typeTokenType.NFC_TAG.
In case of a NFC token of typeTokenType.NFC_DEVICEonly the logged user can cancel its own token.- Throws:
FrameworkException
-
createDeviceConfirmationForPersonalizeNFCTag
DeviceConfirmationVO createDeviceConfirmationForPersonalizeNFCTag(@NotNull @NotNull UserLocatorVO locator, @NotNull @NotNull TokenPrincipalTypeVO tokenTypeVO) throws FrameworkException
Creates a new pending device confirmation for the specified user. The logged user will be notified after the confirmation was processed. It has the same security controls as forpersonalizeNFCTag(NFCTagPersonalizeDTO), that is the logged user must be allowed to personalize a NFC Tag for the specified user.- Parameters:
tokenTypeVO- the principal type used to personalize the card- Throws:
FrameworkException
-
deviceConfirmationBarcodeForPersonalizeNFCTag
SerializableInputStream deviceConfirmationBarcodeForPersonalizeNFCTag(UserLocatorVO locator, @NotNull @NotNull TokenPrincipalTypeVO tokenTypeVO, DeviceConfirmationBarcodeParams params) throws FrameworkException
Generates a two-dimensional barcode (QR code), only if the confirmation was not already approved nor rejected for the given payer. It has the same security controls as forpersonalizeNFCTag(NFCTagPersonalizeDTO), that is the logged user must be allowed to personalize a NFC Tag for the specified user.- Parameters:
tokenTypeVO- the principal type used to personalize the card- Throws:
FrameworkException
-
exportTokens
FileInfo exportTokens(@NotNull @NotNull ExportFormatVO format, @NotNull @NotNull TokenQuery query) throws FrameworkException
Exports the token search results to file- Throws:
FrameworkException
-
getInitializeNFCTagData
InitializeNFCTagData getInitializeNFCTagData() throws FrameworkException
Returns data with the token types available to initialize a blank NFC tag.
The available tokens to personalize the tag are returned too to allow initialization and personalization at the same time. Only allowed for managers (Brokers & Administrators).- Throws:
FrameworkException- See Also:
initializeNFCTag(NFCTagInitializeDTO)
-
getListData
TokensListData getListData(@NotNull @NotNull TokenPrincipalTypeVO tokenType, @NotNull @NotNull UserLocatorVO user) throws FrameworkException
Returns data for listing tokens of a given type and user- Throws:
FrameworkException
-
getPersonalizeNFCTagData
PersonalizeNFCTagData getPersonalizeNFCTagData(@NotNull @NotNull TokenPrincipalTypeVO tokenType, @NotNull @NotNull UserLocatorVO locator) throws FrameworkException
Returns data needed to personalize a NFC tag for the specified type and user.
ThePersonalizeNFCTagData.CONFIRMATION_PASSWORD_INPUTwill be null if the logged user manages the given user. ThePersonalizeNFCTagData.TOKEN_TYPEis the token principal type the tag was initialized for.- Throws:
FrameworkException
-
getSearchData
TokenSearchData getSearchData(TokenPrincipalTypeVO tokenType) throws FrameworkException
Returns data for searching tokens- Throws:
FrameworkException
-
initializeNFCTag
InitializeNFCTagResult initializeNFCTag(@NotNull @NotNull NFCTagInitializeDTO dto) throws FrameworkException, TokenAlreadyInUseException
Initializes and optionally personalize a NFC tag with the given data. If theTokenActionWithUserDTO.getUser()is not null then the token will be personalized for that user too. Returns the private keys (PICC Master Key (i.e. PMK), Application Master Key (i.e. AMK) and Operational key) to be stored into the tag.
Only allowed for managers (Brokers & Administrators).
-
personalizeNFCTag
void personalizeNFCTag(@NotNull @NotNull NFCTagPersonalizeDTO dto) throws FrameworkException, TokenAlreadyInUseExceptionPersonalizes a NFC tag for the given user. If the logged user doesn't manages the user then the confirmation password of that user is required. This method requires a successful previous external authentication (requestForExternalAuthenticate(ExternalNFCTagAuthenticateDTO))
The requiredNFCTagPersonalizeDTO.CYCLOS_CHALLENGEis the encrypted (hexadecimal string) challenge generated by the server (returned in the previous external authenticate) used to ensure the tag presence (internal authenticate)
-
removeDeviceConfirmationForPersonalizeNFCTag
void removeDeviceConfirmationForPersonalizeNFCTag(@NotNull @NotNull UserLocatorVO locator, @NotNull @NotNull TokenPrincipalTypeVO tokenTypeVO, String deviceConfirmationId) throws FrameworkExceptionRemoves a device confirmation for the given user. It has the same security controls as forpersonalizeNFCTag(NFCTagPersonalizeDTO), that is the logged user must be allowed to personalize a NFC Tag for the specified user.- Parameters:
tokenTypeVO- the principal type used to personalize the card- Throws:
FrameworkException
-
requestForExternalAuthenticate
ExternalNFCTagAuthenticateData requestForExternalAuthenticate(@NotNull @NotNull ExternalNFCTagAuthenticateDTO dto) throws FrameworkException
This method must be invoked to start a mutual authentication process between the server and the NFC tag (e.g. a card) to prove that both share the same secret key.
The authentication process is carried out in the following order:- Validate the identity of the server: external authenticate
- Validate the identity of the NFc tag: internal authenticate
- Parameters:
dto- contains the token type id (required), the token value (optional) and an encrypted challenge (required) generated by the tag in hexadecimal notation. If the token value is null then means the authentication process will be using the PICC Master Key (PMK).- Returns:
- data containing the following:
ExternalNFCTagAuthenticateData.CYCLOS_CHALLENGE: encrypted data (hexadecimal string) containing both: a new challenge generated by the server (used to validate the identity of the NFC tag, internal authenticate) and the original challenge generated by the tag processed according to the tag's authentication process. The (processed) original tag challenge will be used by the NFC tag to complete the server identity validation (external authenticate).ExternalNFCTagAuthenticateData.SESSION_KEY: A session key needed by the tag to allow send enciphered data to be written into the NFC tag
- Throws:
FrameworkException
-
requestNewOTPForPersonalizeNFCTag
void requestNewOTPForPersonalizeNFCTag(@NotNull @NotNull UserLocatorVO locator, @NotNull @NotNull TokenPrincipalTypeVO tokenTypeVO, @NotNull @NotNull SendMedium medium) throws FrameworkException, SmsSendingExceptionGenerates a new OTP (removing any previous password, if any) and sends it to the user by the specified medium using the confirmation password type set for theBuiltInChannel.POSchannel for the specified user.
It has the same security controls as forpersonalizeNFCTag(NFCTagPersonalizeDTO), that is the logged user must be allowed to personalize a NFC Tag for the specified user.- Parameters:
tokenTypeVO- the principal type used to personalize the cardmedium- the medium used to send the OTP.- Throws:
SmsSendingException- only if medium isSendMedium.SMSand the OTP could not be sent to any enabled for sms phone.FrameworkException
-
search
Page<TokenVO> search(@NotNull @NotNull TokenQuery query) throws FrameworkException, QueryParseException
Searches for tokens. This method can only be user by administrators or brokers.
-
setActivationDeadline
void setActivationDeadline(@NotNull @NotNull Long tokenId, DateTime date) throws FrameworkExceptionChanges the token activation deadline date. The token status must be eitherTokenStatus.PENDING_ACTIVATIONorTokenStatus.ACTIVATION_EXPIRED.- Throws:
FrameworkException
-
setExpiryDate
void setExpiryDate(@NotNull @NotNull Long tokenId, DateTime date) throws FrameworkExceptionChanges the token expiry date. The token status must be eitherTokenStatus.ACTIVE,TokenStatus.BLOCKEDorTokenStatus.EXPIRED.- Throws:
FrameworkException
-
unblock
void unblock(@NotNull @NotNull Long tokenId) throws FrameworkExceptionUnblocks the given token- Throws:
FrameworkException
-
viewDeviceConfirmationForPersonalizeNFCTag
DeviceConfirmationVO viewDeviceConfirmationForPersonalizeNFCTag(@NotNull @NotNull UserLocatorVO locator, @NotNull @NotNull TokenPrincipalTypeVO tokenTypeVO, String deviceConfirmationId) throws FrameworkException
Loads the details of a confirmation belonging to the given user. It has the same security controls as forpersonalizeNFCTag(NFCTagPersonalizeDTO), that is the logged user must be allowed to personalize a NFC Tag for the specified user.- Parameters:
tokenTypeVO- the principal type used to personalize the card- Throws:
FrameworkException
-
-