if there's only one key, return it as the default
parent
a769c972eb
commit
34a81c25dc
|
@ -102,7 +102,9 @@ public class DefaultJwtEncryptionAndDecryptionService implements JwtEncryptionAn
|
||||||
throw new IllegalArgumentException("Tried to load a key from a keystore without a 'kid' field: " + key);
|
throw new IllegalArgumentException("Tried to load a key from a keystore without a 'kid' field: " + key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buildEncryptersAndDecrypters();
|
buildEncryptersAndDecrypters();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -116,7 +118,14 @@ public class DefaultJwtEncryptionAndDecryptionService implements JwtEncryptionAn
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDefaultEncryptionKeyId() {
|
public String getDefaultEncryptionKeyId() {
|
||||||
return defaultEncryptionKeyId;
|
if (defaultEncryptionKeyId != null) {
|
||||||
|
return defaultEncryptionKeyId;
|
||||||
|
} else if (keys.size() == 1) {
|
||||||
|
// if there's only one key in the map, it's the default
|
||||||
|
return keys.keySet().iterator().next();
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDefaultEncryptionKeyId(String defaultEncryptionKeyId) {
|
public void setDefaultEncryptionKeyId(String defaultEncryptionKeyId) {
|
||||||
|
@ -124,7 +133,14 @@ public class DefaultJwtEncryptionAndDecryptionService implements JwtEncryptionAn
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDefaultDecryptionKeyId() {
|
public String getDefaultDecryptionKeyId() {
|
||||||
return defaultDecryptionKeyId;
|
if (defaultDecryptionKeyId != null) {
|
||||||
|
return defaultDecryptionKeyId;
|
||||||
|
} else if (keys.size() == 1) {
|
||||||
|
// if there's only one key in the map, it's the default
|
||||||
|
return keys.keySet().iterator().next();
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDefaultDecryptionKeyId(String defaultDecryptionKeyId) {
|
public void setDefaultDecryptionKeyId(String defaultDecryptionKeyId) {
|
||||||
|
|
|
@ -109,7 +109,14 @@ public class DefaultJwtSigningAndValidationService implements JwtSigningAndValid
|
||||||
* @return the defaultSignerKeyId
|
* @return the defaultSignerKeyId
|
||||||
*/
|
*/
|
||||||
public String getDefaultSignerKeyId() {
|
public String getDefaultSignerKeyId() {
|
||||||
return defaultSignerKeyId;
|
if (defaultSignerKeyId != null) {
|
||||||
|
return defaultSignerKeyId;
|
||||||
|
} else if (keys.size() == 1) {
|
||||||
|
// if there's only one key, it's the default
|
||||||
|
return keys.keySet().iterator().next();
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue