Hi Dave,
I do not see any possibility of creating two instances of TokenEndpoint as I have observed it while debugging my code.
Below is my security configuration:
Code:
<http access-decision-manager-ref="accessDecisionManager" xmlns="http://www.springframework.org/schema/security">
<intercept-url pattern="/photos.web" access="ROLE_USERS,SCOPE_READ" />
<intercept-url pattern="/photos.web/**" access="ROLE_USERS,SCOPE_READ" />
<intercept-url pattern="/trusted/**" access="ROLE_USERS,SCOPE_TRUST" />
<intercept-url pattern="/oauth/token" access="IS_AUTHENTICATED_ANONYMOUSLY" />
<intercept-url pattern="/oauth/**" access="ROLE_USERS" />
<intercept-url pattern="/**" access="IS_AUTHENTICATED_ANONYMOUSLY,DENY_OAUTH" />
<access-denied-handler ref="accessDeniedHandler"/>
<form-login default-target-url="/busiLogin.web" authentication-failure-url="/error.jsp" login-page="/index.jsp"/>
<remember-me/>
<custom-filter ref="oauth2ProviderFilter" after="EXCEPTION_TRANSLATION_FILTER" />
</http>
<bean id="accessDecisionManager" class="org.springframework.security.access.vote.UnanimousBased" xmlns="http://www.springframework.org/schema/beans">
<property name="decisionVoters">
<list>
<bean class="org.springframework.security.oauth2.provider.vote.ScopeVoter" />
<bean class="org.springframework.security.access.vote.RoleVoter" />
<bean class="org.springframework.security.access.vote.AuthenticatedVoter" />
</list>
</property>
</bean>
<bean class="org.springframework.security.web.access.expression.DefaultWebSecurityExpressionHandler"/>
<authentication-manager xmlns="http://www.springframework.org/schema/security">
<authentication-provider>
<password-encoder ref="passwordEncoder"/>
<jdbc-user-service data-source-ref="dataSource"
users-by-username-query="
select user_name,password,login_valid
from users where user_name=?"
authorities-by-username-query="
select u.user_name, concat('ROLE_', upper(replace(trim(bp.name), ' ', '_'))) from users u, permissions bp
where u.user_id = bp.user_id and u.user_name =? "
/>
</authentication-provider>
</authentication-manager>
<bean id="tokenServices" class="com.services.JdbcCustOAuth2ProviderTokenServices">
<constructor-arg><ref bean="dataSource"/></constructor-arg>
</bean>
<oauth:provider id="oauth2ProviderFilter" client-details-service-ref="appConsumerDetailsService" token-services-ref="tokenServices">
<oauth:authorization-code/>
</oauth:provider>
<bean id="appConsumerDetailsService" class="com.services.AppConsumerDetailsService">
<constructor-arg><ref bean="sessionFactory"/></constructor-arg>
</bean>
<sec:global-method-security pre-post-annotations="enabled" proxy-target-class="true">
<!--you could also wire in the expression handler up at the layer of the http filters. See https://jira.springsource.org/browse/SEC-1452 -->
<sec:expression-handler ref="oauthExpressionHandler" />
</sec:global-method-security>
<oauth:expression-handler id="oauthExpressionHandler" />
<bean id="accessConfirmationController" class="com.annotations.AccessConfirmationController">
<property name="clientDetailsService" ref="appConsumerDetailsService" />
</bean>
We have used Controllers with and without annotations in out project so we have specified the following in our application context
Code:
<context:component-scan base-package="org.springframework.security.oauth2.provider.endpoint" />
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>
<bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter"/>
and the following url patterns in web.xml
Code:
<servlet-mapping>
<servlet-name>SpringAction</servlet-name>
<url-pattern>*.web</url-pattern>
<url-pattern>/oauth/authorize</url-pattern>
<url-pattern>/oauth/confirm_access</url-pattern>
<url-pattern>/oauth/token</url-pattern>
</servlet-mapping>
Thanks,
Sweta