Thank's Rober for your detailed "how to".
I have doubts with this line:

LogUtils.setNdcLogIdentifier(credentials);


Where you get this method??.


Thank's for all.



2013/4/11 Robert Oschwald <[email protected]>

> Here are the rough steps how I created a WsAuthenticationHandler for CAS
> 3.4.xx using SpringWS 1.5.4 and JaxB marshalling.
> Use the recommended Maven Overlay project setup as stated in the CAS CASUM
> Wiki manual.
>
>
> 1. Implement a WsAuthenticationHandler which
> extends AbstractUsernamePasswordAuthenticationHandler and uses an injected
> WebserviceClient for authentication:
> public class WebserviceAuthenticationHandler
> extends AbstractWebserviceAuthenticationHandler implements InitializingBean
> {
> protected final boolean authenticateUsernamePasswordInternal(
> UsernamePasswordCredentials credentials) throws AuthenticationException {
> return this._webserviceClient.doAuthentication(credentials);
> }
> public final void setWebserviceClient(final WebserviceClient
> webserviceClient) {
>  this._webserviceClient = webserviceClient;
>  }
> }
>
> 2. Create WebserviceClient interface:
> public interface WebserviceClient  {
> public boolean doAuthentication(final UsernamePasswordCredentials
> credentials) throws AuthenticationException;
> }
>
> 3. Create a webserviceClient impl
> e.g.:
> public class YourWsClient  implements WebserviceClient {
> public boolean doAuthentication(UsernamePasswordCredentials credentials)
> throws AuthenticationException {
>  LogUtils.setNdcLogIdentifier(credentials);
>  MyRequest request = ObjectFactory.createMyRequest();
> request.setUsername(credentials.getUsername);
> request.setPassword(credentials.getPassword);
> try {
> response = (AuthenticateUserResponse)
> getWebServiceTemplate().marshalSendAndReceive(request);
> return (response.isLoggedIn()); // just an example.
> } catch (Exception e){
> throw AuthenticationException("error.authentication.credentials.bad");
> }
>  }
> }
>
> 4. Define the wsClient bean with its marshaller and unmarshaller (I use a
> separate wsConfigContext.xml file for this)
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns="http://www.springframework.org/schema/beans";
>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>   xsi:schemaLocation="http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd";>
>   <bean id="yourWsClient" class="xxx.cas.adaptors.ws.YourWsClient">
>     <property name="marshaller" ref="marshaller"/>
>     <property name="unmarshaller" ref="marshaller"/>
>     <property name="defaultUri" value="https://
> <ws-server>/<ws-endpoint-address>"/>
>   </bean>
>   <!-- (Un-)Marshaller -->
>   <bean id="marshaller"
> class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
>     <property name="contextPath"
> value="<your_package_name_of_xjc_generated_schema_classes>"/>
>   </bean>
> </beans>
>
>
> 5. Wire in the WebserviceAuthenticationHandler into
> deployerConfigContext.xml authenticationManager:
> ...
> <bean id="authenticationManager"
> class="org.jasig.cas.authentication.AuthenticationManagerImpl">
> <property name="authenticationHandlers">
> <list>
> <!--
> | This is the authentication handler that authenticates services by means
> of callback via SSL, thereby validating
> | a server side SSL certificate.
> +-->
> <bean
> class="org.jasig.cas.authentication.handler.support.HttpBasedServiceCredentialsAuthenticationHandler"
> p:httpClient-ref="httpClient" />
>
> <!-- Your Webservice Authentication Handler  -->
> <bean id="wsAuthHandler"
> class="xxx.handler.WebserviceAuthenticationHandler">
>   <property name="webserviceClient" ref="yourWsClient"/>
> </bean>
> </list>
> </property>
> </bean>
> …
>
> 6. add the wsConfigContext.xml to web.xml:
> <context-param>
> <param-name>contextConfigLocation</param-name>
> <param-value>
> /WEB-INF/spring-configuration/*.xml
> /WEB-INF/deployerConfigContext.xml
> /WEB-INF/wsConfigContext.xml
> </param-value>
> </context-param>
>
>
> You can add the jaxb2 maven plugin to the pom.xml to generate the schema
> classes automatically.
> See http://mojo.codehaus.org/jaxb2-maven-plugin/usage.html
>
>
> Robert
>
> Am 11.04.2013 um 10:37 schrieb Carlos Lorenzo <[email protected]>:
>
> Thank you for your quick response, Robert.
> Could you elaborate a little more your solution??.
> As I said in the previous mail I am fairly new with JASIG Cas Server.
>
>
> Thanks.
>
>
> --
>
> You are currently subscribed to [email protected] as: 
> [email protected]
> To unsubscribe, change settings or access archives, see 
> http://www.ja-sig.org/wiki/display/JSG/cas-user
>
>
> --
> You are currently subscribed to [email protected] as: 
> [email protected]
> To unsubscribe, change settings or access archives, see 
> http://www.ja-sig.org/wiki/display/JSG/cas-user
>
>

-- 
You are currently subscribed to [email protected] as: 
[email protected]
To unsubscribe, change settings or access archives, see 
http://www.ja-sig.org/wiki/display/JSG/cas-user

Reply via email to