// Path: core/src/main/java/org/juiser/io/DefaultResource.java
// public class DefaultResource implements Resource {
// 
//     private final InputStream is;
//     private final String name;
// 
//     public DefaultResource(InputStream is, String name) {
//         Assert.notNull(is, "InputStream cannot be null.");
//         Assert.hasText(name, "String name argument cannot be null or empty.");
//         this.is = is;
//         this.name = name;
//     }
// 
//     @Override
//     public InputStream getInputStream() {
//         return this.is;
//     }
// 
//     @Override
//     public String getName() {
//         return this.name;
//     }
// 
//     @Override
//     public String toString() {
//         return "DefaultResource name='" + getName() + "'";
//     }
// }
// 
// Path: core/src/main/java/org/juiser/io/Resource.java
// public interface Resource {
// 
//     InputStream getInputStream();
// 
//     String getName();
// }
// 
// Path: core/src/main/java/org/juiser/io/ResourceLoader.java
// public interface ResourceLoader {
// 
//     Resource getResource(String path) throws IOException;
// }
// 
// Path: core/src/main/java/org/juiser/jwt/AlgorithmFamily.java
// public enum AlgorithmFamily {
// 
//     HMAC,
//     RSA,
//     EC; //Elliptic Curve
// 
//     public static AlgorithmFamily forName(String name) {
// 
//         if (HMAC.name().equalsIgnoreCase(name)) {
//             return HMAC;
//         } else if (RSA.name().equalsIgnoreCase(name)) {
//             return RSA;
//         } else if (EC.name().equalsIgnoreCase(name) ||
//             "ECDSA".equalsIgnoreCase(name) ||
//             "Elliptic Curve".equalsIgnoreCase(name)) {
//             return EC;
//         }
// 
//         //couldn't associate, invalid arg:
//         String msg = "Unrecognized algorithm family name value: " + name;
//         throw new IllegalArgumentException(msg);
//     }
// }


import java.security.PublicKey;
import java.security.interfaces.ECKey;
import java.security.interfaces.RSAKey;
import java.util.function.Function;
import org.juiser.io.DefaultResource;
import org.juiser.io.Resource;
import org.juiser.io.ResourceLoader;
import org.juiser.jwt.AlgorithmFamily;
import io.jsonwebtoken.SignatureAlgorithm;
import io.jsonwebtoken.impl.TextCodec;
import io.jsonwebtoken.lang.Assert;
import io.jsonwebtoken.lang.Classes;
import io.jsonwebtoken.lang.RuntimeEnvironment;
import io.jsonwebtoken.lang.Strings;
import javax.crypto.spec.SecretKeySpec;
import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
import java.security.Key;

        if (keyResource != null && keyStringSpecified) {
            String msg = "Both the juiser.header.jwt.key.value and " +
                "juiser.header.jwt.key.resource properties may not be set simultaneously.  " +
                "Please choose one.";
            throw new IllegalArgumentException(msg);
        }

        if (keyStringSpecified) {

            String encoding = jwk.getEncoding();

            if (keyString.startsWith(PemResourceKeyResolver.PEM_PREFIX)) {
                encoding = "pem";
            }

            if (encoding == null) {
                //default to the JWK specification format:
                encoding = "base64url";
            }

            if (encoding.equalsIgnoreCase("base64url")) {
                bytes = TextCodec.BASE64URL.decode(keyString);
            } else if (encoding.equalsIgnoreCase("base64")) {
                bytes = TextCodec.BASE64.decode(keyString);
            } else if (encoding.equalsIgnoreCase("utf8")) {
                bytes = keyString.getBytes(StandardCharsets.UTF_8);
            } else if (encoding.equalsIgnoreCase("pem")) {
                byte[] resourceBytes = keyString.getBytes(StandardCharsets.UTF_8);
                final ByteArrayInputStream bais = new ByteArrayInputStream(resourceBytes);
// Path: core/src/main/java/org/juiser/io/DefaultResource.java
// public class DefaultResource implements Resource {
// 
//     private final InputStream is;
//     private final String name;
// 
//     public DefaultResource(InputStream is, String name) {
//         Assert.notNull(is, "InputStream cannot be null.");
//         Assert.hasText(name, "String name argument cannot be null or empty.");
//         this.is = is;
//         this.name = name;
//     }
// 
//     @Override
//     public InputStream getInputStream() {
//         return this.is;
//     }
// 
//     @Override
//     public String getName() {
//         return this.name;
//     }
// 
//     @Override
//     public String toString() {
//         return "DefaultResource name='" + getName() + "'";
//     }
// }
// 
// Path: core/src/main/java/org/juiser/io/Resource.java
// public interface Resource {
// 
//     InputStream getInputStream();
// 
//     String getName();
// }
// 
// Path: core/src/main/java/org/juiser/io/ResourceLoader.java
// public interface ResourceLoader {
// 
//     Resource getResource(String path) throws IOException;
// }
// 
// Path: core/src/main/java/org/juiser/jwt/AlgorithmFamily.java
// public enum AlgorithmFamily {
// 
//     HMAC,
//     RSA,
//     EC; //Elliptic Curve
// 
//     public static AlgorithmFamily forName(String name) {
// 
//         if (HMAC.name().equalsIgnoreCase(name)) {
//             return HMAC;
//         } else if (RSA.name().equalsIgnoreCase(name)) {
//             return RSA;
//         } else if (EC.name().equalsIgnoreCase(name) ||
//             "ECDSA".equalsIgnoreCase(name) ||
//             "Elliptic Curve".equalsIgnoreCase(name)) {
//             return EC;
//         }
// 
//         //couldn't associate, invalid arg:
//         String msg = "Unrecognized algorithm family name value: " + name;
//         throw new IllegalArgumentException(msg);
//     }
// }


// Path: core/src/main/java/org/juiser/jwt/config/ConfigJwkResolver.java
import java.security.PublicKey;
import java.security.interfaces.ECKey;
import java.security.interfaces.RSAKey;
import java.util.function.Function;
import org.juiser.io.DefaultResource;
import org.juiser.io.Resource;
import org.juiser.io.ResourceLoader;
import org.juiser.jwt.AlgorithmFamily;
import io.jsonwebtoken.SignatureAlgorithm;
import io.jsonwebtoken.impl.TextCodec;
import io.jsonwebtoken.lang.Assert;
import io.jsonwebtoken.lang.Classes;
import io.jsonwebtoken.lang.RuntimeEnvironment;
import io.jsonwebtoken.lang.Strings;
import javax.crypto.spec.SecretKeySpec;
import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
import java.security.Key;


        if (keyResource != null && keyStringSpecified) {
            String msg = "Both the juiser.header.jwt.key.value and " +
                "juiser.header.jwt.key.resource properties may not be set simultaneously.  " +
                "Please choose one.";
            throw new IllegalArgumentException(msg);
        }

        if (keyStringSpecified) {

            String encoding = jwk.getEncoding();

            if (keyString.startsWith(PemResourceKeyResolver.PEM_PREFIX)) {
                encoding = "pem";
            }

            if (encoding == null) {
                //default to the JWK specification format:
                encoding = "base64url";
            }

            if (encoding.equalsIgnoreCase("base64url")) {
                bytes = TextCodec.BASE64URL.decode(keyString);
            } else if (encoding.equalsIgnoreCase("base64")) {
                bytes = TextCodec.BASE64.decode(keyString);
            } else if (encoding.equalsIgnoreCase("utf8")) {
                bytes = keyString.getBytes(StandardCharsets.UTF_8);
            } else if (encoding.equalsIgnoreCase("pem")) {
                byte[] resourceBytes = keyString.getBytes(StandardCharsets.UTF_8);
                final ByteArrayInputStream bais = new ByteArrayInputStream(resourceBytes);
                keyResource = new DefaultResource(bais, "juiser.header.jwt.key.value");