public static Optional < JsonWebKeySet > getJsonWebKeySet ( final OidcRegisteredService service ) { try { LOGGER . trace ( "Loading JSON web key from [{}]" , service . getJwks ( ) ) ; val resource = getJsonWebKeySetResource ( service ) ; val jsonWebKeySet = buildJsonWebKeySet ( resource ) ; if ( jsonWebKeySet == null || jsonWebKeySet . getJsonWebKeys ( ) . isEmpty ( ) ) { LOGGER . warn ( "No JSON web keys could be found for [{}]" , service ) ; return Optional . empty ( ) ; } val badKeysCount = jsonWebKeySet . getJsonWebKeys ( ) . stream ( ) . filter ( k -> StringUtils . isBlank ( k . getAlgorithm ( ) ) && StringUtils . isBlank ( k . getKeyId ( ) ) && StringUtils . isBlank ( k . getKeyType ( ) ) ) . count ( ) ; if ( badKeysCount == jsonWebKeySet . getJsonWebKeys ( ) . size ( ) ) { LOGGER . warn ( "No valid JSON web keys could be found for [{}]" , service ) ; return Optional . empty ( ) ; } val webKey = getJsonWebKeyFromJsonWebKeySet ( jsonWebKeySet ) ; if ( Objects . requireNonNull ( webKey ) . getPublicKey ( ) == null ) { LOGGER . warn ( "JSON web key retrieved [{}] has no associated public key" , webKey . getKeyId ( ) ) ; return Optional . empty ( ) ; } return Optional . of ( jsonWebKeySet ) ; } catch ( final Exception e ) { LOGGER . error ( e . getMessage ( ) , e ) ; } return Optional . empty ( ) ; }
Gets json web key set .