@Test public void generateAttachmentAccessTokenShouldThrowWhenUsernameIsNull() throws Exception { assertThatThrownBy(() -> toKenFactory.generateAttachmentAccessToken(null, "blobId")) .isInstanceOf(NullPointerException.class); }
@Override public AttachmentAccessToken generateAttachmentAccessToken(String username, String blobId) { Preconditions.checkArgument(! Strings.isNullOrEmpty(blobId)); ZonedDateTime expirationTime = zonedDateTimeProvider.get().plusMinutes(5); return AttachmentAccessToken.builder() .username(username) .blobId(blobId) .expirationDate(expirationTime) .signature(signatureHandler.sign(Joiner.on(AttachmentAccessToken.SEPARATOR) .join(blobId, username, DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(expirationTime)))) .build(); }
SignedTokenFactory implements SimpleTokenFactory { @Override public AttachmentAccessToken generateAttachmentAccessToken(String username, String blobId) { Preconditions.checkArgument(! Strings.isNullOrEmpty(blobId)); ZonedDateTime expirationTime = zonedDateTimeProvider.get().plusMinutes(5); return AttachmentAccessToken.builder() .username(username) .blobId(blobId) .expirationDate(expirationTime) .signature(signatureHandler.sign(Joiner.on(AttachmentAccessToken.SEPARATOR) .join(blobId, username, DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(expirationTime)))) .build(); } }
SignedTokenFactory implements SimpleTokenFactory { @Override public AttachmentAccessToken generateAttachmentAccessToken(String username, String blobId) { Preconditions.checkArgument(! Strings.isNullOrEmpty(blobId)); ZonedDateTime expirationTime = zonedDateTimeProvider.get().plusMinutes(5); return AttachmentAccessToken.builder() .username(username) .blobId(blobId) .expirationDate(expirationTime) .signature(signatureHandler.sign(Joiner.on(AttachmentAccessToken.SEPARATOR) .join(blobId, username, DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(expirationTime)))) .build(); } @Inject  SignedTokenFactory(SignatureHandler signatureHandler, ZonedDateTimeProvider zonedDateTimeProvider); }
SignedTokenFactory implements SimpleTokenFactory { @Override public AttachmentAccessToken generateAttachmentAccessToken(String username, String blobId) { Preconditions.checkArgument(! Strings.isNullOrEmpty(blobId)); ZonedDateTime expirationTime = zonedDateTimeProvider.get().plusMinutes(5); return AttachmentAccessToken.builder() .username(username) .blobId(blobId) .expirationDate(expirationTime) .signature(signatureHandler.sign(Joiner.on(AttachmentAccessToken.SEPARATOR) .join(blobId, username, DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(expirationTime)))) .build(); } @Inject  SignedTokenFactory(SignatureHandler signatureHandler, ZonedDateTimeProvider zonedDateTimeProvider); @Override ContinuationToken generateContinuationToken(String username); @Override AttachmentAccessToken generateAttachmentAccessToken(String username, String blobId); }
SignedTokenFactory implements SimpleTokenFactory { @Override public AttachmentAccessToken generateAttachmentAccessToken(String username, String blobId) { Preconditions.checkArgument(! Strings.isNullOrEmpty(blobId)); ZonedDateTime expirationTime = zonedDateTimeProvider.get().plusMinutes(5); return AttachmentAccessToken.builder() .username(username) .blobId(blobId) .expirationDate(expirationTime) .signature(signatureHandler.sign(Joiner.on(AttachmentAccessToken.SEPARATOR) .join(blobId, username, DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(expirationTime)))) .build(); } @Inject  SignedTokenFactory(SignatureHandler signatureHandler, ZonedDateTimeProvider zonedDateTimeProvider); @Override ContinuationToken generateContinuationToken(String username); @Override AttachmentAccessToken generateAttachmentAccessToken(String username, String blobId);  }