Tuesday, October 1, 2013

Symmetricds Cookies support

My problem : we need cookies support for SymmetricDS client in order to authenticate against central SymmetricDS.
Solution :
Create an extension point class
 package com.synch.extension;  
 import java.net.CookieHandler;  
 import java.net.CookieManager;  
 import java.net.CookiePolicy;  
 import org.jumpmind.extension.IExtensionPoint;  
 import org.slf4j.Logger;  
 import org.slf4j.LoggerFactory;  
 public class CookieManagerConf implements IExtensionPoint{  
      protected final Logger log = LoggerFactory.getLogger(getClass());  
      public CookieManagerConf() {  
           System.out.println("Cookie manager initialized ------------------------>");  
           log.info("Cookie manager initialized ---------------------->");  
           CookieManager manager = new CookieManager(null,CookiePolicy.ACCEPT_ALL);  
           CookieHandler.setDefault(manager);  
      }  
 }  

Create extension XML in {classpath}\conf\symmetric-extensions.xml as follow :
 <?xml version="1.0" encoding="UTF-8"?>  
 <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
   xmlns:lang="http://www.springframework.org/schema/lang"  
   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  
             http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-3.0.xsd" default-lazy-init="true">  
      <bean id="cookieManager" class="com.synch.extension.CookieManagerConf">  
      </bean>  
 </beans>  

No comments:

Post a Comment