1717package org .oidc .msg ;
1818
1919import com .auth0 .jwt .JWT ;
20- import com .auth0 .jwt .JWTDecryptor ;
2120import com .auth0 .jwt .JWTVerifier ;
2221import com .auth0 .jwt .algorithms .Algorithm ;
2322import com .auth0 .jwt .exceptions .JWTDecodeException ;
3433import java .io .IOException ;
3534import java .lang .reflect .Array ;
3635import java .net .MalformedURLException ;
37- import java .security .interfaces .RSAPrivateKey ;
3836import java .security .interfaces .RSAPublicKey ;
3937import java .util .ArrayList ;
4038import java .util .Arrays ;
4442import java .util .Map ;
4543
4644import org .hamcrest .CoreMatchers ;
47- import org .hamcrest .Matcher ;
4845import org .junit .Assert ;
4946import org .junit .Before ;
5047import org .junit .Test ;
@@ -163,7 +160,17 @@ private void testSuccessJWTEncryptDecrypt(String alg, String encAlg, String encE
163160 MockMessage mockMessage = new MockMessage (claims );
164161 List <Key > keysDec = getKeyJar ().getDecryptKey (null , keyOwner , null , null );
165162 List <Key > keysEnc = getKeyJarPub ().getEncryptKey (null , keyOwner , null , null );
166- String signedAndEncryptedJwt =mockMessage .toJwt (keysDec .get (0 ), alg , keysEnc .get (0 ), encAlg ,
163+ int index =0 ;
164+ if (encAlg .equals ("A128KW" )){
165+ index =1 ;
166+ }
167+ if (encAlg .equals ("A192KW" )){
168+ index =2 ;
169+ }
170+ if (encAlg .equals ("A256KW" )){
171+ index =3 ;
172+ }
173+ String signedAndEncryptedJwt =mockMessage .toJwt (keysDec .get (0 ), alg , keysEnc .get (index ), encAlg ,
167174 encEnc );
168175 MockMessage mockMessage2 = new MockMessage ();
169176 mockMessage2 .fromJwt (signedAndEncryptedJwt , getKeyJar (), keyOwner );
@@ -182,7 +189,9 @@ public void testSuccessJWTEncryptDecrypt1()
182189 testSuccessJWTEncryptDecrypt ("RS256" ,"RSA1_5" ,"A128GCM" );
183190 testSuccessJWTEncryptDecrypt ("RS384" ,"RSA-OAEP" ,"A192GCM" );
184191 testSuccessJWTEncryptDecrypt ("RS512" ,"RSA-OAEP-256" ,"A256GCM" );
185-
192+ testSuccessJWTEncryptDecrypt ("RS256" ,"A128KW" ,"A128CBC-HS256" );
193+ //testSuccessJWTEncryptDecrypt("RS256","A192KW","A128CBC-HS256");
194+ //testSuccessJWTEncryptDecrypt("RS256","A256KW","A128CBC-HS256");
186195 }
187196
188197 @ Test
0 commit comments