cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Juan José Pérez Consuegra <jjpco...@gmail.com>
Subject Re: Can't load Jetty security configuration
Date Sat, 13 Oct 2012 16:15:08 GMT
I think i've found the error, is that in my config file I established port
number = "0", becouse I want to aply security rule to any port number, and
it doesn't. How can I set port number dynamically as in the example??

2012/10/12 Freeman Fang <freeman.fang@gmail.com>

> Hi,
>
> We have a system test which demonstrate how to enable jetty basic auth, it
> should be a good start for you. From this link[1] you can find all
> material, the test code, the configuration files, it's very similar as what
> you want to do.
>
> [1]http://svn.apache.org/viewvc?view=revision&revision=1075784
> -------------
> Freeman Fang
>
> Red Hat, Inc.
> FuseSource is now part of Red Hat
> Web: http://fusesource.com | http://www.redhat.com/
> Twitter: freemanfang
> Blog: http://freemanfang.blogspot.com
> http://blog.sina.com.cn/u/1473905042
> weibo: http://weibo.com/u/1473905042
>
> On 2012-10-12, at 上午5:05, Juan José Pérez Consuegra wrote:
>
> > I'm trying to use Jetty security loading configuration from xml config
> > file. The file loads without any error but policies seems not to work. I
> > thought to load configuration via code, but I'm using
> > JAXRSServerFactoryBean and it seems also not to be possible. Here it is
> mi
> > config file:
> >
> > <beans xmlns="http://www.springframework.org/schema/beans"
> >       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> >       xmlns:httpj="
> > http://cxf.apache.org/transports/http-jetty/configuration"
> >       xsi:schemaLocation="
> > http://cxf.apache.org/transports/http-jetty/configuration
> > http://cxf.apache.org/schemas/configuration/http-jetty.xsd
> > http://www.springframework.org/schema/beans
> > http://www.springframework.org/schema/beans/spring-beans.xsd">
> >
> >    <httpj:engine-factory bus="cxf">
> >        <httpj:engine port="0">
> >            <httpj:threadingParameters minThreads="5"
> >                                 maxThreads="15" />
> >            <httpj:handlers>
> >                <bean
> > class="org.eclipse.jetty.security.ConstraintSecurityHandler">
> >                    <property name="loginService"
> > ref="securityLoginService" />
> >                    <property name="constraintMappings">
> >                        <list>
> >                            <ref bean="securityConstraintMapping" />
> >                        </list>
> >                    </property>
> >                </bean>
> >            </httpj:handlers>
> >        </httpj:engine>
> >    </httpj:engine-factory>
> >
> >    <bean id="securityLoginService"
> > class="org.eclipse.jetty.security.HashLoginService">
> >        <property name="name" value="WSRealm" />
> >        <property name="config"
> >
> value="src/es/uned/scc/related/cserver/ws/configuration/jetty-realm.properties"
> > />
> >    </bean>
> >
> >    <bean id="securityConstraint"
> > class="org.eclipse.jetty.http.security.Constraint">
> >        <property name="name" value="BASIC" />
> >        <property name="roles" value="admin" />
> >        <property name="authenticate" value="true" />
> >    </bean>
> >
> >    <bean id="securityConstraintMapping"
> > class="org.eclipse.jetty.security.ConstraintMapping">
> >        <property name="constraint" ref="securityConstraint" />
> >        <property name="pathSpec" value="/*" />
> >    </bean>
> > </beans>
> >
> >
> > jetty-realm.properties
> > # Defines users that can access the web (console, demo, etc.)
> > # username: password [,rolename ...]
> > ffang: pswd, admin
> >
> > And the code that creates the server:
> >
> >    static{
> >        // set the configuration file
> >        SpringBusFactory factory = new SpringBusFactory();
> >        Bus bus =
> >
> factory.createBus("src/es/uned/scc/related/cserver/ws/configuration/server-sec-bean.xml");
> >        BusFactory.setDefaultBus(bus);
> >    }
> >
> > ....
> > ....
> > ....
> > .....
> >
> > public void start() throws Exception{
> >    if (sf == null){
> >        sf = new JAXRSServerFactoryBean();
> >        sf.setResourceClasses(RLABSystemWSRest.class);
> >        sf.setResourceProvider(RLABSystemWSRest.class,
> >        new SingletonResourceProvider(new RLABSystemWSRest()));
> >        sf.setAddress(address);
> >
> >
> >        server = sf.create();
> >
> >        System.out.println("Servidor arrancado y servicio
> > publicado...");
> >    } else {
> >        if (server.isStarted()) {
> >            System.out.println("Servidor ya estaba arrancado y el servicio
> > publicado...");
> >        }else{
> >            server.start();
> >            System.out.println("Servidor arrancado y servicio
> > publicado...");
> >        }
> >    }
> > }
> >
> >
> > As I said before, the config file loads perfectly, at least apparently,
> but
> > if I try to call any operation defined as service without any
> credential, I
> > receive server status  200 OK, and the correct response of course.
> >
> > Any idea.
> >
> > Thank to everybody,
> >
> > Juanjo.
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message