return new TokenTask<String>() {
@Override
protected String execute() {
String tokenId = nextTokenId();
long expirationTimeMillis = System.currentTimeMillis() + validityMillis;
GateInToken token = new GateInToken(expirationTimeMillis, credentials);
TokenContainer container = getTokenContainer();
// Save the token, password is encoded thanks to the codec
container.encodeAndSaveToken(tokenId, token.getPayload(), new Date(expirationTimeMillis), codec);
return tokenId;
}
}.executeWith(chromatticLifeCycle);
}