Skip to content

Commit fd075e5

Browse files
committed
KeyType replaced with string
1 parent 3904781 commit fd075e5

5 files changed

Lines changed: 15 additions & 20 deletions

File tree

src/test/java/org/oidc/msg/AbstractMessageTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import com.auth0.jwt.interfaces.DecodedJWT;
2727
import com.auth0.msg.Key;
2828
import com.auth0.msg.KeyJar;
29-
import com.auth0.msg.KeyType;
29+
//import com.auth0.msg.KeyType;
3030
import com.auth0.msg.SYMKey;
3131
import com.fasterxml.jackson.core.JsonProcessingException;
3232
import java.io.IOException;
@@ -142,8 +142,8 @@ public void testSuccessToAndFromJWTNoneAlgBasicTypes() throws IOException, Inval
142142
public void testSuccessToJWTSignRS()
143143
throws IllegalArgumentException, ImportException, UnknownKeyType, ValueError,
144144
SerializationException, InvalidClaimException, IOException, JWKException {
145-
List<Key> keysSign = getKeyJarPrv().getSigningKey(KeyType.RSA.name(), keyOwner, null, null);
146-
List<Key> keysVerify = getKeyJarPub().getVerifyKey(KeyType.RSA.name(), keyOwner, null, null);
145+
List<Key> keysSign = getKeyJarPrv().getSigningKey("RSA", keyOwner, null, null);
146+
List<Key> keysVerify = getKeyJarPub().getVerifyKey("RSA", keyOwner, null, null);
147147
HashMap<String, Object> claims = new HashMap<String, Object>();
148148
claims.put("foo", "bar");
149149
MockMessage mockMessage = new MockMessage(claims);

src/test/java/org/oidc/msg/BaseMessageTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import com.auth0.msg.Key;
2626
import com.auth0.msg.KeyBundle;
2727
import com.auth0.msg.KeyJar;
28-
import com.auth0.msg.KeyType;
2928

3029
import java.io.IOException;
3130
import java.security.interfaces.ECPrivateKey;
@@ -111,12 +110,12 @@ protected String getSignedJwt(String alg)
111110
case "RS256":
112111
case "RS384":
113112
case "RS512":
114-
keys = getKeyJarPrv().getSigningKey(KeyType.RSA.name(), keyOwner, null, null);
113+
keys = getKeyJarPrv().getSigningKey("RSA", keyOwner, null, null);
115114
break;
116115
case "ES256":
117116
case "ES384":
118117
case "ES512":
119-
keys = getKeyJarPrv().getSigningKey(KeyType.EC.name(), keyOwner, null, null);
118+
keys = getKeyJarPrv().getSigningKey("EC", keyOwner, null, null);
120119
break;
121120
default:
122121
break;

src/test/java/org/oidc/msg/oidc/AccessTokenResponseTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import com.auth0.jwt.exceptions.oicmsg_exceptions.UnknownKeyType;
2222
import com.auth0.jwt.exceptions.oicmsg_exceptions.ValueError;
2323
import com.auth0.msg.Key;
24-
import com.auth0.msg.KeyType;
2524
import java.io.IOException;
2625
import java.util.HashMap;
2726
import org.junit.Assert;
@@ -46,7 +45,7 @@ public void testValidIdToken() throws InvalidClaimException, IllegalArgumentExce
4645
//TODO: check JWT signature also
4746
message.addClaim("access_token", "mockToken");
4847
message.addClaim("token_type", "mockType");
49-
Key key = getKeyJarPrv().getSigningKey(KeyType.RSA.name(), keyOwner, null, null).get(0);
48+
Key key = getKeyJarPrv().getSigningKey("RSA", keyOwner, null, null).get(0);
5049
String jwt = generateIdTokenNow(new HashMap<String, Object>(), key, "RS256");
5150
message.setIssuer(keyOwner);
5251
message.setKeyJar(getKeyJarPub());

src/test/java/org/oidc/msg/oidc/AuthenticationRequestTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,11 @@
1616

1717
package org.oidc.msg.oidc;
1818

19-
import com.auth0.jwt.exceptions.JWTDecodeException;
2019
import com.auth0.jwt.exceptions.oicmsg_exceptions.ImportException;
2120
import com.auth0.jwt.exceptions.oicmsg_exceptions.JWKException;
2221
import com.auth0.jwt.exceptions.oicmsg_exceptions.UnknownKeyType;
2322
import com.auth0.jwt.exceptions.oicmsg_exceptions.ValueError;
2423
import com.auth0.msg.Key;
25-
import com.auth0.msg.KeyType;
2624
import java.io.IOException;
2725
import java.net.MalformedURLException;
2826
import java.util.ArrayList;
@@ -144,7 +142,7 @@ public void testFailUnAllowedDisplayValue() throws InvalidClaimException {
144142
public void testSuccessIdTokenHint() throws InvalidClaimException, IllegalArgumentException,
145143
ImportException, UnknownKeyType, ValueError, IOException, JWKException, SerializationException, DeserializationException {
146144
IDToken idTokenHint = getIDTokenHint();
147-
List<Key> keysSign = getKeyJarPrv().getSigningKey(KeyType.RSA.name(), keyOwner, null, null);
145+
List<Key> keysSign = getKeyJarPrv().getSigningKey("RSA", keyOwner, null, null);
148146
claims.put("id_token_hint", idTokenHint.toJwt(keysSign.get(0), "RS256"));
149147
AuthenticationRequest req = new AuthenticationRequest(claims);
150148
Assert.assertTrue(req.verify());
@@ -195,7 +193,7 @@ public void testUrlEncodingSuccess()
195193
locales[2] = "en";
196194
claims.put("ui_locales", locales);
197195
IDToken idTokenHint = getIDTokenHint();
198-
List<Key> keysSign = getKeyJarPrv().getSigningKey(KeyType.RSA.name(), keyOwner, null, null);
196+
List<Key> keysSign = getKeyJarPrv().getSigningKey("RSA", keyOwner, null, null);
199197
claims.put("id_token_hint", idTokenHint.toJwt(keysSign.get(0), "RS256"));
200198
claims.put("login_hint", "user_is_bob");
201199
String[] acrs = new String[2];

src/test/java/org/oidc/msg/oidc/AuthenticationResponseTest.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import com.auth0.jwt.exceptions.oicmsg_exceptions.UnknownKeyType;
2222
import com.auth0.jwt.exceptions.oicmsg_exceptions.ValueError;
2323
import com.auth0.msg.Key;
24-
import com.auth0.msg.KeyType;
2524
import java.io.IOException;
2625
import java.util.ArrayList;
2726
import java.util.HashMap;
@@ -89,7 +88,7 @@ public void testFailureAudienceNotMatchingClientIdParameter() throws InvalidClai
8988
public void testSuccessValidIdToken() throws InvalidClaimException, IllegalArgumentException,
9089
ImportException, UnknownKeyType, ValueError, IOException, SerializationException, JWKException, DeserializationException {
9190
// Add id token to response as OP would propably add
92-
Key key = getKeyJarPrv().getSigningKey(KeyType.RSA.name(), keyOwner, null, null).get(0);
91+
Key key = getKeyJarPrv().getSigningKey("RSA", keyOwner, null, null).get(0);
9392
String jwt = generateIdTokenNow(new HashMap<String, Object>(), key, "RS256");
9493
AuthenticationResponse resp = new AuthenticationResponse();
9594
resp.addClaim("id_token", jwt);
@@ -115,7 +114,7 @@ public void testSuccessValidIdToken() throws InvalidClaimException, IllegalArgum
115114
public void testCHashMissingFailure() throws InvalidClaimException, IllegalArgumentException,
116115
ImportException, UnknownKeyType, ValueError, IOException, SerializationException, JWKException {
117116
String code = "AUTHORIZATION_CODE";
118-
Key key = getKeyJarPrv().getSigningKey(KeyType.RSA.name(), keyOwner, null, null).get(0);
117+
Key key = getKeyJarPrv().getSigningKey("RSA", keyOwner, null, null).get(0);
119118
HashMap<String, Object> claims = new HashMap<String, Object>();
120119
String jwt = generateIdTokenNow(claims, key, "RS256");
121120
AuthenticationResponse resp = new AuthenticationResponse();
@@ -128,7 +127,7 @@ public void testCHashMissingFailure() throws InvalidClaimException, IllegalArgum
128127
public void testCHashInvalidFailure() throws InvalidClaimException, IllegalArgumentException,
129128
ImportException, UnknownKeyType, ValueError, IOException, SerializationException, JWKException {
130129
String code = "AUTHORIZATION_CODE";
131-
Key key = getKeyJarPrv().getSigningKey(KeyType.RSA.name(), keyOwner, null, null).get(0);
130+
Key key = getKeyJarPrv().getSigningKey("RSA", keyOwner, null, null).get(0);
132131
HashMap<String, Object> claims = new HashMap<String, Object>();
133132
claims.put("c_hash", "BADGUESS");
134133
String jwt = generateIdTokenNow(claims, key, "RS256");
@@ -142,7 +141,7 @@ public void testCHashInvalidFailure() throws InvalidClaimException, IllegalArgum
142141
public void testCHashSuccess() throws InvalidClaimException, IllegalArgumentException,
143142
ImportException, UnknownKeyType, ValueError, IOException, SerializationException, JWKException {
144143
String code = "AUTHORIZATION_CODE";
145-
Key key = getKeyJarPrv().getSigningKey(KeyType.RSA.name(), keyOwner, null, null).get(0);
144+
Key key = getKeyJarPrv().getSigningKey("RSA", keyOwner, null, null).get(0);
146145
HashMap<String, Object> claims = new HashMap<String, Object>();
147146
claims.put("c_hash", TokenHash.compute(code, "RS256"));
148147
String jwt = generateIdTokenNow(claims, key, "RS256");
@@ -156,7 +155,7 @@ public void testCHashSuccess() throws InvalidClaimException, IllegalArgumentExce
156155
public void testAtHashMissingFailure() throws InvalidClaimException, IllegalArgumentException,
157156
ImportException, UnknownKeyType, ValueError, IOException, SerializationException, JWKException {
158157
String accessToken = "ACCESS_TOKEN";
159-
Key key = getKeyJarPrv().getSigningKey(KeyType.RSA.name(), keyOwner, null, null).get(0);
158+
Key key = getKeyJarPrv().getSigningKey("RSA", keyOwner, null, null).get(0);
160159
HashMap<String, Object> claims = new HashMap<String, Object>();
161160
String jwt = generateIdTokenNow(claims, key, "RS256");
162161
AuthenticationResponse resp = new AuthenticationResponse();
@@ -169,7 +168,7 @@ public void testAtHashMissingFailure() throws InvalidClaimException, IllegalArgu
169168
public void testAtHashInvalidFailure() throws InvalidClaimException, IllegalArgumentException,
170169
ImportException, UnknownKeyType, ValueError, IOException, SerializationException, JWKException {
171170
String accessToken = "ACCESS_TOKEN";
172-
Key key = getKeyJarPrv().getSigningKey(KeyType.RSA.name(), keyOwner, null, null).get(0);
171+
Key key = getKeyJarPrv().getSigningKey("RSA", keyOwner, null, null).get(0);
173172
HashMap<String, Object> claims = new HashMap<String, Object>();
174173
claims.put("at_hash", "BADGUESS");
175174
String jwt = generateIdTokenNow(claims, key, "RS256");
@@ -183,7 +182,7 @@ public void testAtHashInvalidFailure() throws InvalidClaimException, IllegalArgu
183182
public void testAtHashSuccess() throws InvalidClaimException, IllegalArgumentException,
184183
ImportException, UnknownKeyType, ValueError, IOException, SerializationException, JWKException {
185184
String accessToken = "ACCESS_TOKEN";
186-
Key key = getKeyJarPrv().getSigningKey(KeyType.RSA.name(), keyOwner, null, null).get(0);
185+
Key key = getKeyJarPrv().getSigningKey("RSA", keyOwner, null, null).get(0);
187186
HashMap<String, Object> claims = new HashMap<String, Object>();
188187
claims.put("at_hash", TokenHash.compute(accessToken, "RS256"));
189188
String jwt = generateIdTokenNow(claims, key, "RS256");

0 commit comments

Comments
 (0)