@Test public void should_generate_correct_heroku_sso_token() { String id = "123"; int timestamp = 1267597772; String token = securityService.makeHerokuSsoToken( id, timestamp, "2f97bfa52ca102f8874716e2eb1d3b4920ad0be4"); assertThat(token, is("bb466eb1d6bc345d11072c3cd25c311f21be130d")); }
@SneakyThrows(NoSuchAlgorithmException.class) String makeHerokuSsoToken(String externalId, long timestampSeconds, String salt) { MessageDigest sha1 = MessageDigest.getInstance("SHA-1"); byte[] digest = sha1.digest(String.format("%s:%s:%d", externalId, salt, timestampSeconds).getBytes()); return String.format("%x", new BigInteger(1, digest)); }
SecurityServiceImpl implements SecurityService { @SneakyThrows(NoSuchAlgorithmException.class) String makeHerokuSsoToken(String externalId, long timestampSeconds, String salt) { MessageDigest sha1 = MessageDigest.getInstance("SHA-1"); byte[] digest = sha1.digest(String.format("%s:%s:%d", externalId, salt, timestampSeconds).getBytes()); return String.format("%x", new BigInteger(1, digest)); } }
SecurityServiceImpl implements SecurityService { @SneakyThrows(NoSuchAlgorithmException.class) String makeHerokuSsoToken(String externalId, long timestampSeconds, String salt) { MessageDigest sha1 = MessageDigest.getInstance("SHA-1"); byte[] digest = sha1.digest(String.format("%s:%s:%d", externalId, salt, timestampSeconds).getBytes()); return String.format("%x", new BigInteger(1, digest)); }  }
SecurityServiceImpl implements SecurityService { @SneakyThrows(NoSuchAlgorithmException.class) String makeHerokuSsoToken(String externalId, long timestampSeconds, String salt) { MessageDigest sha1 = MessageDigest.getInstance("SHA-1"); byte[] digest = sha1.digest(String.format("%s:%s:%d", externalId, salt, timestampSeconds).getBytes()); return String.format("%x", new BigInteger(1, digest)); }  @PostConstruct void postConstruct(); @Override Long getCustomerId(); @Override void authenticateToken(String token); @Override void removeAuthentication(); @Override @Transactional String createCodeForWebappToken(Long customerId, WebappCredentials credentials); @Override @Transactional String tradeCodeToWebappToken(String code); @Scheduled(initialDelay = 60_000L, fixedRate = 600_000L) @Transactional @Override void removeExpiredTokenCodes(); @Override @Transactional String doHerokuSingleSignOn(
      String token, String externalId, String email, long timestampSeconds, String salt); }
SecurityServiceImpl implements SecurityService { @SneakyThrows(NoSuchAlgorithmException.class) String makeHerokuSsoToken(String externalId, long timestampSeconds, String salt) { MessageDigest sha1 = MessageDigest.getInstance("SHA-1"); byte[] digest = sha1.digest(String.format("%s:%s:%d", externalId, salt, timestampSeconds).getBytes()); return String.format("%x", new BigInteger(1, digest)); }  @PostConstruct void postConstruct(); @Override Long getCustomerId(); @Override void authenticateToken(String token); @Override void removeAuthentication(); @Override @Transactional String createCodeForWebappToken(Long customerId, WebappCredentials credentials); @Override @Transactional String tradeCodeToWebappToken(String code); @Scheduled(initialDelay = 60_000L, fixedRate = 600_000L) @Transactional @Override void removeExpiredTokenCodes(); @Override @Transactional String doHerokuSingleSignOn(
      String token, String externalId, String email, long timestampSeconds, String salt);  }