Servicemix에 배포 할 인증 및 인증을 사용하여 cxf soap webservice를 구성하려고합니다. 다음과 같이 카라프에서 cxf-rs-ws 인증
내가 LDAP 인증 모듈을 구성하십시오 beans.xml 환경 파일을<!-- Bean to allow the $[karaf.base] property to be correctly resolved -->
<ext:property-placeholder placeholder-prefix="$[" placeholder-suffix="]"/>
<jaas:config name="myRealm">
<jaas:module className="org.apache.karaf.jaas.modules.ldap.LDAPLoginModule" flags="required">
connection.url = ldap://srv-ldap:389
user.base.dn = ou=people,dc=intranet,dc=company,dc=com
user.filter = (uid=%u)
user.search.subtree = false
role.base.dn = ou=groups,dc=intranet,dc=company,dc=com
role.filter = (member:=uid=%u,ou=people,dc=intranet,dc=company,dc=com)
role.name.attribute = cn
role.search.subtree = true
authentication = simple
</jaas:module>
</jaas:config>
<service interface="org.apache.karaf.jaas.modules.BackingEngineFactory">
<bean class="org.apache.karaf.jaas.modules.properties.PropertiesBackingEngineFactory"/>
</service>
을 그리고 여기
<jaxws:endpoint id="myService"
implementor="com.myorg.services.impl.MyServiceWSImpl"
address="/myService">
<jaxws:inInterceptors>
<bean class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
<constructor-arg>
<map>
<entry key="action" value="UsernameToken" />
<entry key="passwordType" value="PasswordText" />
</map>
</constructor-arg>
</bean>
<ref bean="authenticationInterceptor" />
<ref bean="authorizationInterceptor" />
</jaxws:inInterceptors>
<jaxws:properties>
<entry key="ws-security.validate.token" value="false" />
</jaxws:properties>
</jaxws:endpoint>
<bean id="authenticationInterceptor"
class="org.apache.cxf.interceptor.security.JAASLoginInterceptor">
<property name="contextName" value="myRealm" />
</bean>
<bean id="authorizationInterceptor"
class="org.apache.cxf.interceptor.security.SecureAnnotationsInterceptor">
<property name="securedObject" ref="securedBean"/>
</bean>
마지막으로, 내 WebService를 구현에서 나는 방법을 주석 @RolesAllowed와 함께.
@RolesAllowed("Role1")
public Department get(String name) throws IdMException {
return service.get(name);
}
인증 인터셉터는 사용자를 검색하고 인증하고 그룹을 RolePrincipal 인스턴스로 검색합니다. 그런 다음 권한 부여 인터셉터 (SecureAnnotationsInterceptor)에서 메서드 구성을 읽으며 expectedRoles는 "Role1"이지만 SimpleAuthorizingInterceptor.isUserInRole 메서드는 false를 반환합니다.
내가 더 많거나 적은 같은 일을하려고 모든 예와 나는 중요한 뭔가가되어야하는 CXF 문서 페이지 http://cxf.apache.org/docs/security.html#Security-Authorization
에서 있었다 발견 된 몇 가지 정보를 발견하지 않았습니다, 누군가가 나를 도울 수 있기를 바랍니다. 미리 감사드립니다.
당신에게 매우 감사를! –
문제 없습니다. ServiceMix의 상용 클론이 완벽하게 지원된다는 점에 유의하십시오. 현재 JBoss Fuse에서도 동일한 문제가 발생하지만 JBoss Fuse에서는 너무 빨리 해결 될 것입니다. 문제에 대한 링크 : https://issues.jboss.org/browse/ENTESB-1672 –