Polish OAuth2Configurer
This commit is contained in:
parent
3573167d77
commit
6081451fa3
|
@ -1000,7 +1000,9 @@ public final class HttpSecurity extends
|
|||
* @throws Exception
|
||||
*/
|
||||
public OAuth2Configurer<HttpSecurity> oauth2() throws Exception {
|
||||
return getOrApply(new OAuth2Configurer<>());
|
||||
OAuth2Configurer<HttpSecurity> configurer = getOrApply(new OAuth2Configurer<>());
|
||||
this.postProcess(configurer);
|
||||
return configurer;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
package org.springframework.security.config.annotation.web.configurers.oauth2;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.config.annotation.ObjectPostProcessor;
|
||||
import org.springframework.security.config.annotation.web.HttpSecurityBuilder;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
|
@ -34,49 +35,40 @@ import org.springframework.security.config.annotation.web.configurers.oauth2.cli
|
|||
public final class OAuth2Configurer<B extends HttpSecurityBuilder<B>>
|
||||
extends AbstractHttpConfigurer<OAuth2Configurer<B>, B> {
|
||||
|
||||
private final OAuth2ClientConfigurer<B> clientConfigurer = new OAuth2ClientConfigurer<>();
|
||||
private boolean clientEnabled;
|
||||
@Autowired
|
||||
private ObjectPostProcessor<Object> objectPostProcessor;
|
||||
|
||||
private OAuth2ClientConfigurer<B> clientConfigurer;
|
||||
|
||||
/**
|
||||
* Returns the {@link OAuth2ClientConfigurer} for configuring OAuth 2.0 Client support.
|
||||
*
|
||||
* @return the {@link OAuth2ClientConfigurer}
|
||||
* @throws Exception
|
||||
*/
|
||||
public OAuth2ClientConfigurer<B> client() throws Exception {
|
||||
this.clientEnabled = true;
|
||||
public OAuth2ClientConfigurer<B> client() {
|
||||
if (this.clientConfigurer == null) {
|
||||
this.initClientConfigurer();
|
||||
}
|
||||
return this.clientConfigurer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(B builder) throws Exception {
|
||||
if (this.clientEnabled) {
|
||||
if (this.clientConfigurer != null) {
|
||||
this.clientConfigurer.init(builder);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure(B builder) throws Exception {
|
||||
if (this.clientEnabled) {
|
||||
if (this.clientConfigurer != null) {
|
||||
this.clientConfigurer.configure(builder);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBuilder(B builder) {
|
||||
this.clientConfigurer.setBuilder(builder);
|
||||
super.setBuilder(builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addObjectPostProcessor(ObjectPostProcessor<?> objectPostProcessor) {
|
||||
this.clientConfigurer.addObjectPostProcessor(objectPostProcessor);
|
||||
super.addObjectPostProcessor(objectPostProcessor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OAuth2Configurer<B> withObjectPostProcessor(ObjectPostProcessor<?> objectPostProcessor) {
|
||||
this.clientConfigurer.withObjectPostProcessor(objectPostProcessor);
|
||||
return super.withObjectPostProcessor(objectPostProcessor);
|
||||
private void initClientConfigurer() {
|
||||
this.clientConfigurer = new OAuth2ClientConfigurer<>();
|
||||
this.clientConfigurer.setBuilder(this.getBuilder());
|
||||
this.clientConfigurer.addObjectPostProcessor(this.objectPostProcessor);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue