KEYCLOAK-18560 NoClassDefFoundError: Could not initialize class org.keycloak.util.JWKSUtils
This commit is contained in:
parent
8a82130579
commit
c1168ea6ea
1 changed files with 6 additions and 5 deletions
|
@ -17,7 +17,6 @@
|
||||||
|
|
||||||
package org.keycloak.util;
|
package org.keycloak.util;
|
||||||
|
|
||||||
import org.jboss.logging.Logger;
|
|
||||||
import org.keycloak.crypto.KeyUse;
|
import org.keycloak.crypto.KeyUse;
|
||||||
import org.keycloak.crypto.KeyWrapper;
|
import org.keycloak.crypto.KeyWrapper;
|
||||||
import org.keycloak.jose.jwk.JSONWebKeySet;
|
import org.keycloak.jose.jwk.JSONWebKeySet;
|
||||||
|
@ -27,13 +26,15 @@ import org.keycloak.jose.jwk.JWKParser;
|
||||||
import java.security.PublicKey;
|
import java.security.PublicKey;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||||
*/
|
*/
|
||||||
public class JWKSUtils {
|
public class JWKSUtils {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(JWKSUtils.class);
|
private static final Logger logger = Logger.getLogger(JWKSUtils.class.getName());
|
||||||
|
|
||||||
public static Map<String, PublicKey> getKeysForUse(JSONWebKeySet keySet, JWK.Use requestedUse) {
|
public static Map<String, PublicKey> getKeysForUse(JSONWebKeySet keySet, JWK.Use requestedUse) {
|
||||||
Map<String, PublicKey> result = new HashMap<>();
|
Map<String, PublicKey> result = new HashMap<>();
|
||||||
|
@ -41,7 +42,7 @@ public class JWKSUtils {
|
||||||
for (JWK jwk : keySet.getKeys()) {
|
for (JWK jwk : keySet.getKeys()) {
|
||||||
JWKParser parser = JWKParser.create(jwk);
|
JWKParser parser = JWKParser.create(jwk);
|
||||||
if (jwk.getPublicKeyUse() == null) {
|
if (jwk.getPublicKeyUse() == null) {
|
||||||
logger.debugf("Ignoring JWK key '%s'. Missing required field 'use'.", jwk.getKeyId());
|
logger.log(Level.FINE, "Ignoring JWK key '%s'. Missing required field 'use'.", jwk.getKeyId());
|
||||||
} else if (requestedUse.asString().equals(jwk.getPublicKeyUse()) && parser.isKeyTypeSupported(jwk.getKeyType())) {
|
} else if (requestedUse.asString().equals(jwk.getPublicKeyUse()) && parser.isKeyTypeSupported(jwk.getKeyType())) {
|
||||||
result.put(jwk.getKeyId(), parser.toPublicKey());
|
result.put(jwk.getKeyId(), parser.toPublicKey());
|
||||||
}
|
}
|
||||||
|
@ -55,7 +56,7 @@ public class JWKSUtils {
|
||||||
for (JWK jwk : keySet.getKeys()) {
|
for (JWK jwk : keySet.getKeys()) {
|
||||||
JWKParser parser = JWKParser.create(jwk);
|
JWKParser parser = JWKParser.create(jwk);
|
||||||
if (jwk.getPublicKeyUse() == null) {
|
if (jwk.getPublicKeyUse() == null) {
|
||||||
logger.debugf("Ignoring JWK key '%s'. Missing required field 'use'.", jwk.getKeyId());
|
logger.log(Level.FINE, "Ignoring JWK key '%s'. Missing required field 'use'.", jwk.getKeyId());
|
||||||
} else if (requestedUse.asString().equals(jwk.getPublicKeyUse()) && parser.isKeyTypeSupported(jwk.getKeyType())) {
|
} else if (requestedUse.asString().equals(jwk.getPublicKeyUse()) && parser.isKeyTypeSupported(jwk.getKeyType())) {
|
||||||
KeyWrapper keyWrapper = new KeyWrapper();
|
KeyWrapper keyWrapper = new KeyWrapper();
|
||||||
keyWrapper.setKid(jwk.getKeyId());
|
keyWrapper.setKid(jwk.getKeyId());
|
||||||
|
@ -90,7 +91,7 @@ public class JWKSUtils {
|
||||||
for (JWK jwk : keySet.getKeys()) {
|
for (JWK jwk : keySet.getKeys()) {
|
||||||
JWKParser parser = JWKParser.create(jwk);
|
JWKParser parser = JWKParser.create(jwk);
|
||||||
if (jwk.getPublicKeyUse() == null) {
|
if (jwk.getPublicKeyUse() == null) {
|
||||||
logger.debugf("Ignoring JWK key '%s'. Missing required field 'use'.", jwk.getKeyId());
|
logger.log(Level.FINE, "Ignoring JWK key '%s'. Missing required field 'use'.", jwk.getKeyId());
|
||||||
} else if (requestedUse.asString().equals(parser.getJwk().getPublicKeyUse()) && parser.isKeyTypeSupported(jwk.getKeyType())) {
|
} else if (requestedUse.asString().equals(parser.getJwk().getPublicKeyUse()) && parser.isKeyTypeSupported(jwk.getKeyType())) {
|
||||||
return jwk;
|
return jwk;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue