Java OIOSAML:服务端点设置问题

Java OIOSAML:服务端点设置问题,java,single-sign-on,saml-2.0,shibboleth,opensaml,Java,Single Sign On,Saml 2.0,Shibboleth,Opensaml,我编写了一个简单的系统,其中SP基于。为了测试系统,我在远程主机上部署了它 但是,AssertionConsumerServiceURL,其中我指定了idP(基于Shibboleth的idP)应该返回答案的URL,但没有调用该URL SAMLAssertionConsumer-只是一个简单的servlet,如下所示: @WebServlet("/saml/consumer") public class SAMLAssertionConsumer extends HttpServlet {

我编写了一个简单的系统,其中SP基于。为了测试系统,我在远程主机上部署了它

但是,
AssertionConsumerServiceURL
,其中我指定了idP(基于Shibboleth的idP)应该返回答案的URL,但没有调用该URL

SAMLAssertionConsumer
-只是一个简单的servlet,如下所示:

@WebServlet("/saml/consumer")
public class SAMLAssertionConsumer extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        System.out.println(new Date() + " incoming AuthResponse");
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        out.println("Yes, it worked");

        System.out.println(new Date() + " incoming AuthResponse");
    }
}
首先,我只需要确保得到响应

My web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="3.0"
    metadata-complete="false"     
    xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >

    <display-name>OIOSAML-J</display-name>

    <listener>
        <listener-class>dk.itst.oiosaml.sp.service.session.SessionDestroyListener</listener-class>
    </listener>

    <servlet>
        <servlet-name>SAMLDispatcherServlet</servlet-name>
        <servlet-class>dk.itst.oiosaml.sp.service.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>SAMLDispatcherServlet</servlet-name>
        <url-pattern>/saml/*</url-pattern>
    </servlet-mapping>

    <filter>
        <filter-name>LoginFilter</filter-name>
        <filter-class>dk.itst.oiosaml.sp.service.SPFilter</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>LoginFilter</filter-name>
        <url-pattern>/sp/*</url-pattern>
    </filter-mapping>

    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

</web-app>
生成的
AuthnRequest

<?xml version="1.0" encoding="UTF-8"?>
<saml2p:AuthnRequest xmlns:saml2p="urn:oasis:names:tc:SAML:2.0:protocol"
                     AssertionConsumerServiceURL="http://ip-of-remote-system-here:8080/saml/consumer"
                     Destination="http://ip-of-identity-provider-here/idp/profile/SAML2/Redirect/SSO" ForceAuthn="false"
                     ID="_31e...341d322d1d" IsPassive="false"
                     IssueInstant="2014-07-11T10:24:43.852Z"
                     ProtocolBinding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Version="2.0">
    <saml2:Issuer xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion">http://ip-of-remote-system-here:8080</saml2:Issuer>
</saml2p:AuthnRequest> 
在这个请求之后,我重定向到identity provider的登录页面:

http://ip-of-identity-provider-here/idp/Authn/CommonLogin
输入两个登录名/密码,然后。。没有什么打开包含一些常见错误描述的页面:

http://ip-of-identity-provider-here/idp/Authn/UsernamePasswordLogin
错误

处理请求时出错

不工作,并且我的servlet
SAMLAssertionConsumer
,控制台已清除。但是如果我向servlet
SAMLAssertionConsumer
direct发出请求:

http://ip-of-remote-system-here:8080/saml/consumer
然后它就起作用了。当然

我想知道如何正确配置断言使用者服务。这是SP元数据的一部分,我在其中指定断言使用者

<md:EntityDescriptor xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:esia="urn:esia:shibboleth:2.0:mdext" entityID="http://ip-of-remote-system-here:8080">
...
<md:SingleLogoutService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"  Location="http://ip-of-remote-system-here:8080/saml/consumer" ResponseLocation="http://ip-of-remote-system-here:8080/saml/consumer"/>
<md:AssertionConsumerService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Location="http://ip-of-remote-system-here:8080/saml/consumer" index="0" isDefault="true"/>

...

问题不同。使用了不正确的密钥库。现在一切都好了

最初,我假设
entityID
属性必须引用在attributes
Location
中指定的域名。然而,事实并非如此。它必须是唯一的,最好使用域名

在SAML中使用Shibboleth标识和服务提供者 部署,因此,它们被分配一个唯一的名称,称为 “实体ID”

entityID
[必需]-

 Specifies the unique identifier of the SAML entity whose metadata is 
 described by the element's contents.

强烈建议不要使用服务器的物理主机名 将Shibboleth作为
实体ID运行
。随着时间的推移,事情会发生变化 而且这种部署可能并不总是在同一个盒子上

此外,Shibboleth可能有多个逻辑部署 在单个物理服务器上,每个服务器都需要自己的唯一
entityID
,因此使用服务器名称不会超出单个 一个

在沙箱中可以使用物理地址

<md:EntityDescriptor xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:esia="urn:esia:shibboleth:2.0:mdext" entityID="http://ip-of-remote-system-here:8080">
...
<md:SingleLogoutService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"  Location="http://ip-of-remote-system-here:8080/saml/consumer" ResponseLocation="http://ip-of-remote-system-here:8080/saml/consumer"/>
<md:AssertionConsumerService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Location="http://ip-of-remote-system-here:8080/saml/consumer" index="0" isDefault="true"/>
 Specifies the unique identifier of the SAML entity whose metadata is 
 described by the element's contents.