use of org.springframework.beans.factory.support.BeanDefinitionBuilder in project spring-security-oauth by spring-projects.
the class ProtectedResourceDetailsBeanDefinitionParser method doParse.
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
List consumerElements = DomUtils.getChildElementsByTagName(element, "resource");
for (Object item : consumerElements) {
BeanDefinitionBuilder resource = BeanDefinitionBuilder.rootBeanDefinition(BaseProtectedResourceDetails.class);
Element consumerElement = (Element) item;
String id = consumerElement.getAttribute("id");
if (StringUtils.hasText(id)) {
resource.addPropertyValue("id", id);
} else {
parserContext.getReaderContext().error("A resource id must be supplied with the definition of a protected resource.", consumerElement);
}
String key = consumerElement.getAttribute("key");
if (StringUtils.hasText(key)) {
resource.addPropertyValue("consumerKey", key);
} else {
parserContext.getReaderContext().error("A consumer key must be supplied with the definition of a protected resource.", consumerElement);
}
String secret = consumerElement.getAttribute("secret");
if (StringUtils.hasText(secret)) {
resource.addPropertyValue("sharedSecret", secret);
} else {
parserContext.getReaderContext().error("A shared secret must be supplied with the definition of a resource.", consumerElement);
}
String requestTokenURL = consumerElement.getAttribute("request-token-url");
if (StringUtils.hasText(requestTokenURL)) {
resource.addPropertyValue("requestTokenURL", requestTokenURL);
} else {
parserContext.getReaderContext().error("A request token URL must be supplied with the definition of a resource.", consumerElement);
}
String requestTokenMethod = consumerElement.getAttribute("request-token-method");
if (StringUtils.hasText(requestTokenMethod)) {
resource.addPropertyValue("requestTokenHttpMethod", requestTokenMethod);
}
String accessTokenURL = consumerElement.getAttribute("access-token-url");
if (StringUtils.hasText(accessTokenURL)) {
resource.addPropertyValue("accessTokenURL", accessTokenURL);
} else {
parserContext.getReaderContext().error("An access token URL must be supplied with the definition of a resource.", consumerElement);
}
String accessTokenMethod = consumerElement.getAttribute("access-token-method");
if (StringUtils.hasText(accessTokenMethod)) {
resource.addPropertyValue("accessTokenHttpMethod", accessTokenMethod);
}
String userAuthorizationURL = consumerElement.getAttribute("user-authorization-url");
if (StringUtils.hasText(userAuthorizationURL)) {
resource.addPropertyValue("userAuthorizationURL", userAuthorizationURL);
} else {
parserContext.getReaderContext().error("A user authorization URL must be supplied with the definition of a resource.", consumerElement);
}
String sigMethod = consumerElement.getAttribute("signature-method");
if (!StringUtils.hasText(sigMethod)) {
sigMethod = HMAC_SHA1SignatureMethod.SIGNATURE_NAME;
}
resource.addPropertyValue("signatureMethod", sigMethod);
String acceptsHeader = consumerElement.getAttribute("accepts-authorization-header");
if (StringUtils.hasText(acceptsHeader)) {
resource.addPropertyValue("acceptsAuthorizationHeader", Boolean.valueOf(acceptsHeader));
}
String headerRealm = consumerElement.getAttribute("authorization-header-realm");
if (StringUtils.hasText(headerRealm)) {
resource.addPropertyValue("authorizationHeaderRealm", headerRealm);
}
String use10a = consumerElement.getAttribute("use10a");
if (StringUtils.hasText(use10a)) {
resource.addPropertyValue("use10a", "true".equals(use10a));
}
List additionalParameters = DomUtils.getChildElementsByTagName(consumerElement, "addtionalParameter");
if (additionalParameters != null && !additionalParameters.isEmpty()) {
Map<String, String> additionalParams = new HashMap<String, String>();
for (Object additionalParameter : additionalParameters) {
additionalParams.put(((Element) additionalParameter).getAttribute("name"), ((Element) additionalParameter).getAttribute("value"));
}
resource.addPropertyValue("additionalParameters", additionalParams);
}
List additionalRequestHeaders = DomUtils.getChildElementsByTagName(consumerElement, "additionalRequestHeader");
if (additionalRequestHeaders != null && !additionalRequestHeaders.isEmpty()) {
Map<String, String> headers = new HashMap<String, String>();
for (Object additionalParameter : additionalRequestHeaders) {
headers.put(((Element) additionalParameter).getAttribute("name"), ((Element) additionalParameter).getAttribute("value"));
}
resource.addPropertyValue("additionalRequestHeaders", headers);
}
parserContext.getRegistry().registerBeanDefinition(id, resource.getBeanDefinition());
}
}
use of org.springframework.beans.factory.support.BeanDefinitionBuilder in project spring-security by spring-projects.
the class AuthenticationConfigBuilder method createOpenIDProvider.
private void createOpenIDProvider() {
Element openIDLoginElt = DomUtils.getChildElementByTagName(httpElt, Elements.OPENID_LOGIN);
BeanDefinitionBuilder openIDProviderBuilder = BeanDefinitionBuilder.rootBeanDefinition(OPEN_ID_AUTHENTICATION_PROVIDER_CLASS);
RootBeanDefinition uds = new RootBeanDefinition();
uds.setFactoryBeanName(BeanIds.USER_DETAILS_SERVICE_FACTORY);
uds.setFactoryMethodName("authenticationUserDetailsService");
uds.getConstructorArgumentValues().addGenericArgumentValue(openIDLoginElt.getAttribute(ATT_USER_SERVICE_REF));
openIDProviderBuilder.addPropertyValue("authenticationUserDetailsService", uds);
BeanDefinition openIDProvider = openIDProviderBuilder.getBeanDefinition();
openIDProviderRef = new RuntimeBeanReference(pc.getReaderContext().registerWithGeneratedName(openIDProvider));
}
use of org.springframework.beans.factory.support.BeanDefinitionBuilder in project spring-security-oauth by spring-projects.
the class ResourceBeanDefinitionParser method doParse.
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
String id = element.getAttribute("id");
if (!StringUtils.hasText(id)) {
parserContext.getReaderContext().error("An id must be supplied on a resource element.", element);
}
builder.addPropertyValue("id", id);
String type = element.getAttribute("type");
if (!StringUtils.hasText(type)) {
type = "client_credentials";
}
builder.addPropertyValue("grantType", type);
String accessTokenUri = element.getAttribute("access-token-uri");
if (!StringUtils.hasText(accessTokenUri) && !"implicit".equals(type)) {
parserContext.getReaderContext().error("An accessTokenUri must be supplied on a resource element of type " + type, element);
}
builder.addPropertyValue("accessTokenUri", accessTokenUri);
String clientId = element.getAttribute("client-id");
if (!StringUtils.hasText(clientId)) {
parserContext.getReaderContext().error("An clientId must be supplied on a resource element", element);
}
builder.addPropertyValue("clientId", clientId);
String clientSecret = element.getAttribute("client-secret");
if (StringUtils.hasText(clientSecret)) {
builder.addPropertyValue("clientSecret", clientSecret);
}
String clientAuthenticationScheme = element.getAttribute("client-authentication-scheme");
if (StringUtils.hasText(clientAuthenticationScheme)) {
builder.addPropertyValue("clientAuthenticationScheme", clientAuthenticationScheme);
}
String userAuthorizationUri = element.getAttribute("user-authorization-uri");
if (StringUtils.hasText(userAuthorizationUri)) {
if (needsUserAuthorizationUri(type)) {
builder.addPropertyValue("userAuthorizationUri", userAuthorizationUri);
} else {
parserContext.getReaderContext().error("The " + type + " grant type does not accept an authorization URI", element);
}
} else {
if (needsUserAuthorizationUri(type)) {
parserContext.getReaderContext().error("An authorization URI must be supplied for a resource of type " + type, element);
}
}
String preEstablishedRedirectUri = element.getAttribute("pre-established-redirect-uri");
if (StringUtils.hasText(preEstablishedRedirectUri)) {
builder.addPropertyValue("preEstablishedRedirectUri", preEstablishedRedirectUri);
}
String requireImmediateAuthorization = element.getAttribute("require-immediate-authorization");
if (StringUtils.hasText(requireImmediateAuthorization)) {
builder.addPropertyValue("requireImmediateAuthorization", requireImmediateAuthorization);
}
String useCurrentUri = element.getAttribute("use-current-uri");
if (StringUtils.hasText(useCurrentUri)) {
builder.addPropertyValue("useCurrentUri", useCurrentUri);
}
String scope = element.getAttribute("scope");
if (StringUtils.hasText(scope)) {
BeanDefinitionBuilder scopesBuilder = BeanDefinitionBuilder.genericBeanDefinition(StringListFactoryBean.class);
scopesBuilder.addConstructorArgValue(new TypedStringValue(scope));
builder.addPropertyValue("scope", scopesBuilder.getBeanDefinition());
}
AuthenticationScheme btm = AuthenticationScheme.header;
String bearerTokenMethod = element.getAttribute("authentication-scheme");
if (StringUtils.hasText(bearerTokenMethod)) {
btm = AuthenticationScheme.valueOf(bearerTokenMethod);
}
builder.addPropertyValue("authenticationScheme", btm);
String bearerTokenName = element.getAttribute("token-name");
if (!StringUtils.hasText(bearerTokenName)) {
bearerTokenName = OAuth2AccessToken.ACCESS_TOKEN;
}
builder.addPropertyValue("tokenName", bearerTokenName);
if (type.equals("password")) {
String[] attributeNames = { "username", "password" };
for (String attributeName : attributeNames) {
String attribute = element.getAttribute(attributeName);
if (StringUtils.hasText(attribute)) {
builder.addPropertyValue(attributeName, attribute);
} else {
parserContext.getReaderContext().error("A " + attributeName + " must be supplied on a resource element of type " + type, element);
}
}
}
}
use of org.springframework.beans.factory.support.BeanDefinitionBuilder in project spring-security-oauth by spring-projects.
the class ResourceServerBeanDefinitionParser method parseEndpointAndReturnFilter.
@Override
protected AbstractBeanDefinition parseEndpointAndReturnFilter(Element element, ParserContext parserContext, String tokenServicesRef, String serializerRef) {
String resourceId = element.getAttribute("resource-id");
String entryPointRef = element.getAttribute("entry-point-ref");
String authenticationManagerRef = element.getAttribute("authentication-manager-ref");
String tokenExtractorRef = element.getAttribute("token-extractor-ref");
String entryAuthDetailsSource = element.getAttribute("auth-details-source-ref");
String stateless = element.getAttribute("stateless");
// configure the protected resource filter
BeanDefinitionBuilder protectedResourceFilterBean = BeanDefinitionBuilder.rootBeanDefinition(OAuth2AuthenticationProcessingFilter.class);
if (StringUtils.hasText(authenticationManagerRef)) {
protectedResourceFilterBean.addPropertyReference("authenticationManager", authenticationManagerRef);
} else {
BeanDefinitionBuilder authenticationManagerBean = BeanDefinitionBuilder.rootBeanDefinition(OAuth2AuthenticationManager.class);
authenticationManagerBean.addPropertyReference("tokenServices", tokenServicesRef);
if (StringUtils.hasText(resourceId)) {
authenticationManagerBean.addPropertyValue("resourceId", resourceId);
}
protectedResourceFilterBean.addPropertyValue("authenticationManager", authenticationManagerBean.getBeanDefinition());
}
if (StringUtils.hasText(entryPointRef)) {
protectedResourceFilterBean.addPropertyReference("authenticationEntryPoint", entryPointRef);
}
if (StringUtils.hasText(entryAuthDetailsSource)) {
protectedResourceFilterBean.addPropertyReference("authenticationDetailsSource", entryAuthDetailsSource);
}
if (StringUtils.hasText(tokenExtractorRef)) {
protectedResourceFilterBean.addPropertyReference("tokenExtractor", tokenExtractorRef);
}
if (StringUtils.hasText(stateless)) {
protectedResourceFilterBean.addPropertyValue("stateless", stateless);
}
return protectedResourceFilterBean.getBeanDefinition();
}
use of org.springframework.beans.factory.support.BeanDefinitionBuilder in project spring-security-oauth by spring-projects.
the class AuthorizationServerBeanDefinitionParser method parseEndpointAndReturnFilter.
@Override
protected AbstractBeanDefinition parseEndpointAndReturnFilter(Element element, ParserContext parserContext, String tokenServicesRef, String serializerRef) {
String clientDetailsRef = element.getAttribute("client-details-service-ref");
String oAuth2RequestFactoryRef = element.getAttribute("authorization-request-manager-ref");
String tokenEndpointUrl = element.getAttribute("token-endpoint-url");
String checkTokenUrl = element.getAttribute("check-token-endpoint-url");
String enableCheckToken = element.getAttribute("check-token-enabled");
String authorizationEndpointUrl = element.getAttribute("authorization-endpoint-url");
String tokenGranterRef = element.getAttribute("token-granter-ref");
String redirectStrategyRef = element.getAttribute("redirect-strategy-ref");
String userApprovalHandlerRef = element.getAttribute("user-approval-handler-ref");
String approvalPage = element.getAttribute("user-approval-page");
String errorPage = element.getAttribute("error-page");
String approvalParameter = element.getAttribute("approval-parameter-name");
String redirectResolverRef = element.getAttribute("redirect-resolver-ref");
String oAuth2RequestValidatorRef = element.getAttribute("request-validator-ref");
// Create a bean definition speculatively for the auth endpoint
BeanDefinitionBuilder authorizationEndpointBean = BeanDefinitionBuilder.rootBeanDefinition(AuthorizationEndpoint.class);
if (!StringUtils.hasText(clientDetailsRef)) {
parserContext.getReaderContext().error("ClientDetailsService must be provided", element);
return null;
}
if (!StringUtils.hasText(oAuth2RequestValidatorRef)) {
oAuth2RequestValidatorRef = "defaultOAuth2RequestValidator";
BeanDefinitionBuilder oAuth2RequestValidator = BeanDefinitionBuilder.rootBeanDefinition(DefaultOAuth2RequestValidator.class);
parserContext.getRegistry().registerBeanDefinition(oAuth2RequestValidatorRef, oAuth2RequestValidator.getBeanDefinition());
}
authorizationEndpointBean.addPropertyReference("oAuth2RequestValidator", oAuth2RequestValidatorRef);
if (!StringUtils.hasText(oAuth2RequestFactoryRef)) {
oAuth2RequestFactoryRef = "oAuth2AuthorizationRequestManager";
BeanDefinitionBuilder oAuth2RequestManager = BeanDefinitionBuilder.rootBeanDefinition(DefaultOAuth2RequestFactory.class);
oAuth2RequestManager.addConstructorArgReference(clientDetailsRef);
parserContext.getRegistry().registerBeanDefinition(oAuth2RequestFactoryRef, oAuth2RequestManager.getBeanDefinition());
}
ManagedList<BeanMetadataElement> tokenGranters = null;
if (!StringUtils.hasText(tokenGranterRef)) {
tokenGranterRef = "oauth2TokenGranter";
BeanDefinitionBuilder tokenGranterBean = BeanDefinitionBuilder.rootBeanDefinition(CompositeTokenGranter.class);
parserContext.getRegistry().registerBeanDefinition(tokenGranterRef, tokenGranterBean.getBeanDefinition());
tokenGranters = new ManagedList<BeanMetadataElement>();
tokenGranterBean.addConstructorArgValue(tokenGranters);
}
authorizationEndpointBean.addPropertyReference("tokenGranter", tokenGranterRef);
boolean registerAuthorizationEndpoint = false;
Element authorizationCodeElement = DomUtils.getChildElementByTagName(element, "authorization-code");
if (authorizationCodeElement != null && !"true".equalsIgnoreCase(authorizationCodeElement.getAttribute("disabled"))) {
// authorization code grant configuration.
String authorizationCodeServices = authorizationCodeElement.getAttribute("authorization-code-services-ref");
String clientTokenCacheRef = authorizationCodeElement.getAttribute("client-token-cache-ref");
BeanDefinitionBuilder authorizationCodeTokenGranterBean = BeanDefinitionBuilder.rootBeanDefinition(AuthorizationCodeTokenGranter.class);
if (StringUtils.hasText(tokenServicesRef)) {
authorizationCodeTokenGranterBean.addConstructorArgReference(tokenServicesRef);
}
if (!StringUtils.hasText(authorizationCodeServices)) {
authorizationCodeServices = "oauth2AuthorizationCodeServices";
BeanDefinitionBuilder authorizationCodeServicesBean = BeanDefinitionBuilder.rootBeanDefinition(InMemoryAuthorizationCodeServices.class);
parserContext.getRegistry().registerBeanDefinition(authorizationCodeServices, authorizationCodeServicesBean.getBeanDefinition());
}
authorizationEndpointBean.addPropertyReference("authorizationCodeServices", authorizationCodeServices);
authorizationCodeTokenGranterBean.addConstructorArgReference(authorizationCodeServices);
authorizationCodeTokenGranterBean.addConstructorArgReference(clientDetailsRef);
authorizationCodeTokenGranterBean.addConstructorArgReference(oAuth2RequestFactoryRef);
if (StringUtils.hasText(clientTokenCacheRef)) {
authorizationEndpointBean.addPropertyReference("clientTokenCache", clientTokenCacheRef);
}
if (StringUtils.hasText(oAuth2RequestFactoryRef)) {
authorizationEndpointBean.addPropertyReference("oAuth2RequestFactory", oAuth2RequestFactoryRef);
}
if (tokenGranters != null) {
tokenGranters.add(authorizationCodeTokenGranterBean.getBeanDefinition());
}
// end authorization code provider configuration.
registerAuthorizationEndpoint = true;
}
if (tokenGranters != null) {
Element refreshTokenElement = DomUtils.getChildElementByTagName(element, "refresh-token");
if (refreshTokenElement != null && !"true".equalsIgnoreCase(refreshTokenElement.getAttribute("disabled"))) {
BeanDefinitionBuilder refreshTokenGranterBean = BeanDefinitionBuilder.rootBeanDefinition(RefreshTokenGranter.class);
refreshTokenGranterBean.addConstructorArgReference(tokenServicesRef);
refreshTokenGranterBean.addConstructorArgReference(clientDetailsRef);
refreshTokenGranterBean.addConstructorArgReference(oAuth2RequestFactoryRef);
tokenGranters.add(refreshTokenGranterBean.getBeanDefinition());
}
Element implicitElement = DomUtils.getChildElementByTagName(element, "implicit");
if (implicitElement != null && !"true".equalsIgnoreCase(implicitElement.getAttribute("disabled"))) {
BeanDefinitionBuilder implicitGranterBean = BeanDefinitionBuilder.rootBeanDefinition(ImplicitTokenGranter.class);
implicitGranterBean.addConstructorArgReference(tokenServicesRef);
implicitGranterBean.addConstructorArgReference(clientDetailsRef);
implicitGranterBean.addConstructorArgReference(oAuth2RequestFactoryRef);
tokenGranters.add(implicitGranterBean.getBeanDefinition());
registerAuthorizationEndpoint = true;
}
Element clientCredentialsElement = DomUtils.getChildElementByTagName(element, "client-credentials");
if (clientCredentialsElement != null && !"true".equalsIgnoreCase(clientCredentialsElement.getAttribute("disabled"))) {
BeanDefinitionBuilder clientCredentialsGranterBean = BeanDefinitionBuilder.rootBeanDefinition(ClientCredentialsTokenGranter.class);
clientCredentialsGranterBean.addConstructorArgReference(tokenServicesRef);
clientCredentialsGranterBean.addConstructorArgReference(clientDetailsRef);
clientCredentialsGranterBean.addConstructorArgReference(oAuth2RequestFactoryRef);
tokenGranters.add(clientCredentialsGranterBean.getBeanDefinition());
}
Element clientPasswordElement = DomUtils.getChildElementByTagName(element, "password");
if (clientPasswordElement != null && !"true".equalsIgnoreCase(clientPasswordElement.getAttribute("disabled"))) {
BeanDefinitionBuilder clientPasswordTokenGranter = BeanDefinitionBuilder.rootBeanDefinition(ResourceOwnerPasswordTokenGranter.class);
String authenticationManagerRef = clientPasswordElement.getAttribute("authentication-manager-ref");
if (!StringUtils.hasText(authenticationManagerRef)) {
authenticationManagerRef = BeanIds.AUTHENTICATION_MANAGER;
}
clientPasswordTokenGranter.addConstructorArgReference(authenticationManagerRef);
clientPasswordTokenGranter.addConstructorArgReference(tokenServicesRef);
clientPasswordTokenGranter.addConstructorArgReference(clientDetailsRef);
clientPasswordTokenGranter.addConstructorArgReference(oAuth2RequestFactoryRef);
tokenGranters.add(clientPasswordTokenGranter.getBeanDefinition());
}
List<Element> customGrantElements = DomUtils.getChildElementsByTagName(element, "custom-grant");
for (Element customGrantElement : customGrantElements) {
if (!"true".equalsIgnoreCase(customGrantElement.getAttribute("disabled"))) {
String customGranterRef = customGrantElement.getAttribute("token-granter-ref");
tokenGranters.add(new RuntimeBeanReference(customGranterRef));
}
}
}
if (registerAuthorizationEndpoint) {
BeanDefinitionBuilder approvalEndpointBean = BeanDefinitionBuilder.rootBeanDefinition(WhitelabelApprovalEndpoint.class);
parserContext.getRegistry().registerBeanDefinition("oauth2ApprovalEndpoint", approvalEndpointBean.getBeanDefinition());
if (!StringUtils.hasText(clientDetailsRef)) {
parserContext.getReaderContext().error("A client details service is mandatory", element);
}
if (StringUtils.hasText(redirectStrategyRef)) {
authorizationEndpointBean.addPropertyReference("redirectStrategy", redirectStrategyRef);
}
if (StringUtils.hasText(userApprovalHandlerRef)) {
authorizationEndpointBean.addPropertyReference("userApprovalHandler", userApprovalHandlerRef);
}
authorizationEndpointBean.addPropertyReference("clientDetailsService", clientDetailsRef);
if (StringUtils.hasText(redirectResolverRef)) {
authorizationEndpointBean.addPropertyReference("redirectResolver", redirectResolverRef);
}
if (StringUtils.hasText(approvalPage)) {
authorizationEndpointBean.addPropertyValue("userApprovalPage", approvalPage);
}
if (StringUtils.hasText(errorPage)) {
authorizationEndpointBean.addPropertyValue("errorPage", errorPage);
}
parserContext.getRegistry().registerBeanDefinition("oauth2AuthorizationEndpoint", authorizationEndpointBean.getBeanDefinition());
}
// configure the token endpoint
BeanDefinitionBuilder tokenEndpointBean = BeanDefinitionBuilder.rootBeanDefinition(TokenEndpoint.class);
tokenEndpointBean.addPropertyReference("clientDetailsService", clientDetailsRef);
tokenEndpointBean.addPropertyReference("tokenGranter", tokenGranterRef);
authorizationEndpointBean.addPropertyReference("oAuth2RequestValidator", oAuth2RequestValidatorRef);
parserContext.getRegistry().registerBeanDefinition("oauth2TokenEndpoint", tokenEndpointBean.getBeanDefinition());
if (StringUtils.hasText(oAuth2RequestFactoryRef)) {
tokenEndpointBean.addPropertyReference("oAuth2RequestFactory", oAuth2RequestFactoryRef);
}
if (StringUtils.hasText(oAuth2RequestValidatorRef)) {
tokenEndpointBean.addPropertyReference("oAuth2RequestValidator", oAuth2RequestValidatorRef);
}
// Register a handler mapping that can detect the auth server endpoints
BeanDefinitionBuilder handlerMappingBean = BeanDefinitionBuilder.rootBeanDefinition(FrameworkEndpointHandlerMapping.class);
ManagedMap<String, TypedStringValue> mappings = new ManagedMap<String, TypedStringValue>();
if (StringUtils.hasText(tokenEndpointUrl) || StringUtils.hasText(authorizationEndpointUrl)) {
if (StringUtils.hasText(tokenEndpointUrl)) {
mappings.put("/oauth/token", new TypedStringValue(tokenEndpointUrl, String.class));
}
if (StringUtils.hasText(authorizationEndpointUrl)) {
mappings.put("/oauth/authorize", new TypedStringValue(authorizationEndpointUrl, String.class));
}
if (StringUtils.hasText(approvalPage)) {
mappings.put("/oauth/confirm_access", new TypedStringValue(approvalPage, String.class));
}
}
if (StringUtils.hasText(enableCheckToken) && enableCheckToken.equals("true")) {
// configure the check token endpoint
BeanDefinitionBuilder checkTokenEndpointBean = BeanDefinitionBuilder.rootBeanDefinition(CheckTokenEndpoint.class);
checkTokenEndpointBean.addConstructorArgReference(tokenServicesRef);
parserContext.getRegistry().registerBeanDefinition("oauth2CheckTokenEndpoint", checkTokenEndpointBean.getBeanDefinition());
if (StringUtils.hasText(checkTokenUrl)) {
mappings.put("/oauth/check_token", new TypedStringValue(checkTokenUrl, String.class));
}
}
if (!mappings.isEmpty()) {
handlerMappingBean.addPropertyValue("mappings", mappings);
}
if (StringUtils.hasText(approvalParameter) && registerAuthorizationEndpoint) {
if (!StringUtils.hasText(userApprovalHandlerRef)) {
BeanDefinitionBuilder userApprovalHandler = BeanDefinitionBuilder.rootBeanDefinition(DefaultUserApprovalHandler.class);
userApprovalHandler.addPropertyValue("approvalParameter", new TypedStringValue(approvalParameter, String.class));
authorizationEndpointBean.addPropertyValue("userApprovalHandler", userApprovalHandler.getBeanDefinition());
}
handlerMappingBean.addPropertyValue("approvalParameter", approvalParameter);
}
parserContext.getRegistry().registerBeanDefinition("oauth2HandlerMapping", handlerMappingBean.getBeanDefinition());
// We aren't defining a filter...
return null;
}
Aggregations