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;
}
config.getClients().forEach((id, c) -> {
c.setId(id);
validator.validate(CONF_PREFIX + ".clients." + id, c);
});
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;
if(null == keyPair) {
keyPair = RSA.generateKeyPair();
signer = new RsaSigner(keyPair.getPrivateKey());
verifier = new RsaVerifier(keyPair.getPublicKey());
}
createEndpoints(app.routes());
}