Signer { public <T extends Rfc7519Claims> String sign(T claims) throws GeneralSecurityException { return sign(claims, null); } Signer(byte[] secret);  Signer(byte[] secret, Gson gson); String sign(T claims); String sign(T claims, Algorithm algorithm);  }
@Test public void testEmptyClaims() throws Exception { Signer signer = new Signer("secret".getBytes()); Rfc7519Claims claims = new Rfc7519Claims(); String jwt = signer.sign(claims); assertEquals( "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.e30.DMCAvRgzrcf5w0Z879BsqzcrnDFKBY_GN6c3qKOUFtQ", jwt); }
@Test public void testRfc7515A1() throws Throwable { Rfc7515A1Claims.Builder builder = new Rfc7515A1Claims.Builder(); builder.setIssuer("joe"); builder.setExpirationTime(new Long(1300819380)); builder.setIsRoot(true); Rfc7519Claims claims = builder.getResult(); Signer signer = new Rfc7515A1Signer(rfc7515A1key); assertEquals(rfc7515A1jwt, signer.sign(claims)); }