小编Ver*_*gen的帖子

没有适用于oauth2提供程序端点的处理程序错误的适配器

我想为我的Spring 3.1和RESTEasy项目实现OAuth 2.0 .该项目是基于JSON的REST服务.我使用Spring Security 3.1和spring-security-oauth2版本1.0.0.RC2(应该是最新版本).到目前为止,我有弹簧安全设置默认设置.我还有OAuth 2.0的基本(默认)配置.

我之前使用过REST服务,它完美无缺.Spring安全性似乎也运行得很好.如果我打开到我的REST服务的链接,我将被重定向到登录页面.登录后,我可以进行REST调用,以获得预期的结果.

当我打开het url localhost:8080/tools-service/oauth/token或者localhost:8080/tools-service/oauth/error为了测试OAuth时,我收到错误500.当我访问时会显示以下错误/oauth/token.错误/oauth/error是类似的.

HTTP Status 500 - No adapter for handler [public org.springframework.http.ResponseEntity org.springframework.security.oauth2.provider.endpoint.TokenEndpoint.getAccessToken(java.security.Principal,java.lang.String,java.util.Map)]: Does your handler implement a supported interface like Controller?

如果我是正确的,这意味着TokenEndpoint.getAccessToken函数中有错误?由于该类是Spring框架的一部分(我查找了代码,看起来很好),我不认为问题实际上与这些类有关.这让我一无所知.

现在我想知道为什么会发生这种情况以及如何解决这个问题.我考虑过,我可能不允许在浏览器中访问这些URL.但是,如果我尝试使用Sparklr2(Spring OAuth 2.0示例应用程序),我会得到一条XML消息(对于/ oauth2/token)和一个错误页面(对于/ oauth2/error),这是预期的.

任何帮助或提示将不胜感激.


web.xml中与安全性相关的代码段:

<filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>springSecurityFilterChain</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
Run Code Online (Sandbox Code Playgroud)

我的应用程序上下文加载了我创建的以下security-config.xml文件:

<?xml version="1.0" encoding="UTF-8"?>

<beans
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:sec="http://www.springframework.org/schema/security"
    xmlns:oauth="http://www.springframework.org/schema/security/oauth2"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
                        http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
                        http://www.springframework.org/schema/security
                        http://www.springframework.org/schema/security/spring-security-3.1.xsd
                        http://www.springframework.org/schema/security/oauth2
                        http://www.springframework.org/schema/security/spring-security-oauth2.xsd">

    <sec:http auto-config="true">
        <sec:intercept-url pattern="/**" access="ROLE_USER" …
Run Code Online (Sandbox Code Playgroud)

spring-security resteasy oauth-provider oauth-2.0

5
推荐指数
1
解决办法
4340
查看次数