TokenUtils { @Deprecated public static String generateTokenString(final String jsonResName) throws Exception { return signClaims(jsonResName); } private  TokenUtils(); @Deprecated static String generateTokenString(final String jsonResName); static String signClaims(final String jsonResName); static String signClaims(final String jsonResName, SignatureAlgorithm algorithm); @Deprecated static String generateTokenString(final String jsonResName, final Set<InvalidClaims> invalidClaims); static String signClaims(final String jsonResName, SignatureAlgorithm algorithm, final Set<InvalidClaims> invalidClaims); @Deprecated static String generateTokenString(String jsonResName, Set<InvalidClaims> invalidClaims, Map<String, Long> timeClaims); static String signClaims(String jsonResName, SignatureAlgorithm algorithm,
        Set<InvalidClaims> invalidClaims, Map<String, Long> timeClaims); @Deprecated static String generateTokenString(PrivateKey pk, String kid, String jsonResName, Set<InvalidClaims> invalidClaims,
            Map<String, Long> timeClaims); static String signClaims(PrivateKey pk, String kid, String jsonResName); static String signClaims(PrivateKey pk, String kid, String jsonResName,
        Set<InvalidClaims> invalidClaims, Map<String, Long> timeClaims); static String encryptClaims(final String jsonResName); static String encryptClaims(final String jsonResName, final Set<InvalidClaims> invalidClaims); static String encryptClaims(String jsonResName, Set<InvalidClaims> invalidClaims, Map<String, Long> timeClaims); static String encryptClaims(PublicKey pk, String jsonResName); static String encryptClaims(PublicKey pk, String kid, String jsonResName); static String encryptClaims(PublicKey pk, String kid, String jsonResName, Set<InvalidClaims> invalidClaims,
            Map<String, Long> timeClaims); static String signEncryptClaims(String jsonResName); static String signEncryptClaims(String jsonResName, SignatureAlgorithm signatureAlgorithm); static String signEncryptClaims(PrivateKey signingKey,
                                             PublicKey encryptionKey,
                                             String jsonResName); static String signEncryptClaims(PrivateKey signingKey,
                                       String signingKid,
                                       PublicKey encryptionKey,
                                       String encryptionKid,
                                       String jsonResName); static String signEncryptClaims(PrivateKey signingKey,
                                       String signingKid,
                                       PublicKey encryptionKey,
                                       String encryptionKid,
                                       String jsonResName,
                                       boolean setContentType); static String readResource(String resName); static RSAPrivateKey readPrivateKey(final String pemResName); static ECPrivateKey readECPrivateKey(final String pemResName); static RSAPublicKey readPublicKey(final String pemResName); static ECPublicKey readECPublicKey(final String pemResName); static PublicKey readJwkPublicKey(final String jwkResName); static PrivateKey readJwkPrivateKey(final String jwkResName); static KeyPair generateKeyPair(final int keySize); static RSAPrivateKey decodePrivateKey(final String pemEncoded); static ECPrivateKey decodeECPrivateKey(final String pemEncoded); static RSAPublicKey decodePublicKey(String pemEncoded); static ECPublicKey decodeECPublicKey(String pemEncoded); static int currentTimeInSecs();  }
@Test(groups = TCKConstants.TEST_GROUP_UTILS, expectedExceptions = {InvalidJwtException.class}, description = "Deprecated: Illustrate validation of signer") public void testFailSignatureDeprecated() throws Exception { Set<TokenUtils.InvalidClaims> invalidFields = new HashSet<>(); invalidFields.add(TokenUtils.InvalidClaims.SIGNER); @SuppressWarnings("deprecation") String token = TokenUtils.generateTokenString("/Token1.json", invalidFields); validateToken(token); }
@Test(groups = TCKConstants.TEST_GROUP_UTILS, expectedExceptions = {InvalidJwtException.class}, description = "Deprecated: Illustrate validation of exp") public void testFailExpiredDeprecated() throws Exception { Map<String, Long> timeClaims = new HashMap<>(); Set<TokenUtils.InvalidClaims> invalidFields = new HashSet<>(); invalidFields.add(TokenUtils.InvalidClaims.EXP); @SuppressWarnings("deprecation") String token = TokenUtils.generateTokenString("/Token1.json", invalidFields, timeClaims); validateToken(token); }
@Test(groups = TCKConstants.TEST_GROUP_UTILS, expectedExceptions = {InvalidJwtException.class}, description = "Deprecated: Illustrate validation of alg") public void testFailAlgorithmDeprecated() throws Exception { Set<TokenUtils.InvalidClaims> invalidFields = new HashSet<>(); invalidFields.add(TokenUtils.InvalidClaims.ALG); @SuppressWarnings("deprecation") String token = TokenUtils.generateTokenString("/Token1.json", invalidFields); validateToken(token); }
@Test(groups = TCKConstants.TEST_GROUP_UTILS, description = "Deprecated: Illustrate validation of a JWT") public void testValidTokenDeprecated() throws Exception { @SuppressWarnings("deprecation") String token = TokenUtils.generateTokenString("/Token1.json"); validateToken(token); }
@Test(groups = TCKConstants.TEST_GROUP_UTILS, expectedExceptions = {InvalidJwtException.class}, description = "Deprecated: Illustrate validation of issuer") public void testFailIssuerDeprecated() throws Exception { Set<TokenUtils.InvalidClaims> invalidFields = new HashSet<>(); invalidFields.add(TokenUtils.InvalidClaims.ISSUER); @SuppressWarnings("deprecation") String token = TokenUtils.generateTokenString("/Token1.json", invalidFields); validateToken(token); }