public static Authenticator buildAuthenticatorWithTruststore(final String keystorePath,
            final char[] keystorePassword, final List<String> keyids) {
        if (keystorePath != null) {
            final File file = new File(keystorePath);
            if (file.exists()) {
                try (final FileInputStream fis = new FileInputStream(file)) {
                    final KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
                    ks.load(fis, keystorePassword);
                    final List<String> keyIds = filterKeyIds(ks, keyids);
                    switch (keyIds.size()) {
                        case 0:
                            LOGGER.warn("No valid key ids provided! Skipping keystore: {}", keystorePath);
                            return null;
                        case 1:
                            return new JwtAuthenticator(ks.getCertificate(keyIds.get(0)).getPublicKey());
                        default:
                            return new FederatedJwtAuthenticator(ks, keyIds);
                    }
                } catch (final IOException | CertificateException | NoSuchAlgorithmException | KeyStoreException ex) {
                    LOGGER.error("Error reading keystore: {}", ex.getMessage());
                    LOGGER.warn("Ignoring JWT authenticator with keystore: {}", keystorePath);
                }
            }
        }
        return null;
    }
public static Authenticator buildAuthenticatorWithTruststore ( final String keystorePath , final char [ ] keystorePassword , final List < String > keyids ) { if ( keystorePath != null ) { final File file = new File ( keystorePath ) ; if ( file . exists ( ) ) { try ( final FileInputStream fis = new FileInputStream ( file ) ) { final KeyStore ks = KeyStore . getInstance ( KeyStore . getDefaultType ( ) ) ; ks . load ( fis , keystorePassword ) ; final List < String > keyIds = filterKeyIds ( ks , keyids ) ; switch ( keyIds . size ( ) ) { case 0 : LOGGER . warn ( "No valid key ids provided! Skipping keystore: {}" , keystorePath ) ; return null ; case 1 : return new JwtAuthenticator ( ks . getCertificate ( keyIds . get ( 0 ) ) . getPublicKey ( ) ) ; default : return new FederatedJwtAuthenticator ( ks , keyIds ) ; } } catch ( final IOException | CertificateException | NoSuchAlgorithmException | KeyStoreException ex ) { LOGGER . error ( "Error reading keystore: {}" , ex . getMessage ( ) ) ; LOGGER . warn ( "Ignoring JWT authenticator with keystore: {}" , keystorePath ) ; } } } return null ; }
Build an authenticator.
@param keystorePath the path to a keystore
@param keystorePassword the password for a keystore
@param keyids the key ids
@return an Authenticator, or null if there was an error