Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6871381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:47:56+00:00 2026-05-27T03:47:56+00:00

I am trying to set up a spring 3 webapp to act as a

  • 0

I am trying to set up a spring 3 webapp to act as a proxy for another app that serves protected resource with oauth2.

We’re using the UsernamePassword grant type.
My app should not know about the user database ; actually it will query the other app to get the details about the users (which permissions they have, amoung other things).

My app is responsible for displaying the login page.

I want to use a custom spring-security AuthenticationProvider that would :

  • connect to the oauth server to obtain an access token
  • then use an OAuth2RestTemplate to query the user that tries to login, in order to get its GrantedAuthorities, and other details
  • build a UserDetails out of this. (My AuthenticationProvider would extends AbstractUserDetailsAuthenticationProvider)

The problem is :

  • since I’m using to configure my spring app, spring adds an OAuth2ClientSecurityContextFilter to the filter chain
  • when the ‘retrieveUser’ method of my AuthenticationProvider class is called, this filter has not been passed through yet
  • so if I try using the OAuth2RestTemplate inside my overriden ‘retrieveUser’ method, I get an exception :

    java.lang.IllegalStateException: No OAuth 2 security context has been established. Unable to access resource ‘avop-services’.
    at org.springframework.security.oauth2.consumer.OAuth2ClientHttpRequestFactory.createRequest(OAuth2ClientHttpRequestFactory.java:38)
    at org.springframework.http.client.support.HttpAccessor.createRequest(HttpAccessor.java:76)
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:434)
    at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:401)
    .. etc ..

(I’m linking this to the OAuth2ClientSecurityContextFilter because of this topic : http://forum.springsource.org/showthread.php?98141-error-No-OAuth-2-security-context-has-been-established )

So my question is :

  • does it make sense to have the AuthenticationProvider fire up after some other filters have played ?
  • if so, it is possible to control the order of filters ?
  • or is there a way to delay the computing of the UserDetails to later in the filter chain ?

I know this is probably a very specific case, but I’m wondering if I am attacking it the right way or if I am missing something.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T03:47:57+00:00Added an answer on May 27, 2026 at 3:47 am

    The solution was to use add a filter at the right-position.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Spring 3, and trying to set up a simple web-app using annotations
I'm trying to set up a Spring JPA Hibernate simple example WAR for deployment
Following the spring-security documentation: http://static.springsource.org/spring-security/site/docs/3.0.x/reference/ldap.html I am trying to set up ldap authentication (very
Trying to set up caching on our datasets - we're using clr stored procedures
I have a Spring/Hibernate webapp that has some integration tests that run on an
I am working on a webapp that uses both the Spring Framework and RESTEasy.
I have a web app with a form that I am trying to pass
I'm trying to set up a Spring configuration with tutorials and some stuff. It
I'm currently trying to get Freemarker to work with my application using Spring. No
Trying to set up a new spring project and im having this issue where

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.