use of com.gw2auth.oauth2.server in project webtools.servertools by eclipse.
the class XmlTestCase method getXml40Server.
private Server getXml40Server(String testId) {
Factory factory = new Factory();
factory.setPackageName("org.eclipse.jst.server.tomcat.core.internal.xml.server40");
try {
return (Server) factory.loadDocument(getXmlInputStream(testId));
} catch (Exception e) {
fail("Exception occurred loading " + testId + " XML: " + e.getMessage());
return null;
}
}
use of com.gw2auth.oauth2.server in project webtools.servertools by eclipse.
the class XmlTestCase method getXml32Server.
private org.eclipse.jst.server.tomcat.core.internal.xml.server32.Server getXml32Server(String testId) {
Factory factory = new Factory();
factory.setPackageName("org.eclipse.jst.server.tomcat.core.internal.xml.server32");
try {
return (org.eclipse.jst.server.tomcat.core.internal.xml.server32.Server) factory.loadDocument(getXmlInputStream(testId));
} catch (Exception e) {
fail("Exception occurred loading " + testId + " XML: " + e.getMessage());
return null;
}
}
use of com.gw2auth.oauth2.server in project oauth2-server by gw2auth.
the class OAuth2ServerConfiguration method jwkSource.
@Bean
public JWKSource<SecurityContext> jwkSource(@Value("${com.gw2auth.oauth2.keypair.id}") String keyPairId, @Value("${com.gw2auth.oauth2.keypair.path}") String keyPairPath) throws IOException, GeneralSecurityException {
if (keyPairId.equals("generate")) {
keyPairId = UUID.randomUUID().toString();
}
final KeyPair keyPair;
if (keyPairPath.equals("generate")) {
keyPair = generateRsaKey();
} else {
keyPair = loadRsaKey(keyPairPath, keyPairPath + ".pub");
}
final RSAKey rsaKey = new RSAKey.Builder((RSAPublicKey) keyPair.getPublic()).privateKey((RSAPrivateKey) keyPair.getPrivate()).keyID(keyPairId).build();
final JWKSet jwkSet = new JWKSet(rsaKey);
return (jwkSelector, securityContext) -> jwkSelector.select(jwkSet);
}
use of com.gw2auth.oauth2.server in project oauth2-server by gw2auth.
the class OAuth2ServerConfiguration method oauth2ServerHttpSecurityFilterChain.
@Bean
@Order(Ordered.HIGHEST_PRECEDENCE + 1)
public SecurityFilterChain oauth2ServerHttpSecurityFilterChain(HttpSecurity http, Customizer<OAuth2LoginConfigurer<HttpSecurity>> oauth2LoginCustomizer) throws Exception {
final OAuth2AuthorizationServerConfigurer<HttpSecurity> authorizationServerConfigurer = new OAuth2AuthorizationServerConfigurer<>();
authorizationServerConfigurer.authorizationEndpoint((authorizationEndpoint) -> {
authorizationEndpoint.authenticationProvider(CustomOAuth2AuthorizationCodeRequestAuthenticationProvider.create(http)).consentPage(OAUTH2_CONSENT_PAGE);
});
final RequestMatcher endpointsMatcher = authorizationServerConfigurer.getEndpointsMatcher();
// This configuration is only for requests matched by the RequestMatcher
// (that is, only OAuth2 AUTHORIZATION requests -> requests where this application acts as a OAuth2 server, not a client)
http.requestMatcher(endpointsMatcher).authorizeRequests((auth) -> auth.anyRequest().authenticated()).csrf((csrf) -> csrf.ignoringRequestMatchers(endpointsMatcher)).oauth2Login(oauth2LoginCustomizer).apply(authorizationServerConfigurer);
return http.build();
}
Aggregations