public static <T extends RSAPublicKey> JwtVerifier createRSAJwtVerifier(T publicKey){ return new RsaVerifier(publicKey); } public static <T extends RSAPublicKey> JwtVerifier createRSAJwtVerifier(PublicKeyGetter<T> getter){
public Map<String, Object> verifyToken(String token) throws TokenVerifyException{ return verifier.verify(token); }
public static <T extends RSAPublicKey> JwtVerifier createRSAJwtVerifier(T publicKey){ return new RsaVerifier(publicKey); } public static <T extends RSAPublicKey> JwtVerifier createRSAJwtVerifier(PublicKeyGetter<T> getter){
public static <T extends RSAPublicKey> JwtVerifier createRSAJwtVerifier(PublicKeyGetter<T> getter){ return new RsaVerifier(getter.getPublicKey()); } public static JwtVerifier createNetPublicKeyRSAJwtVerifier(String url){
protected JwtVerifier getVerifier(){ return new RsaVerifier(this.getter.getPublicKey()); }
public static <T extends RSAPublicKey> JwtVerifier createRSAJwtVerifier(PublicKeyGetter<T> getter){ return new RsaVerifier(getter.getPublicKey()); } public static JwtVerifier createNetPublicKeyRSAJwtVerifier(String url){
protected JwtVerifier getVerifier(){ return new RsaVerifier(this.getter.getPublicKey()); }
@Override public OAuth2AuthzServerConfigurator useRsaJwtVerifier() { if(this.publicKey == null){ throw new NullPointerException("public key is null! please use setPublicKeyStr(String publicKey) " + "or setPublicKey to set the public key."); } if(this.publicKey instanceof RSAPublicKey){ this.jwtVerifier = new RsaVerifier((RSAPublicKey)this.getPublicKey()); }else{ throw new AppConfigException("this public key is not a rsa public key!"); } return this; }
@Override public OAuth2AuthzServerConfigurator useRsaJwtVerifier() { if(this.publicKey == null){ throw new NullPointerException("public key is null! please use setPublicKeyStr(String publicKey) " + "or setPublicKey to set the public key."); } if(this.publicKey instanceof RSAPublicKey){ this.jwtVerifier = new RsaVerifier((RSAPublicKey)this.getPublicKey()); }else{ throw new AppConfigException("this public key is not a rsa public key!"); } return this; }
@Override public OAuth2ResServerConfigurator useRsaJwtVerifier() { Assert.notEmpty(rsaPublicKeyStr,"rsa public key string can not be empty"); jwtVerifier = new RsaVerifier(RSA.decodePublicKey(rsaPublicKeyStr)); return this; }
protected void refreshJwtVerifier() { log.info("Fetching public key from server, url '{}' ...", config.getPublicKeyUrl()); HttpResponse response = httpClient.request(config.getPublicKeyUrl()).get(); if(!response.isOk()) { throw new OAuth2InternalServerException("Error fetching public key from server, status " + response.getStatus() + ""); } String encoded = response.getString(); RSAPublicKey publicKey = RSA.decodePublicKey(encoded); verifier = new RsaVerifier(publicKey); }
public void configure() { if(!endpoints.isEmpty()) { endpoints.forEach(r -> app.routes().remove(r)); } Map<String, Object> map = ConfigUtils.extractMap(app.config(), CONF_PREFIX); if(null == map || map.isEmpty()) { return; } config = Converts.convert(map, OAuth2ServerConfig.class); if(!config.isEnabled()) { return; } //clients config.getClients().forEach((id, c) -> { c.setId(id); validator.validate(CONF_PREFIX + ".clients." + id, c); }); //url int port = app.config().getIntProperty("server.port", 8080); String contextPath = app.config().getProperty("server.context-path", ""); this.url = (config.isSsl() ? "https:" : "http") + "://localhost:" + port + contextPath; //gen key pair if(null == keyPair) { keyPair = RSA.generateKeyPair(); signer = new RsaSigner(keyPair.getPrivateKey()); verifier = new RsaVerifier(keyPair.getPublicKey()); } //create endpoint createEndpoints(app.routes()); }