"URI must not be null", on oauth implemantation

Viewed 4004

The Project had implement Oauth based authentication using resource server. It throws error URI NULL even after passing a url. This is the resource server configuration Im using.

@Configuration
@EnableResourceServer
public class ResourceServerConfiguration extends
        ResourceServerConfigurerAdapter {


     @Autowired
     private AuthenticationEntryPoint customAuthenticationEntryPoint;

    private CheckTokenEndpoint point;

    @Autowired
    Environment env;

    @Bean
    public PasswordEncoder passwordEncoder() {
        return new BCryptPasswordEncoder();
    }


    @Override
    public void configure(HttpSecurity httpSecurity) throws Exception {
        httpSecurity.exceptionHandling()
        .authenticationEntryPoint(customAuthenticationEntryPoint)
        .and()
        .sessionManagement()
        .sessionCreationPolicy(SessionCreationPolicy.STATELESS)
        .and().authorizeRequests()
         .antMatchers(HttpMethod.OPTIONS, "/**").permitAll()
         .antMatchers(HttpMethod.GET, "/","/node_modules/**", "/assets/**","/app/**").permitAll()
         .antMatchers(HttpMethod.GET, "/system-config.js","/init.js","/index.html").permitAll()
       //  .antMatchers(HttpMethod.GET, "/**").permitAll()
      //   .antMatchers(HttpMethod.GET, "/authenticate").permitAll()
         .anyRequest().authenticated()
         .and()
         .formLogin().permitAll();

        httpSecurity.addFilterBefore(getOAuth2AuthenticationProcessingFilter(), UsernamePasswordAuthenticationFilter.class);
        httpSecurity.headers().cacheControl();
    }


    private OAuth2AuthenticationProcessingFilter getOAuth2AuthenticationProcessingFilter() {
        BearerTokenExtractor tokenExtractor = new BearerTokenExtractor();
        OAuth2AuthenticationManager manager = new OAuth2AuthenticationManager();
        manager.setTokenServices(tokenService());
        OAuth2AuthenticationProcessingFilter filter = new OAuth2AuthenticationProcessingFilter();
        filter.setTokenExtractor(tokenExtractor);
        filter.setAuthenticationManager(manager);
        return filter;

    }


    @Bean
    @Primary
    public ResourceServerTokenServices tokenService() {
        RemoteTokenServices tokenServices = new RemoteTokenServices();
        tokenServices.setClientId(env.getProperty("oauth.clientid"));
        tokenServices.setClientSecret(env.getProperty("oauth.clientsecret"));
        tokenServices.setCheckTokenEndpointUrl(env.getProperty("oauth.token.url"));
        return tokenServices;
    }
}

While accessing the service http://localhost:9190/irs/categoryMas using valid token

Header

Authorization   Bearer  bca03ed4-4608-499d-a3fe-60e6e671dea6

service returns error :

{
    "timestamp": 1505805120134,
    "status": 500,
    "error": "Internal Server Error",
    "exception": "java.lang.IllegalArgumentException",
    "message": "URI must not be null",
    "path": "/irs/categoryMast"
}

On debugging uriTemplate is null. How can I solve this ?

Let me know if you need any more details.

0 Answers
Related