@Test public void generateToken_byIdentity_nullIdentity() throws CryptoException { Jwt jwt = this.generator.generateToken(null); assertNotNull(jwt); assertNull(jwt.getIdentity()); assertTrue(signer.verifyTokenSignature(jwt.getSignatureData(), ConvertionUtils.toBytes(jwt.unsigned()), fake.getApiPublicKey())); }
public Jwt generateToken(String identity) throws CryptoException { JwtHeaderContent jwtHeaderContent = new JwtHeaderContent(apiPublicKeyIdentifier); JwtBodyContent jwtBodyContent = new JwtBodyContent(appId, identity, ttl, new Date()); Jwt jwtToken = new Jwt(jwtHeaderContent, jwtBodyContent); byte[] signature = this.accessTokenSigner .generateTokenSignature(ConvertionUtils.toBytes(jwtToken.unsigned()), apiKey); return new Jwt(jwtToken.stringRepresentation() + "." + Base64Url.encode(signature)); }
JwtGenerator { public Jwt generateToken(String identity) throws CryptoException { JwtHeaderContent jwtHeaderContent = new JwtHeaderContent(apiPublicKeyIdentifier); JwtBodyContent jwtBodyContent = new JwtBodyContent(appId, identity, ttl, new Date()); Jwt jwtToken = new Jwt(jwtHeaderContent, jwtBodyContent); byte[] signature = this.accessTokenSigner .generateTokenSignature(ConvertionUtils.toBytes(jwtToken.unsigned()), apiKey); return new Jwt(jwtToken.stringRepresentation() + "." + Base64Url.encode(signature)); } }
JwtGenerator { public Jwt generateToken(String identity) throws CryptoException { JwtHeaderContent jwtHeaderContent = new JwtHeaderContent(apiPublicKeyIdentifier); JwtBodyContent jwtBodyContent = new JwtBodyContent(appId, identity, ttl, new Date()); Jwt jwtToken = new Jwt(jwtHeaderContent, jwtBodyContent); byte[] signature = this.accessTokenSigner .generateTokenSignature(ConvertionUtils.toBytes(jwtToken.unsigned()), apiKey); return new Jwt(jwtToken.stringRepresentation() + "." + Base64Url.encode(signature)); } JwtGenerator(String appId, VirgilPrivateKey apiKey, String apiPublicKeyIdentifier, TimeSpan ttl,
                      VirgilAccessTokenSigner accessTokenSigner); }
JwtGenerator { public Jwt generateToken(String identity) throws CryptoException { JwtHeaderContent jwtHeaderContent = new JwtHeaderContent(apiPublicKeyIdentifier); JwtBodyContent jwtBodyContent = new JwtBodyContent(appId, identity, ttl, new Date()); Jwt jwtToken = new Jwt(jwtHeaderContent, jwtBodyContent); byte[] signature = this.accessTokenSigner .generateTokenSignature(ConvertionUtils.toBytes(jwtToken.unsigned()), apiKey); return new Jwt(jwtToken.stringRepresentation() + "." + Base64Url.encode(signature)); } JwtGenerator(String appId, VirgilPrivateKey apiKey, String apiPublicKeyIdentifier, TimeSpan ttl,
                      VirgilAccessTokenSigner accessTokenSigner); Jwt generateToken(String identity); Jwt generateToken(String identity, Map<String, String> additionalData); }
JwtGenerator { public Jwt generateToken(String identity) throws CryptoException { JwtHeaderContent jwtHeaderContent = new JwtHeaderContent(apiPublicKeyIdentifier); JwtBodyContent jwtBodyContent = new JwtBodyContent(appId, identity, ttl, new Date()); Jwt jwtToken = new Jwt(jwtHeaderContent, jwtBodyContent); byte[] signature = this.accessTokenSigner .generateTokenSignature(ConvertionUtils.toBytes(jwtToken.unsigned()), apiKey); return new Jwt(jwtToken.stringRepresentation() + "." + Base64Url.encode(signature)); } JwtGenerator(String appId, VirgilPrivateKey apiKey, String apiPublicKeyIdentifier, TimeSpan ttl,
                      VirgilAccessTokenSigner accessTokenSigner); Jwt generateToken(String identity); Jwt generateToken(String identity, Map<String, String> additionalData);  }