Announcement Announcement Module
Collapse
No announcement yet.
ACEGI + CAS SERVER + MYSQL ???? Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • ACEGI + CAS SERVER + MYSQL ????

    Hi you all

    Well I’m trying to configurate CAS Server with the Spring PasswordHandler, I follow the instructions suggested by ACEGI, and it works all fine, but when I try to use MYSQL data source instead of InMemoryDaoImp I just don’t know where to go!

    The original ACEGI instructions are here (I was going to paste the instructions but it's too much lol)http://acegisecurity.sourceforge.net...install-client


    I ‘ve managed to get this far with the configuration in order to use a database datasource instead of memory:

    Code:
    	<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
            <property name="driverClassName">
                <value>com.mysql.jdbc.Driver</value>
            </property>
            <property name="url">
                <value>jdbc&#58;mysql&#58;//localhost&#58;3306/acegiDB</value>
            </property>
            <property name="username">
                <value>acegi</value>
            </property>
            <property name="password">
                <value>acegi</value>
            </property>
        </bean>
    
    	<bean id="authenticationDao" class="net.sf.acegisecurity.providers.dao.jdbc.JdbcDaoImpl">
    		<property name="dataSource"><ref bean="dataSource"/></property>
    		
    		<property name="usersByUsernameQuery">
    		<value>select username, password, 'true' from users where username=?</value>
    		</property>
    		
    		<property name="authoritiesByUsernameQuery">
    		<value>select username, privilege from authorities where username=?</value>
    		</property>
    	</bean>
    	
    	<bean id="daoAuthenticationProvider" class="net.sf.acegisecurity.providers.dao.DaoAuthenticationProvider">
    	  <property name="authenticationDao"><ref bean="authenticationDao"/></property>
    	</bean>
    	
    	<bean id="authenticationManager" class="net.sf.acegisecurity.providers.ProviderManager">
    	  <property name="providers">
    		 <list>
    			<ref bean="daoAuthenticationProvider"/>
    		 </list>
    	  </property>
    	</bean>
    	
    	<bean id="casPasswordHandler" class="net.sf.acegisecurity.adapters.cas.CasPasswordHandler">
    	  <property name="authenticationManager"><ref bean="authenticationManager"/></property>
    	</bean>
    But it just doesn’t work! I get no error messages nor warnings or anything that helps me to understand what’s going on…
    I saw a post in regards on something like this, but, I just get the following info :
    Code:
    DEBUG |net.sf.acegisecurity.providers.ProviderManager| Authentication attempt using net.sf.acegisecurity.providers.dao.DaoAut
    henticationProvider
    INFO  |org.springframework.beans.factory.xml.XmlBeanDefinitionReader| Loading XML bean definitions from class path resource &#91;
    org/springframework/jdbc/support/sql-error-codes.xml&#93;
    INFO  |org.springframework.beans.factory.support.DefaultListableBeanFactory| Creating shared instance of singleton bean 'DB2'
    INFO  |org.springframework.beans.factory.support.DefaultListableBeanFactory| Creating shared instance of singleton bean 'HSQL'
    INFO  |org.springframework.beans.factory.support.DefaultListableBeanFactory| Creating shared instance of singleton bean 'MS-SQL'
    INFO  |org.springframework.beans.factory.support.DefaultListableBeanFactory| Creating shared instance of singleton bean 'MySQL'
    INFO  |org.springframework.beans.factory.support.DefaultListableBeanFactory| Creating shared instance of singleton bean 'Oracle'
    INFO  |org.springframework.beans.factory.support.DefaultListableBeanFactory| Creating shared instance of singleton bean 'Informix'
    INFO  |org.springframework.beans.factory.support.DefaultListableBeanFactory| Creating shared instance of singleton bean 'PostgreSQL'
    INFO  |org.springframework.beans.factory.support.DefaultListableBeanFactory| Creating shared instance of singleton bean 'Sybase'
    INFO  |org.springframework.jdbc.support.SQLErrorCodesFactory| SQLErrorCodes loaded&#58; &#91;DB2, HSQL, MS-SQL, MySQL, Oracle, Inform
    ix, PostgreSQL, Sybase&#93;
    And nothing more happens! So I’m wondering, have anybody has a configuration example that works that I could follow??? Or any suggestions?? Am I doing something wrong in my config that I'm not aware of?

    thanks in advance

  • #2
    ok new configuration

    Ok news flash jajaja, I got to this new configuration, and didn't get any errors....

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http&#58;//www.springframework.org/dtd/spring-beans.dtd">
    
    <beans>
     <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
             <property name="driverClassName">
                <value>com.mysql.jdbc.Driver</value>
            </property>
            <property name="url">
                <value>jdbc&#58;mysql&#58;//localhost&#58;3306/acegiDB</value>
            </property>
            <property name="username">
                <value>acegi</value>
            </property>
            <property name="password">
                <value>acegi</value>
            </property>
    </bean>
    
    <bean id="jdbcDaoImpl" class="net.sf.acegisecurity.providers.dao.jdbc.JdbcDaoImpl">
      <property name="dataSource"><ref bean="dataSource"/></property>
    </bean>
    
    <bean id="daoAuthenticationProvider" class="net.sf.acegisecurity.providers.dao.DaoAuthenticationProvider">
      <property name="authenticationDao"><ref bean="jdbcDaoImpl"/></property>
    </bean>
    
    <bean id="authenticationManager" class="net.sf.acegisecurity.providers.ProviderManager">
      <property name="providers">
        <list>
          <ref bean="daoAuthenticationProvider"/>
        </list>
      </property>
    </bean>
    
    <bean id="casPasswordHandler" class="net.sf.acegisecurity.adapters.cas.CasPasswordHandler">
      <property name="authenticationManager"><ref bean="authenticationManager"/></property>
    </bean>
    however I can't login!!! :cry: when I deug I see that there are conections to my database, a select prepared statment and a substitution of the ? for my user!!! BUT EVEN THOUGH THAT I'M USING THE CORRECT PASSWORD IT DOESNT RETURN ANYTHING!!!

    Code:
    DEBUG |org.springframework.jdbc.core.JdbcTemplate| Executing SQL query &#91;SELECT username,authority FROM authorities WHERE user name = ?&#93;
    
    DEBUG |org.springframework.jdbc.datasource.DataSourceUtils| Opening JDBC Connection
    
    DEBUG |org.springframework.jdbc.datasource.DriverManagerDataSource| Creating new JDBC connection to &#91;jdbc&#58;mysql&#58;//localhost&#58;3306/acegiDB&#93;
    
    DEBUG |org.springframework.jdbc.core.StatementCreatorUtils| Setting SQL statement parameter value&#58; columnIndex 1, parameter value &#91;marissa&#93;, valueClass &#91;java.lang.String&#93;, sqlType 12
    
    DEBUG |org.springframework.jdbc.datasource.DataSourceUtils| Closing JDBC Connection
    I'm starting to believe that it might be some password enconding thing, because if I check directly in my database, the encription for the password "koala" is different from the one that is given originally to the database


    Original encripted password : a564de63c2d0da68cf47586ee05984d7
    Mysql encripted password : *544C21D1C87CD672CCDCD26A79B2E269958C4B94

    By any chance anybody knows what kind of encription is used? (MD5, SHA and cleartext ), or how to configure the so called PasswordEncoder ????

    thanks again...[/code]

    Comment


    • #3
      elemental mi querido watson...

      Indeed it was a problem with encryption
      Here's the complete solution to my old predicament if anybody find's it useful good luck

      cheers


      The complete listing of the applicationContext.xml
      Code:
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http&#58;//www.springframework.org/dtd/spring-beans.dtd">
      
      <beans>
          <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
              <property name="driverClassName"><value>com.mysql.jdbc.Driver</value></property>
              <property name="url"><value>jdbc&#58;mysql&#58;//localhost&#58;3306/acegiDB</value></property>
              <property name="username"><value>acegi</value></property>
              <property name="password"><value>acegi</value></property>
          </bean>
      
          <bean id="jdbcDaoImpl" class="net.sf.acegisecurity.providers.dao.jdbc.JdbcDaoImpl">
              <property name="dataSource">
                  <ref bean="dataSource"/>
              </property>
          </bean>
      
      
          <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
              <property name="configLocation"><value>classpath&#58;/ehcache-failsafe.xml</value></property>
          </bean>
      
          <bean id="userCacheBackend" class="org.springframework.cache.ehcache.EhCacheFactoryBean">
              <property name="cacheManager"><ref local="cacheManager"/></property>
              <property name="cacheName"><value>userCache</value></property>
          </bean>
      
          <bean id="userCache" class="net.sf.acegisecurity.providers.dao.cache.EhCacheBasedUserCache">
              <property name="cache"><ref local="userCacheBackend"/></property>
          </bean>
      
          <bean id="daoAuthenticationProvider" class="net.sf.acegisecurity.providers.dao.DaoAuthenticationProvider">
              <property name="authenticationDao"><ref bean="jdbcDaoImpl"/></property>
              <property name="passwordEncoder"><ref bean="passwordEncoder"/></property>
              <property name="userCache"><ref bean="userCache"/></property>
          </bean>
      
      
          <bean id="passwordEncoder" class="net.sf.acegisecurity.providers.encoding.Md5PasswordEncoder">
              <property name="encodeHashAsBase64"><value>false</value></property>
          </bean>
      
          <bean id="authenticationManager" class="net.sf.acegisecurity.providers.ProviderManager">
              <property name="providers">
                  <list>
                      <ref bean="daoAuthenticationProvider"/>
                  </list>
              </property>
          </bean>
      
          <bean id="casPasswordHandler" class="net.sf.acegisecurity.adapters.cas.CasPasswordHandler">
              <property name="authenticationManager">
                  <ref bean="authenticationManager"/>
              </property>
          </bean>
      
      </beans>
      The jar libraries that must be in your lib directory:
      Code:
       acegi-security-0.8.2.jar
       acegi-security-cas-0.8.2.jar
       cas.jar
       commons-codec-1.3.jar
       commons-collections-3.1.jar
       commons-logging.jar
       ehcache-1.1.jar
       log4j-1.2.9.jar
       mysql-connector-java-3.0.16-ga-bin.jar
       oro-2.0.8.jar
       spring-1.2.1.jar

      Comment

      Working...
      X