Merge pull request #3807 from hmlnarik/KEYCLOAK-4329-NPE-when-not-providing-KeyInfo-element-in-IdP-initiated-SSO-SAML-
KEYCLOAK-4329 Fix NPE when not providing KeyInfo element in IdP initiated SSO SAML
This commit is contained in:
commit
e28ca0ae61
1 changed files with 5 additions and 2 deletions
|
@ -35,6 +35,9 @@ public class KeyInfoTools {
|
|||
* @return The object or {@code null} if not found.
|
||||
*/
|
||||
public static <T> T getContent(Iterable<Object> objects, Class<T> clazz) {
|
||||
if (objects == null) {
|
||||
return null;
|
||||
}
|
||||
for (Object o : objects) {
|
||||
if (clazz.isInstance(o)) {
|
||||
return (T) o;
|
||||
|
@ -45,11 +48,11 @@ public class KeyInfoTools {
|
|||
|
||||
|
||||
public static KeyName getKeyName(KeyInfo keyInfo) {
|
||||
return getContent(keyInfo.getContent(), KeyName.class);
|
||||
return keyInfo == null ? null : getContent(keyInfo.getContent(), KeyName.class);
|
||||
}
|
||||
|
||||
public static X509Data getX509Data(KeyInfo keyInfo) {
|
||||
return getContent(keyInfo.getContent(), X509Data.class);
|
||||
return keyInfo == null ? null : getContent(keyInfo.getContent(), X509Data.class);
|
||||
}
|
||||
|
||||
public static X509Certificate getX509Certificate(KeyInfo keyInfo) {
|
||||
|
|
Loading…
Reference in a new issue