You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by contactreji <co...@gmail.com> on 2013/08/27 21:00:43 UTC

Re: camel-cxf and HTTP BASIC authentication

Hi Christian.. did you get a work around the problem?



--
View this message in context: http://camel.465427.n5.nabble.com/camel-cxf-and-HTTP-BASIC-authentication-tp5716163p5738071.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: camel-cxf and HTTP BASIC authentication

Posted by Christian Müller <ch...@gmail.com>.
${fromCxfEndpointUri.port} is resolved with the port number this service is
using.

Regarding your issue: org.xml.sax.SAXParseException:
cvc-datatype-valid.1.2.3: '{
http://es0sreao:8181/mes/bw/MEStoBW_CopperRecoveryPercentage_JAAS}.8181' is
not a valid value of union type 'ParameterizedInt'.

use <httpj:engine port="8181">

instead of <httpj:engine port="{
http://es0sreao:8181/mes/bw/Service_Endpoint}.8181">


And as Claus said, you should make sure you use the same Jetty version as
your Karaf/ServiceMix/Camel. You may have to change the package names, if
they are renamed in a newer version. My code is working with Camel 2.8.x
(which is using Jetty 7.4.x) in ServiceMix 4.4.x (which is using Karaf
2.2.x).

Best,
Christian
-----------------

Software Integration Specialist

Apache Camel committer: https://camel.apache.org/team
V.P. Apache Camel: https://www.apache.org/foundation/
Apache Member: https://www.apache.org/foundation/members.html

https://www.linkedin.com/pub/christian-mueller/11/551/642


On Thu, Sep 5, 2013 at 8:44 AM, contactreji <co...@gmail.com> wrote:

> Hi Christian
>
> I have followed your steps and made my coade as follows
>
> *
>         <cxf:cxfEndpoint id="MESEndpoint"
>                 address="http://server:8181/mes/bw/Service_Endpoint"
>
> serviceClass="company.pi.mes.id56.copperrecovery.ImplementationClass"
>                 wsdlURL="wsdl/myWSDL.wsdl"
>                 serviceName="p1:ServiceClasses"
> endpointName="p1:HTTPS_Port"
>                 xmlns:p1="urn:company:pi:mes:id56:Task"
>              xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" />
>
>
>
>         <httpj:engine-factory>
>                 <httpj:engine
>                         port="{
> http://es0sreao:8181/mes/bw/Service_Endpoint}.8181">
>                         <httpj:tlsServerParameters>
>                                 <sec:keyManagers keyPassword="fuseesb">
>                                         <sec:keyStore type="JKS"
> password="fuseesb"
>
> file="certs/truststore.jks" />
>                                 </sec:keyManagers>
>                                 <sec:trustManagers>
>                                         <sec:keyStore type="JKS"
> password="fuseesb"
>
> file="certs/truststore.jks" />
>                                 </sec:trustManagers>
>                                 <sec:cipherSuitesFilter>
>                                         <sec:include>.*.*</sec:include>
>                                         <sec:exclude>.*40_.*</sec:exclude>
>
> <sec:exclude>.*_RSA_WITH_DES_CBC_SHA.*</sec:exclude>
>
> <sec:exclude>.*_RSA_WITH_3DES_EDE_CBC_SHA.*</sec:exclude>
>                                 </sec:cipherSuitesFilter>
>                                 <sec:clientAuthentication want="false"
>                                         required="false" />
>                         </httpj:tlsServerParameters>
>                         <httpj:threadingParameters minThreads="5"
>                                 maxThreads="20" />
>                         <httpj:handlers>
>
>                                 <ref bean="securityHandler" />
>                         </httpj:handlers>
>                 </httpj:engine>
>         </httpj:engine-factory>
>
>         <bean id="securityHandler"
> class="org.eclipse.jetty.security.ConstraintSecurityHandler">
>                 <property name="authenticator">
>                         <bean
> class="org.eclipse.jetty.security.authentication.BasicAuthenticator" />
>                 </property>
>                 <property name="constraintMappings">
>                         <list>
>                                 <bean
> class="org.eclipse.jetty.security.ConstraintMapping">
>                                         <property name="constraint">
>                                                 <bean
> class="org.eclipse.jetty.http.security.Constraint">
>                                                         <property
> name="name" value="BASIC" />
>                                                         <property
> name="roles" value="our-role-name" />
>                                                         <property
> name="authenticate" value="true" />
>                                                 </bean>
>                                         </property>
>                                         <property name="pathSpec"
> value="/*" />
>                                 </bean>
>                         </list>
>                 </property>
>                 <property name="loginService">
>                         <bean
> class="org.eclipse.jetty.plus.jaas.JAASLoginService">
>                                 <property name="name" value="karaf" />
>                                 <property name="loginModuleName"
> value="karaf" />
>                                 <property name="roleClassNames">
>                                         <list>
>
>
> <value>org.apache.karaf.jaas.modules.RolePrincipal</value>
>                                         </list>
>                                 </property>
>                         </bean>
>                 </property>
>                 <property name="strict" value="false" />
>                 <property name="identityService">
>                         <bean
> class="org.eclipse.jetty.security.DefaultIdentityService" />
>                 </property>
>         </bean>*
>
>
> While deployment I am getting following exception in log
>
> *
> 09:34:15,721 | INFO  | xtenderThread-36 | XmlBeanDefinitionReader
>  |
> 105 - org.springframework.beans - 3.0.7.RELEASE | Loading XML bean
> definitions from URL [bundle://324.0:0/META-INF/spring/camel-cxf.xml]
> 09:34:15,741 | ERROR | xtenderThread-36 | ContextLoaderListener
>  |
> 113 - org.springframework.osgi.extender - 1.2.1 | Application context
> refresh failed
>
> (OsgiBundleXmlApplicationContext(bundle=com.outotec.mes-bw-copper_recovery_perc_ssl,
> config=osgibundle:/META-INF/spring/*.xml))
> org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line
> 39 in XML document from URL
> [bundle://324.0:0/META-INF/spring/camel-cxf.xml]
> is invalid; nested exception is org.xml.sax.SAXParseException:
> cvc-datatype-valid.1.2.3:
> '{http://es0sreao:8181/mes/bw/MEStoBW_CopperRecoveryPercentage_JAAS}.8181'
> is not a valid value of union type 'ParameterizedInt'.
>         at
>
> org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)[105:org.springframework.beans:3.0.7.RELEASE]
>         at
>
> org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)[105:org.springframework.beans:3.0.7.RELEASE]
> *
>
> Could you please let me know what is the exact value to be entered for
> <httpj:engine port="${fromCxfEndpointUri.port}">
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/camel-cxf-and-HTTP-BASIC-authentication-tp5716163p5738725.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: camel-cxf and HTTP BASIC authentication

Posted by contactreji <co...@gmail.com>.
Hi Christian

I have followed your steps and made my coade as follows

*
	<cxf:cxfEndpoint id="MESEndpoint"
		address="http://server:8181/mes/bw/Service_Endpoint"
		serviceClass="company.pi.mes.id56.copperrecovery.ImplementationClass"
		wsdlURL="wsdl/myWSDL.wsdl"
		serviceName="p1:ServiceClasses" endpointName="p1:HTTPS_Port"
		xmlns:p1="urn:company:pi:mes:id56:Task" 
             xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" />

	
	
	<httpj:engine-factory>
		<httpj:engine
			port="{http://es0sreao:8181/mes/bw/Service_Endpoint}.8181">  
			<httpj:tlsServerParameters>
				<sec:keyManagers keyPassword="fuseesb">
					<sec:keyStore type="JKS" password="fuseesb"
						file="certs/truststore.jks" />
				</sec:keyManagers>
				<sec:trustManagers>
					<sec:keyStore type="JKS" password="fuseesb"
						file="certs/truststore.jks" />
				</sec:trustManagers>
				<sec:cipherSuitesFilter>
					<sec:include>.*.*</sec:include>
					<sec:exclude>.*40_.*</sec:exclude>
					<sec:exclude>.*_RSA_WITH_DES_CBC_SHA.*</sec:exclude>
					<sec:exclude>.*_RSA_WITH_3DES_EDE_CBC_SHA.*</sec:exclude>
				</sec:cipherSuitesFilter>
				<sec:clientAuthentication want="false"
					required="false" />
			</httpj:tlsServerParameters>
			<httpj:threadingParameters minThreads="5"
				maxThreads="20" />
			<httpj:handlers>
				
				<ref bean="securityHandler" />
			</httpj:handlers>
		</httpj:engine>
	</httpj:engine-factory>

	<bean id="securityHandler"
class="org.eclipse.jetty.security.ConstraintSecurityHandler">
		<property name="authenticator">
			<bean
class="org.eclipse.jetty.security.authentication.BasicAuthenticator" />
		</property>
		<property name="constraintMappings">
			<list>
				<bean class="org.eclipse.jetty.security.ConstraintMapping">
					<property name="constraint">
						<bean class="org.eclipse.jetty.http.security.Constraint">
							<property name="name" value="BASIC" />
							<property name="roles" value="our-role-name" />
							<property name="authenticate" value="true" />
						</bean>
					</property>
					<property name="pathSpec" value="/*" />
				</bean>
			</list>
		</property>
		<property name="loginService">
			<bean class="org.eclipse.jetty.plus.jaas.JAASLoginService">
				<property name="name" value="karaf" />
				<property name="loginModuleName" value="karaf" />
				<property name="roleClassNames">
					<list>

						<value>org.apache.karaf.jaas.modules.RolePrincipal</value>
					</list>
				</property>
			</bean>
		</property>
		<property name="strict" value="false" />
		<property name="identityService">
			<bean class="org.eclipse.jetty.security.DefaultIdentityService" />
		</property>
	</bean>*


While deployment I am getting following exception in log

*
09:34:15,721 | INFO  | xtenderThread-36 | XmlBeanDefinitionReader          |
105 - org.springframework.beans - 3.0.7.RELEASE | Loading XML bean
definitions from URL [bundle://324.0:0/META-INF/spring/camel-cxf.xml]
09:34:15,741 | ERROR | xtenderThread-36 | ContextLoaderListener            |
113 - org.springframework.osgi.extender - 1.2.1 | Application context
refresh failed
(OsgiBundleXmlApplicationContext(bundle=com.outotec.mes-bw-copper_recovery_perc_ssl,
config=osgibundle:/META-INF/spring/*.xml))
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line
39 in XML document from URL [bundle://324.0:0/META-INF/spring/camel-cxf.xml]
is invalid; nested exception is org.xml.sax.SAXParseException:
cvc-datatype-valid.1.2.3:
'{http://es0sreao:8181/mes/bw/MEStoBW_CopperRecoveryPercentage_JAAS}.8181'
is not a valid value of union type 'ParameterizedInt'.
	at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)[105:org.springframework.beans:3.0.7.RELEASE]
	at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)[105:org.springframework.beans:3.0.7.RELEASE]
*

Could you please let me know what is the exact value to be entered for 
<httpj:engine port="${fromCxfEndpointUri.port}"> 




--
View this message in context: http://camel.465427.n5.nabble.com/camel-cxf-and-HTTP-BASIC-authentication-tp5716163p5738725.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: camel-cxf and HTTP BASIC authentication

Posted by contactreji <co...@gmail.com>.
Hi Christain.. Could you please guide us with the details of dependencies
added.
Would be really helpful fi you could post the copy of your POM file.
Reji



--
View this message in context: http://camel.465427.n5.nabble.com/camel-cxf-and-HTTP-BASIC-authentication-tp5716163p5738715.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: camel-cxf and HTTP BASIC authentication

Posted by Christian Müller <ch...@gmail.com>.
We use the following engine factory configuration to configure our Jetty
server (placed in our bundle-context.xml Spring DM configuration)

<httpj:engine-factory bus="cxf">
    <httpj:engine port="${fromCxfEndpointUri.port}">
        <httpj:tlsServerParameters>
            <sec:keyManagers keyPassword="${keyStoreKeyPassword}">
                <sec:keyStore type="JKS" password="${keyStorePassword}"
file="${keyStoreFile}" />
            </sec:keyManagers>
            <sec:trustManagers>
                <sec:keyStore type="JKS" password="${keyStorePassword}"
file="${keyStoreFile}"/>
            </sec:trustManagers>
            <sec:cipherSuitesFilter>
                <sec:include>.*.*</sec:include>
                <sec:exclude>.*40_.*</sec:exclude>
                <sec:exclude>.*_RSA_WITH_DES_CBC_SHA.*</sec:exclude>
                <sec:exclude>.*_RSA_WITH_3DES_EDE_CBC_SHA.*</sec:exclude>
            </sec:cipherSuitesFilter>
            <sec:clientAuthentication want="false" required="false" />
        </httpj:tlsServerParameters>
        <httpj:threadingParameters minThreads="5" maxThreads="20" />
        <httpj:handlers>
            <!-- BASIC AUTHENTICATION configuration -->
            <ref bean="securityHandler"/>
        </httpj:handlers>
    </httpj:engine>
</httpj:engine-factory>


In our bundle-context-osgi Spring DM configuration which is used in Karaf,
we defined the "securityHandler" as following:
<bean id="securityHandler"
class="org.eclipse.jetty.security.ConstraintSecurityHandler">
    <property name="authenticator">
        <bean
class="org.eclipse.jetty.security.authentication.BasicAuthenticator"/>
    </property>
    <property name="constraintMappings">
        <list>
            <bean class="org.eclipse.jetty.security.ConstraintMapping">
                <property name="constraint">
                    <bean
class="org.eclipse.jetty.http.security.Constraint">
                        <property name="name" value="BASIC"/>
                        <property name="roles" value="our-role-name"/>
                        <property name="authenticate" value="true"/>
                    </bean>
                </property>
                <property name="pathSpec" value="/*"/>
            </bean>
        </list>
    </property>
    <property name="loginService">
        <bean class="org.eclipse.jetty.plus.jaas.JAASLoginService">
            <property name="name" value="karaf"/>
            <property name="loginModuleName" value="karaf"/>
            <property name="roleClassNames">
                <list>

<value>org.apache.karaf.jaas.modules.RolePrincipal</value>
                </list>
            </property>
        </bean>
    </property>
    <property name="strict" value="false"/>
    <property name="identityService">
        <bean class="org.eclipse.jetty.security.DefaultIdentityService"/>
    </property>
</bean>


Edit the ${KARAF_HOME}/etc/users.properties file and add the user:
user=password,our-role-name


For our unit tests, we are using a different "securityHandler"
configuration:
<bean id="securityHandler"
class="org.eclipse.jetty.security.ConstraintSecurityHandler">
    <property name="authenticator">
        <bean
class="org.eclipse.jetty.security.authentication.BasicAuthenticator"/>
    </property>
    <property name="constraintMappings">
        <list>
            <bean class="org.eclipse.jetty.security.ConstraintMapping">
                <property name="constraint">
                    <bean
class="org.eclipse.jetty.http.security.Constraint">
                        <property name="name" value="BASIC"/>
                        <property name="roles" value="our-role-name"/>
                        <property name="authenticate" value="true"/>
                    </bean>
                </property>
                <property name="pathSpec" value="/*"/>
            </bean>
        </list>
    </property>
    <property name="loginService">
        <bean class="org.eclipse.jetty.security.HashLoginService">
            <property name="name" value="karaf" />
            <property name="config"
value="src/test/resources/jetty-realm.properties" />
        </bean>
    </property>
    <property name="strict" value="false"/>
</bean>


The "jetty-realm.properties" fooks like this one:
user: password,our-role-name


We are creating our test client like this one:
String url = "https://localhost:7071/foo/services/BarService";
List<Interceptor<? extends Message>> outInterceptors =
    new ArrayList<Interceptor<? extends Message>>();

LoggingOutInterceptor loggingOutInterceptor = new LoggingOutInterceptor();
outInterceptors.add(loggingOutInterceptor);

JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setBus(BusFactory.getDefaultBus());
factory.setOutInterceptors(outInterceptors);
factory.setServiceClass(SemprisEaiAIG.class);
factory.setAddress(url);
factory.setUsername("user");
factory.setPassword("password");
BarService serviceClient = (BarService) factory.create();

serviceClient.doSomething(...);

Hope this helps.

Best,
Christian
-----------------

Software Integration Specialist

Apache Camel committer: https://camel.apache.org/team
V.P. Apache Camel: https://www.apache.org/foundation/
Apache Member: https://www.apache.org/foundation/members.html

https://www.linkedin.com/pub/christian-mueller/11/551/642


On Mon, Sep 2, 2013 at 10:02 PM, Christian Müller <
christian.mueller@gmail.com> wrote:

> Yes, we got it working. I can post the relevant code snippets here
> tomorrow.
>
> Best,
> Christian
> -----------------
>
> Software Integration Specialist
>
> Apache Camel committer: https://camel.apache.org/team
> V.P. Apache Camel: https://www.apache.org/foundation/
> Apache Member: https://www.apache.org/foundation/members.html
>
> https://www.linkedin.com/pub/christian-mueller/11/551/642
>
>
> On Tue, Aug 27, 2013 at 9:00 PM, contactreji <co...@gmail.com>wrote:
>
>> Hi Christian.. did you get a work around the problem?
>>
>>
>>
>> --
>> View this message in context:
>> http://camel.465427.n5.nabble.com/camel-cxf-and-HTTP-BASIC-authentication-tp5716163p5738071.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>
>

Re: camel-cxf and HTTP BASIC authentication

Posted by Christian Müller <ch...@gmail.com>.
Yes, we got it working. I can post the relevant code snippets here tomorrow.

Best,
Christian
-----------------

Software Integration Specialist

Apache Camel committer: https://camel.apache.org/team
V.P. Apache Camel: https://www.apache.org/foundation/
Apache Member: https://www.apache.org/foundation/members.html

https://www.linkedin.com/pub/christian-mueller/11/551/642


On Tue, Aug 27, 2013 at 9:00 PM, contactreji <co...@gmail.com> wrote:

> Hi Christian.. did you get a work around the problem?
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/camel-cxf-and-HTTP-BASIC-authentication-tp5716163p5738071.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>