我正在尝试在JBoss Fuse中部署SAML安全服务。我已经查阅了这个链接 - http://cxf.apache.org/docs/jax-rs-saml.html#JAX-RSSAML-SAMLAssertionValidation。
我想使用Authorization标头选项,因此已经配置了服务器和客户端,如下所示。我总是得到例外和#34;断言无法验证"。
服务器日志 - >
地址:http:// .... Http-Method:GET 内容类型: /
2015-10-19 16:52:14,536 |警告| p1930854886-1149 | AbstractSamlInHandler | 849 - org.apache.cxf.cxf-rt-rs-security-xml - 3.0.4.redhat-620123 |断言必须签名 2015-10-19 16:52:14,536 |警告| p1930854886-1149 | AbstractSamlInHandler | 849 - org.apache.cxf.cxf-rt-rs-security-xml - 3.0.4.redhat-620123 |断言无法验证 2015-10-19 16:52:14,536 |警告| p1930854886-1149 | WebApplicationExceptionMapper | 128 - org.apache.cxf.cxf-rt-frontend-jaxrs - 3.0.4.redhat-620123 | javax.ws.rs.NotAuthorizedException:HTTP 401未经授权 at org.apache.cxf.jaxrs.utils.SpecExceptions.toNotAuthorizedException(SpecExceptions.java:94) at org.apache.cxf.jaxrs.utils.ExceptionUtils.toNotAuthorizedException(ExceptionUtils.java:134) 在org.apache.cxf.rs.security.saml.AbstractSamlInHandler.throwFault(AbstractSamlInHandler.java:243) at org.apache.cxf.rs.security.saml.AbstractSamlInHandler.validateToken(AbstractSamlInHandler.java:181) 在org.apache.cxf.rs.security.saml.AbstractSamlInHandler.validateToken(AbstractSamlInHandler.java:115) at org.apache.cxf.rs.security.saml.AbstractSamlInHandler.validateToken(AbstractSamlInHandler.java:98) at org.apache.cxf.rs.security.saml.AbstractSamlBase64InHandler.handleToken(AbstractSamlBase64InHandler.java:53) 在org.apache.cxf.rs.security.saml.SamlHeaderInHandler.filter(SamlHeaderInHandler.java:52) 在org.apache.cxf.jaxrs.utils.JAXRSUtils.runContainerRequestFilters(JAXRSUtils.java:1647) 在org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSInInterceptor.java:106) at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInInterceptor.java:77) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307) at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121) at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:251) 在org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:234) 在org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208) 在org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:160) at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:171) at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:293) at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:217) 在javax.servlet.http.HttpServlet.service(HttpServlet.java:575) at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:268) 在org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:684) 在org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:503) 在org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:69) 在org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137) 在org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:533) 在org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086) 在org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:240) 在org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:429) 在org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193) 在org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020) 在org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135) 在org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:75) 在org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116) 在org.eclipse.jetty.server.Server.handle(Server.java:370) at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:494) at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:971) at org.eclipse.jetty.server.AbstractHttpConnection $ RequestHandler.headerComplete(AbstractHttpConnection.java:1033) 在org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:644) 在org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235) at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82) 在org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:696) 在org.eclipse.jetty.io.nio.SelectChannelEndPoint $ 1.run(SelectChannelEndPoint.java:53) 在org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608) 在org.eclipse.jetty.util.thread.QueuedThreadPool $ 3.run(QueuedThreadPool.java:543) 在java.lang.Thread.run(Thread.java:745)
服务器 - >
<jaxrs:server id="service111" address="/saml/test">
<jaxrs:serviceBeans>
<ref component-id="serviceBean"/>
</jaxrs:serviceBeans>
<jaxrs:features>
<bean class="org.apache.cxf.jaxrs.swagger.SwaggerFeature"/>
</jaxrs:features>
<jaxrs:providers>
<ref component-id="jaxbProvider" />
<ref component-id="jsonProvider" />
<!-- SAML -->
<ref component-id="samlHandler"/>
</jaxrs:providers>
<!-- SAML -->
<jaxrs:properties>
<entry key="ws-security.signature.properties" value="alice.properties"/>
</jaxrs:properties>
</jaxrs:server>
<!-- SAML -->
<!-- Authorization Header -->
<bean id="samlHandler" class="org.apache.cxf.rs.security.saml.SamlHeaderInHandler"/>
客户端代码 - &gt;
公共类JavaTestAPI {
/*
* SAML
*/
private WebClient createWebClient(String address) {
JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
bean.setAddress(address);
Map<String, Object> properties = new HashMap<String, Object>();
/*properties.put("ws-security.callback-handler", "org.apache.cxf.systest.jaxrs.security.saml.KeystorePasswordCallback");
properties.put("ws-security.saml-callback-handler", "org.apache.cxf.systest.jaxrs.security.saml.SamlCallbackHandler");
*/
properties.put("ws-security.callback-handler", "org.rest.test.saml.KeystorePasswordCallback");
properties.put("ws-security.saml-callback-handler", "org.rest.test.saml.SamlCallbackHandler");
properties.put("ws-security.signature.username", "alice");
properties.put("ws-security.signature.properties", "alice.properties");
properties.put("ws-security.self-sign-saml-assertion", "true");
bean.setProperties(properties);
bean.getOutInterceptors().add(new SamlHeaderOutInterceptor());
return bean.createWebClient();
}
public static void main(String[] args) {
JavaTestSolrAPI test = new JavaTestAPI();
String address = "http://localhost:8181/cxf/saml/test/1.0.0?codes=usa,ger&format=json";
System.out.println("before createWebClient..");
WebClient wc = test.createWebClient(address);
System.out.println("wc=" + wc);
Response resp = wc.get();
System.out.println("after response=" + resp.getStatus());
System.out.println("response=" + resp.readEntity(String.class));
}
}
答案 0 :(得分:0)
我不确定它是否是您问题的根源,但看起来您回复的断言声明尚未签署。