I have setup :
- Tomcat6/JDK6/CAS 3.5.2.1
- LDAP authentication (password thing)
- MySQL storage for tickets & services registries

I face a problem with Principal Resolving (from catalina.out) :

WHO: [username: mdupont]
WHAT: 'principal' cannot be null.
Check the correctness of @Audit annotation at the following audit point: 
execution(public abstract org.jasig.cas.authentication.Authentication 
org.jasig.cas.authentication.AuthenticationManager.authenticate(org.jasig.cas.authentication.principal.Credentials))
ACTION: TICKET_GRANTING_TICKET_NOT_CREATED
APPLICATION: CAS


I have attached my deployerConfigContext.xml
My goal is to setup LDAP auth, with a filter by service (OU filtering), and 
attributes grabing for the web applications.

For now, I am blocked by this "null" principal. I guess that this has to be 
mapped to an ldap attribute. Right?


Thanks for any help.


-----Message d'origine-----
De : John Gasper [mailto:jgas...@unicon.net] 
Envoyé : mardi 16 septembre 2014 16:32
À : cas-user@lists.jasig.org
Objet : Re: [cas-user] Connection CAS Server 3.5.2 with LDAP Server

Hello,

Have you looked at https://wiki.jasig.org/display/CASUM/LDAP? That's should get 
you started.

John

On 9/16/14 2:06 AM, Patrick Pat wrote:
> Hi,
> I would like to connect CAS Server 3.5.2 with LDAP Server but i don't 
> have a good procedure.
> Please help me.
>
> --
> You are currently subscribed to cas-user@lists.jasig.org as: 
> jgas...@unicon.net To unsubscribe, change settings or access archives, 
> see http://www.ja-sig.org/wiki/display/JSG/cas-user


--
You are currently subscribed to cas-user@lists.jasig.org as: gtour...@tibco.fr 
To unsubscribe, change settings or access archives, see 
http://www.ja-sig.org/wiki/display/JSG/cas-user

-- 
You are currently subscribed to cas-user@lists.jasig.org as: 
arch...@mail-archive.com
To unsubscribe, change settings or access archives, see 
http://www.ja-sig.org/wiki/display/JSG/cas-user
<?xml version="1.0" encoding="UTF-8"?>
<!--

    Licensed to Jasig under one or more contributor license
    agreements. See the NOTICE file distributed with this work
    for additional information regarding copyright ownership.
    Jasig licenses this file to you under the Apache License,
    Version 2.0 (the "License"); you may not use this file
    except in compliance with the License.  You may obtain a
    copy of the License at the following location:

      http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.

-->
<!--
	| deployerConfigContext.xml centralizes into one file some of the declarative configuration that
	| all CAS deployers will need to modify.
	|
	| This file declares some of the Spring-managed JavaBeans that make up a CAS deployment.  
	| The beans declared in this file are instantiated at context initialization time by the Spring 
	| ContextLoaderListener declared in web.xml.  It finds this file because this
	| file is among those declared in the context parameter "contextConfigLocation".
	|
	| By far the most common change you will need to make in this file is to change the last bean
	| declaration to replace the default SimpleTestUsernamePasswordAuthenticationHandler with
	| one implementing your approach for authenticating usernames and passwords.
	+-->

<beans xmlns="http://www.springframework.org/schema/beans";
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
       xmlns:p="http://www.springframework.org/schema/p";
       xmlns:tx="http://www.springframework.org/schema/tx";
       xmlns:sec="http://www.springframework.org/schema/security";
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
       http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd";>


<bean id="contextSource" class="org.springframework.ldap.core.support.LdapContextSource">
  <property name="pooled" value="false"/>
  <property name="url" value="ldap://ldap-server.ts.lab"; />
  <property name="userDn" value="admin"/>
  <property name="password" value="${ldap.password}"/>
  <property name="baseEnvironmentProperties">
    <map>
      <entry key="com.sun.jndi.ldap.connect.timeout" value="3000" />
      <entry key="com.sun.jndi.ldap.read.timeout" value="3000" />
      <entry key="java.naming.security.authentication" value="simple" />
    </map>
  </property>
</bean>

<bean id="pooledContextSource"
  class="org.springframework.ldap.pool.factory.PoolingContextSource"
  p:minIdle="${ldap.pool.minIdle}"
  p:maxIdle="${ldap.pool.maxIdle}"
  p:maxActive="${ldap.pool.maxSize}"
  p:maxWait="${ldap.pool.maxWait}"
  p:timeBetweenEvictionRunsMillis="${ldap.pool.evictionPeriod}"
  p:minEvictableIdleTimeMillis="${ldap.pool.idleTime}"
  p:testOnBorrow="${ldap.pool.testOnBorrow}"
  p:testWhileIdle="${ldap.pool.testWhileIdle}"
  p:dirContextValidator-ref="dirContextValidator"
  p:contextSource-ref="contextSource" />
 
<bean id="dirContextValidator"
  class="org.springframework.ldap.pool.validation.DefaultDirContextValidator"
  p:base=""
  p:filter="objectclass=*">
  <property name="searchControls">
    <bean class="javax.naming.directory.SearchControls"
      p:timeLimit="1000"
      p:countLimit="1"
      p:searchScope="0"
      p:returningAttributes="" />
  </property>
</bean>

	<!--
		| This bean declares our AuthenticationManager.  The CentralAuthenticationService service bean
		| declared in applicationContext.xml picks up this AuthenticationManager by reference to its id, 
		| "authenticationManager".  Most deployers will be able to use the default AuthenticationManager
		| implementation and so do not need to change the class of this bean.  We include the whole
		| AuthenticationManager here in the userConfigContext.xml so that you can see the things you will
		| need to change in context.
		+-->
	<bean id="authenticationManager"
		class="org.jasig.cas.authentication.AuthenticationManagerImpl">
		
		<!-- Uncomment the metadata populator to allow clearpass to capture and cache the password
		     This switch effectively will turn on clearpass.
		<property name="authenticationMetaDataPopulators">
		   <list>
		      <bean class="org.jasig.cas.extension.clearpass.CacheCredentialsMetaDataPopulator">
		         <constructor-arg index="0" ref="credentialsCache" />
		      </bean>

			<bean class="org.jasig.cas.authentication.SamlAuthenticationMetaDataPopulator" />
		   </list>
		</property>
		 -->
		
		<!--
			| This is the List of CredentialToPrincipalResolvers that identify what Principal is trying to authenticate.
			| The AuthenticationManagerImpl considers them in order, finding a CredentialToPrincipalResolver which 
			| supports the presented credentials.
			|
			| AuthenticationManagerImpl uses these resolvers for two purposes.  First, it uses them to identify the Principal
			| attempting to authenticate to CAS /login .  In the default configuration, it is the DefaultCredentialsToPrincipalResolver
			| that fills this role.  If you are using some other kind of credentials than UsernamePasswordCredentials, you will need to replace
			| DefaultCredentialsToPrincipalResolver with a CredentialsToPrincipalResolver that supports the credentials you are
			| using.
			|
			| Second, AuthenticationManagerImpl uses these resolvers to identify a service requesting a proxy granting ticket. 
			| In the default configuration, it is the HttpBasedServiceCredentialsToPrincipalResolver that serves this purpose. 
			| You will need to change this list if you are identifying services by something more or other than their callback URL.
			+-->
		<property name="credentialsToPrincipalResolvers">
			<list>
				<!--
				<bean class="org.jasig.cas.authentication.principal.UsernamePasswordCredentialsToPrincipalResolver" >
					<property name="attributeRepository" ref="attributeRepository" />
				</bean>
				-->

				<bean class="org.jasig.cas.authentication.principal.HttpBasedServiceCredentialsToPrincipalResolver" />

				<bean class="org.jasig.cas.authentication.principal.CredentialsToLDAPAttributePrincipalResolver">
				      <property name="credentialsToPrincipalResolver">
				          <bean class="org.jasig.cas.authentication.principal.UsernamePasswordCredentialsToPrincipalResolver" />
				      </property>
				      <property name="filter" value="(uid=%u)" />
				      <property name="principalAttributeName" value="businessCategory" />
				      <property name="searchBase" value="ou=users,dc=ts,dc=lab" />
				      <property name="contextSource" ref="contextSource" />
				      <property name="attributeRepository">
				          <ref bean="attributeRepository" />
				      </property>
				</bean>
			</list>
		</property>

		<!--
			| Whereas CredentialsToPrincipalResolvers identify who it is some Credentials might authenticate, 
			| AuthenticationHandlers actually authenticate credentials.  Here we declare the AuthenticationHandlers that
			| authenticate the Principals that the CredentialsToPrincipalResolvers identified.  CAS will try these handlers in turn
			| until it finds one that both supports the Credentials presented and succeeds in authenticating.
			+-->
		<property name="authenticationHandlers">
			<list>
				<bean class="org.jasig.cas.authentication.handler.support.HttpBasedServiceCredentialsAuthenticationHandler"
					p:httpClient-ref="httpClient" />

				<bean class="org.jasig.cas.adaptors.ldap.BindLdapAuthenticationHandler"
				      p:filter="uid=%u"
				      p:searchBase="ou=users,dc=ts,dc=lab"
				      p:contextSource-ref="contextSource"
				      p:searchContextSource-ref="pooledContextSource" />

			</list>
		</property>
	</bean>


	<!--
	This bean defines the security roles for the Services Management application.  Simple deployments can use the in-memory version.
	More robust deployments will want to use another option, such as the Jdbc version.
	
	The name of this should remain "userDetailsService" in order for Spring Security to find it.
	 -->
	
    <sec:ldap-server id="ldapServer" url="ldap://ldap-server.ts.lab:389/";
                 manager-dn="cn=admin,dc=ts,dc=lab"
                 manager-password="Tibco44" />
    <sec:ldap-user-service id="userDetailsService" server-ref="ldapServer"
            user-search-base="cn=admins,dc=ts,dc=lab"
            user-search-filter="(uid={0})"/>

<!--
            group-search-base="cn=groups,dc=ts,dc=lab" group-role-attribute="cn"
            group-search-filter="(memberuid={0})"
-->


<!--  <bean id="attributeRepository" class="org.jasig.services.persondir.support.ldap.LdapPersonAttributeAndRoleDao"> -->
  <bean id="attributeRepository" class="org.jasig.services.persondir.support.ldap.LdapPersonAttributeDao">
      <property name="contextSource" ref="contextSource" />
      <property name="baseDN" value="ou=users,dc=ts,dc=lab" />
      <property name="requireAllQueryAttributes" value="true" />
      <property name="queryAttributeMapping">
          <map>
              <entry key="username" value="uid" />
          </map>
      </property>
      <property name="resultAttributeMapping">
          <map>
              <entry key="uid" value="username" />
              <entry key="givenname" value="first_name" />
              <entry key="sn" value="last_name" />
              <entry key="mail" value="email" />
            <!--  <entry key="authorities" value="authorities" /> -->
          </map>
      </property>
    <!--  <property name="ldapAuthoritiesPopulator" ref="ldapAuthoritiesPopulator" /> -->
  </bean>

<!--
  <bean id="ldapAuthoritiesPopulator" class="org.springframework.security.ldap.userdetails.DefaultLdapAuthoritiesPopulator">
      <constructor-arg ref="contextSource"/>
      <constructor-arg value="ou=users,dc=ts,dc=lab"/>
      <property name="groupRoleAttribute" value="cn"/>
      <property name="groupSearchFilter" value="(uniqueMember={0})" />
  </bean>

  <bean id="userDetailsService"
      class="org.springframework.security.cas.userdetails.GrantedAuthorityFromAssertionAttributesUserDetailsService">
      <constructor-arg >
          <list>
              <value>authorities</value>
          </list>
      </constructor-arg>
  </bean>
-->

<!-- END LDAP -->

<!-- DATABASE -->
	
<bean id="serviceRegistryDao" class="org.jasig.cas.services.JpaServiceRegistryDaoImpl"
   p:entityManagerFactory-ref="entityManagerFactory" />
 
    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="jpaVendorAdapter">
            <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                <property name="generateDdl" value="true"/>
                <property name="showSql" value="true" />
            </bean>
        </property>
        <property name="jpaProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
                <prop key="hibernate.hbm2ddl.auto">update</prop>
            </props>
        </property>
    </bean>
 
    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
        <property name="entityManagerFactory" ref="entityManagerFactory"/>
    </bean>
 
    <tx:annotation-driven transaction-manager="transactionManager"/>
 
    <bean
        id="dataSource"
        class="org.apache.commons.dbcp.BasicDataSource"
        p:driverClassName="com.mysql.jdbc.Driver"
        p:url="jdbc:mysql://ldap-server.ts.lab:3306/CAS?autoReconnect=true"
        p:password="${database.username}"
        p:username="${database.password}" />


  <bean id="auditTrailManager" class="com.github.inspektr.audit.support.Slf4jLoggingAuditTrailManager" />
  
  <bean id="healthCheckMonitor" class="org.jasig.cas.monitor.HealthCheckMonitor">
    <property name="monitors">
      <list>
        <bean class="org.jasig.cas.monitor.MemoryMonitor"
            p:freeMemoryWarnThreshold="10" />
        <bean class="org.jasig.cas.monitor.SessionMonitor"
            p:ticketRegistry-ref="ticketRegistry"
            p:serviceTicketCountWarnThreshold="5000"
            p:sessionCountWarnThreshold="100000" />
      </list>
    </property>
  </bean>

<!--
  <bean id="casAuthenticationProvider" class="org.springframework.security.cas.authentication.CasAuthenticationProvider"
        p:key="my_password_for_this_auth_provider_only"
        p:serviceProperties-ref="serviceProperties"
        p:authenticationUserDetailsService-ref="userDetailsService">
      <property name="ticketValidator">
          <bean class="org.jasig.cas.client.validation.Saml11TicketValidator">
              <constructor-arg index="0" value="${cas.securityContext.ticketValidator.casServerUrlPrefix}" />
          </bean>
      </property>
  </bean>
-->

</beans>

Reply via email to