Skip to content

Commit b2b915b

Browse files
author
Justin Richer
committed
explcitly set alg and enc instead of trying to guess
1 parent b75d774 commit b2b915b

File tree

1 file changed

+32
-15
lines changed

1 file changed

+32
-15
lines changed

openid-connect-client/src/main/java/org/mitre/openid/connect/client/service/impl/EncryptedAuthRequestUrlBuilder.java

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,16 @@ public class EncryptedAuthRequestUrlBuilder implements AuthRequestUrlBuilder {
3030

3131
private JWKSetCacheService encrypterService;
3232

33+
private JWEAlgorithm alg;
34+
private EncryptionMethod enc;
35+
36+
3337
/* (non-Javadoc)
3438
* @see org.mitre.openid.connect.client.service.AuthRequestUrlBuilder#buildAuthRequestUrl(org.mitre.openid.connect.config.ServerConfiguration, org.mitre.oauth2.model.RegisteredClient, java.lang.String, java.lang.String, java.lang.String, java.util.Map)
3539
*/
3640
@Override
3741
public String buildAuthRequestUrl(ServerConfiguration serverConfig, RegisteredClient clientConfig, String redirectUri, String nonce, String state, Map<String, String> options) {
3842

39-
JWEAlgorithm alg = null;
40-
EncryptionMethod enc = null;
41-
42-
if (serverConfig.getRequestObjectEncryptionAlgValuesSupported() != null || !serverConfig.getRequestObjectEncryptionAlgValuesSupported().isEmpty()) {
43-
alg = serverConfig.getRequestObjectEncryptionAlgValuesSupported().get(0); // get the first alg value in the list
44-
if (serverConfig.getRequestObjectEncryptionEncValuesSupported() != null || !serverConfig.getRequestObjectEncryptionEncValuesSupported().isEmpty()) {
45-
enc = serverConfig.getRequestObjectEncryptionEncValuesSupported().get(0); // get the first enc value in the list
46-
}
47-
}
48-
49-
if (alg == null || enc == null) {
50-
throw new IllegalArgumentException("No encryption algorithms found for server " + serverConfig);
51-
}
52-
53-
5443
// create our signed JWT for the request object
5544
JWTClaimsSet claims = new JWTClaimsSet();
5645

@@ -104,4 +93,32 @@ public void setEncrypterService(JWKSetCacheService encrypterService) {
10493
this.encrypterService = encrypterService;
10594
}
10695

96+
/**
97+
* @return the alg
98+
*/
99+
public JWEAlgorithm getAlg() {
100+
return alg;
101+
}
102+
103+
/**
104+
* @param alg the alg to set
105+
*/
106+
public void setAlg(JWEAlgorithm alg) {
107+
this.alg = alg;
108+
}
109+
110+
/**
111+
* @return the enc
112+
*/
113+
public EncryptionMethod getEnc() {
114+
return enc;
115+
}
116+
117+
/**
118+
* @param enc the enc to set
119+
*/
120+
public void setEnc(EncryptionMethod enc) {
121+
this.enc = enc;
122+
}
123+
107124
}

0 commit comments

Comments
 (0)