You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by bob45 <fu...@gmx.de> on 2014/03/14 16:42:40 UTC

WebServiceContext always null for SAML

Hi,

I have a web service that receives a SAML Token issued by an STS.
The web service has the property:

@Resource
WebServiceContext context;

When the web service is called with a valid SAML token, the service
operation is executed and the context is set. But context.getUserPrincipal()
returns null.
I expected it to contain the subject from the SAML Token.

Am I wrong or do I have to do something special to to get the principal?



--
View this message in context: http://cxf.547215.n5.nabble.com/WebServiceContext-always-null-for-SAML-tp5741327.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: WebServiceContext always null for SAML

Posted by bob45 <fu...@gmx.de>.
I updated to JBoss Wildfly which includes CXF 2.7.7.
Now it works!

Thank you very much.



--
View this message in context: http://cxf.547215.n5.nabble.com/WebServiceContext-always-null-for-SAML-tp5741327p5741443.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: WebServiceContext always null for SAML

Posted by Colm O hEigeartaigh <co...@apache.org>.
CXF 2.6.6 is quite old. Could you try with a newer version to see if it is
fixed? I tried with the latest trunk code and the user principal is correct.

Colm.


On Fri, Mar 14, 2014 at 4:03 PM, bob45 <fu...@gmx.de> wrote:

> I am using CXF 2.6.6.
>
> The service is implemented as follows:
>
> @WebServlet(name="test", urlPatterns={"/test"})
> @InInterceptors
> (interceptors={"org.apache.cxf.interceptor.LoggingInInterceptor"})
> @OutInterceptors
> (interceptors={"org.apache.cxf.interceptor.LoggingOutInterceptor"})
> @EndpointProperties(value = {
>                 @EndpointProperty(key =
> "ws-security.encryption.properties.sct", value =
> "keystore.properties"),
>                 @EndpointProperty(key =
> "ws-security.encryption.username.sct", value =
> "cert"),
>                 @EndpointProperty(key =
> "ws-security.callback-handler.sct", value =
> "test.CallbackHandler"),
> })
> @WebService(targetNamespace="http://www.test.net/namespace",
>             serviceName="TestService",
>             portName="TestPort",
>             wsdlLocation="WEB-INF/classes/schemas/TestService.wsdl")
> public class TestServiceImpl implements TestServicePortType {
>
>         @Resource
>         WebServiceContext context;
>
>   @Override
>         public TestResponse test(TestRequest request) throws TestException
> {
>                 Principal p = context.getUserPrincipal();
>                            // Always null
>   }
>
> }
>
>
>
>
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/WebServiceContext-always-null-for-SAML-tp5741327p5741329.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>



-- 
Colm O hEigeartaigh

Talend Community Coder
http://coders.talend.com

Re: WebServiceContext always null for SAML

Posted by bob45 <fu...@gmx.de>.
I am using CXF 2.6.6.

The service is implemented as follows:

@WebServlet(name="test", urlPatterns={"/test"})
@InInterceptors
(interceptors={"org.apache.cxf.interceptor.LoggingInInterceptor"})
@OutInterceptors
(interceptors={"org.apache.cxf.interceptor.LoggingOutInterceptor"})
@EndpointProperties(value = {
		@EndpointProperty(key = "ws-security.encryption.properties.sct", value =
"keystore.properties"),
		@EndpointProperty(key = "ws-security.encryption.username.sct", value =
"cert"),
		@EndpointProperty(key = "ws-security.callback-handler.sct", value =
"test.CallbackHandler"),
})
@WebService(targetNamespace="http://www.test.net/namespace",
            serviceName="TestService",
            portName="TestPort",
            wsdlLocation="WEB-INF/classes/schemas/TestService.wsdl")
public class TestServiceImpl implements TestServicePortType {

	@Resource
	WebServiceContext context;

  @Override
	public TestResponse test(TestRequest request) throws TestException {
		Principal p = context.getUserPrincipal();
                           // Always null
  }  
  
}




--
View this message in context: http://cxf.547215.n5.nabble.com/WebServiceContext-always-null-for-SAML-tp5741327p5741329.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: WebServiceContext always null for SAML

Posted by Colm O hEigeartaigh <co...@apache.org>.
It should contain the subject from the SAML Token. What does your
configuration for the service look like? And what version of CXF are you
using?

Colm.


On Fri, Mar 14, 2014 at 3:42 PM, bob45 <fu...@gmx.de> wrote:

> Hi,
>
> I have a web service that receives a SAML Token issued by an STS.
> The web service has the property:
>
> @Resource
> WebServiceContext context;
>
> When the web service is called with a valid SAML token, the service
> operation is executed and the context is set. But
> context.getUserPrincipal()
> returns null.
> I expected it to contain the subject from the SAML Token.
>
> Am I wrong or do I have to do something special to to get the principal?
>
>
>
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/WebServiceContext-always-null-for-SAML-tp5741327.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>



-- 
Colm O hEigeartaigh

Talend Community Coder
http://coders.talend.com