具有自定义OpenLDAP身份验证的CAS

具有自定义OpenLDAP身份验证的CAS,ldap,cas,Ldap,Cas,我需要编辑deployerConfigContext.xml以使用自定义ldap。我知道卡塔琳娜的错误 创建在ServletContext资源[/WEB-INF/deployerConfigContext.xml]中定义的名为“authenticationManager”的bean时出错:设置构造函数参数时无法解析对bean“ldapAuthenticationHandler”的引用;嵌套异常为org.springframework.beans.factory.BeanCreationExcep

我需要编辑deployerConfigContext.xml以使用自定义ldap。我知道卡塔琳娜的错误

创建在ServletContext资源[/WEB-INF/deployerConfigContext.xml]中定义的名为“authenticationManager”的bean时出错:设置构造函数参数时无法解析对bean“ldapAuthenticationHandler”的引用;嵌套异常为org.springframework.beans.factory.BeanCreationException:创建名为“ldapAuthenticationHandler”的bean时出错,该名称在ServletContext资源[/WEB-INF/deployerConfigContext.xml]:设置bean属性“principalIdAttribute”时无法解析对bean“mail”的引用;嵌套异常为org.springframework.beans.factory.NoSuchBeanDefinitionException:未定义名为“mail”的bean

你能帮我吗

My deployerConfigContext.xml:

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:c="http://www.springframework.org/schema/c"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:util="http://www.springframework.org/schema/util"
       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.2.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
       http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd
       http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">

    <!--
       | The authentication manager defines security policy for authentication by specifying at a minimum
       | the authentication handlers that will be used to authenticate credential. While the AuthenticationManager
       | interface supports plugging in another implementation, the default PolicyBasedAuthenticationManager should
       | be sufficient in most cases.
       +-->
    <bean id="authenticationManager" class="org.jasig.cas.authentication.PolicyBasedAuthenticationManager">
        <constructor-arg>
            <map>
                <!--
                   | IMPORTANT
                   | Every handler requires a unique name.
                   | If more than one instance of the same handler class is configured, you must explicitly
                   | set its name to something other than its default name (typically the simple class name).
                   -->
                <entry key-ref="proxyAuthenticationHandler" value-ref="proxyPrincipalResolver" />
                <entry key-ref="primaryAuthenticationHandler" value-ref="primaryPrincipalResolver" />
        <entry key-ref="ldapAuthenticationHandler" value-ref="usernamePasswordCredentialsResolver"/>
            </map>
        </constructor-arg>

        <!-- Uncomment the metadata populator to allow clearpass to capture and cache the password
             This switch effectively will turn on clearpass.
        <property name="authenticationMetaDataPopulators">
           <util:list>
              <bean class="org.jasig.cas.extension.clearpass.CacheCredentialsMetaDataPopulator"
                    c:credentialCache-ref="encryptedMap" />
           </util:list>
        </property>
        -->

        <!--
           | Defines the security policy around authentication. Some alternative policies that ship with CAS:
           |
           | * NotPreventedAuthenticationPolicy - all credential must either pass or fail authentication
           | * AllAuthenticationPolicy - all presented credential must be authenticated successfully
           | * RequiredHandlerAuthenticationPolicy - specifies a handler that must authenticate its credential to pass
           -->
        <property name="authenticationPolicy">
            <bean class="org.jasig.cas.authentication.AnyAuthenticationPolicy" />
        </property>
    </bean>

<!-- LDAP. -->

<bean id="ldapAuthenticationHandler"
class="org.jasig.cas.authentication.LdapAuthenticationHandler"
init-method="initialize"
p:principalIdAttribute-ref="mail" 
c:authenticator-ref="authenticator">
<property name="principalAttributeList">
<list>
<value>mail</value>
</list>
</property>
</bean>


<bean id="authenticator" class="org.ldaptive.auth.Authenticator"
c:resolver-ref="dnResolver"
c:handler-ref="authHandler" />
<bean id="dnResolver" class="org.ldaptive.auth.PooledSearchDnResolver"
p:baseDn="ou=employees,dc=microblog,dc=com"
p:subtreeSearch="true"
p:allowMultipleDns="false"
p:connectionFactory-ref="searchPooledLdapConnectionFactory"
p:userFilter="(uid={user})" />
<bean id="searchPooledLdapConnectionFactory"
class="org.ldaptive.pool.PooledConnectionFactory"
p:connectionPool-ref="searchConnectionPool" />
<bean id="searchConnectionPool" parent="abstractConnectionPool" />
<bean id="abstractConnectionPool" abstract="true"
class="org.ldaptive.pool.BlockingConnectionPool"
init-method="initialize"
destroy-method="close"
p:poolConfig-ref="ldapPoolConfig"
p:blockWaitTime="3000"
p:validator-ref="searchValidator"
p:pruneStrategy-ref="pruneStrategy"
p:connectionFactory-ref="connectionFactory" />
<bean id="ldapPoolConfig" class="org.ldaptive.pool.PoolConfig"
p:minPoolSize="3"
p:maxPoolSize="10"
p:validateOnCheckOut="false"
p:validatePeriodically="true"
p:validatePeriod="300" />
<bean id="connectionFactory" class="org.ldaptive.DefaultConnectionFactory"
p:connectionConfig-ref="connectionConfig" />
<bean id="connectionConfig" class="org.ldaptive.ConnectionConfig"
p:ldapUrl="ldap://localhost.microblog.com"
p:connectTimeout="3000"
p:useStartTLS="false"
p:sslConfig-ref="sslConfig" />
<bean id="sslConfig" class="org.ldaptive.ssl.SslConfig">
<property name="credentialConfig">
<bean class="org.ldaptive.ssl.X509CredentialConfig"
p:trustCertificates="/path/to/cert.cer" />
</property>
</bean>
<bean id="pruneStrategy" class="org.ldaptive.pool.IdlePruneStrategy"
p:prunePeriod="300"
p:idleTime="600" />
<bean id="searchValidator" class="org.ldaptive.pool.SearchValidator" />
<bean id="authHandler" class="org.ldaptive.auth.PooledBindAuthenticationHandler"
p:connectionFactory-ref="bindPooledLdapConnectionFactory" />
<bean id="bindPooledLdapConnectionFactory"
class="org.ldaptive.pool.PooledConnectionFactory"
p:connectionPool-ref="bindConnectionPool" />
<bean id="bindConnectionPool" parent="abstractConnectionPool" />

<!-- LDAP. -->

    <!-- Required for proxy ticket mechanism. -->
    <bean id="proxyAuthenticationHandler"
          class="org.jasig.cas.authentication.handler.support.HttpBasedServiceCredentialsAuthenticationHandler"
          p:httpClient-ref="httpClient" />

    <!--
       | TODO: Replace this component with one suitable for your enviroment.
       |
       | This component provides authentication for the kind of credential used in your environment. In most cases
       | credential is a username/password pair that lives in a system of record like an LDAP directory.
       | The most common authentication handler beans:
       |
       | * org.jasig.cas.authentication.LdapAuthenticationHandler
       | * org.jasig.cas.adaptors.jdbc.QueryDatabaseAuthenticationHandler
       | * org.jasig.cas.adaptors.x509.authentication.handler.support.X509CredentialsAuthenticationHandler
       | * org.jasig.cas.support.spnego.authentication.handler.support.JCIFSSpnegoAuthenticationHandler
       -->
    <bean id="primaryAuthenticationHandler"
          class="org.jasig.cas.authentication.AcceptUsersAuthenticationHandler">
        <property name="users">
            <map>
                <entry key="casuser" value="Mellon"/>
        <entry key="Venta" value="pass"/>
        <entry key="yorke" value="yorke68"/>
        <entry key="selway" value="selway67"/>
            </map>
        </property>
    </bean>

    <!-- Required for proxy ticket mechanism -->
    <bean id="proxyPrincipalResolver"
          class="org.jasig.cas.authentication.principal.BasicPrincipalResolver" />

    <!--
       | Resolves a principal from a credential using an attribute repository that is configured to resolve
       | against a deployer-specific store (e.g. LDAP).
       -->
    <bean id="primaryPrincipalResolver"
          class="org.jasig.cas.authentication.principal.PersonDirectoryPrincipalResolver" >
        <property name="attributeRepository" ref="attributeRepository" />
    </bean>

    <!--
    Bean that defines the attributes that a service may return.  This example uses the Stub/Mock version.  A real implementation
    may go against a database or LDAP server.  The id should remain "attributeRepository" though.
    +-->
    <bean id="attributeRepository" class="org.jasig.services.persondir.support.StubPersonAttributeDao"
            p:backingMap-ref="attrRepoBackingMap" />

    <util:map id="attrRepoBackingMap">
        <entry key="uid" value="uid" />
        <entry key="eduPersonAffiliation" value="eduPersonAffiliation" /> 
        <entry key="groupMembership" value="groupMembership" />
    </util:map>

    <!-- 
    Sample, in-memory data store for the ServiceRegistry. A real implementation
    would probably want to replace this with the JPA-backed ServiceRegistry DAO
    The name of this bean should remain "serviceRegistryDao".
    +-->
    <bean id="serviceRegistryDao" class="org.jasig.cas.services.InMemoryServiceRegistryDaoImpl"
            p:registeredServices-ref="registeredServicesList" />

    <util:list id="registeredServicesList">
        <bean class="org.jasig.cas.services.RegexRegisteredService"
              p:id="0" p:name="HTTP and IMAP" p:description="Allows HTTP(S) and IMAP(S) protocols"
              p:serviceId="^(https?|imaps?)://.*" p:evaluationOrder="10000001" />
        <!--
        Use the following definition instead of the above to further restrict access
        to services within your domain (including sub domains).
        Note that example.com must be replaced with the domain you wish to permit.
        This example also demonstrates the configuration of an attribute filter
        that only allows for attributes whose length is 3.
        -->
        <!--
        <bean class="org.jasig.cas.services.RegexRegisteredService">
            <property name="id" value="1" />
            <property name="name" value="HTTP and IMAP on example.com" />
            <property name="description" value="Allows HTTP(S) and IMAP(S) protocols on example.com" />
            <property name="serviceId" value="^(https?|imaps?)://([A-Za-z0-9_-]+\.)*example\.com/.*" />
            <property name="evaluationOrder" value="0" />
            <property name="attributeFilter">
              <bean class="org.jasig.cas.services.support.RegisteredServiceRegexAttributeFilter" c:regex="^\w{3}$" /> 
            </property>
        </bean>
        -->
    </util:list>

    <bean id="auditTrailManager" class="com.github.inspektr.audit.support.Slf4jLoggingAuditTrailManager" />

    <bean id="healthCheckMonitor" class="org.jasig.cas.monitor.HealthCheckMonitor" p:monitors-ref="monitorsList" />

    <util:list id="monitorsList">
      <bean class="org.jasig.cas.monitor.MemoryMonitor" p:freeMemoryWarnThreshold="10" />
      <!--
        NOTE
        The following ticket registries support SessionMonitor:
          * DefaultTicketRegistry
          * JpaTicketRegistry
        Remove this monitor if you use an unsupported registry.
      -->
      <bean class="org.jasig.cas.monitor.SessionMonitor"
          p:ticketRegistry-ref="ticketRegistry"
          p:serviceTicketCountWarnThreshold="5000"
          p:sessionCountWarnThreshold="100000" />
    </util:list>
</beans>
你有: p:principalIdAttribute ref=“邮件”

为什么?

改为: p:principalIdAttribute=“邮件”

然后看看“-ref”对Spring意味着什么

dn: dc=microblog,dc=com
objectClass: top
objectClass: dcObject
objectClass: organization
o: microblog
dc: microblog
structuralObjectClass: organization
entryUUID: bcb12420-99f6-1035-99c1-b36f1cbbab10
creatorsName: cn=admin,dc=microblog,dc=com
createTimestamp: 20160418211744Z
entryCSN: 20160418211744.739498Z#000000#000#000000
modifiersName: cn=admin,dc=microblog,dc=com
modifyTimestamp: 20160418211744Z

dn: cn=admin,dc=microblog,dc=com
objectClass: simpleSecurityObject
objectClass: organizationalRole
cn: admin
description: LDAP administrator
userPassword:: e1NTSEF9SnpjVjlRMGdSUlBIK3pnZFhpMmVMZzVMaWhJQkhYS3o=
structuralObjectClass: organizationalRole
entryUUID: bcb1687c-99f6-1035-99c2-b36f1cbbab10
creatorsName: cn=admin,dc=microblog,dc=com
createTimestamp: 20160418211744Z
entryCSN: 20160418211744.741251Z#000000#000#000000
modifiersName: cn=admin,dc=microblog,dc=com
modifyTimestamp: 20160418211744Z

dn: ou=employees,dc=microblog,dc=com
objectClass: organizationalUnit
ou: employees
structuralObjectClass: organizationalUnit
entryUUID: ee39d9a2-9b6c-1035-9697-f962cc7890d6
creatorsName: cn=admin,dc=microblog,dc=com
createTimestamp: 20160420175619Z
entryCSN: 20160420175619.620665Z#000000#000#000000
modifiersName: cn=admin,dc=microblog,dc=com
modifyTimestamp: 20160420175619Z

dn: ou=customers,dc=microblog,dc=com
objectClass: organizationalUnit
ou: customers
structuralObjectClass: organizationalUnit
entryUUID: ee39f6b2-9b6c-1035-9698-f962cc7890d6
creatorsName: cn=admin,dc=microblog,dc=com
createTimestamp: 20160420175619Z
entryCSN: 20160420175619.621411Z#000000#000#000000
modifiersName: cn=admin,dc=microblog,dc=com
modifyTimestamp: 20160420175619Z

dn: ou=suppliers,dc=microblog,dc=com
objectClass: organizationalUnit
ou: suppliers
structuralObjectClass: organizationalUnit
entryUUID: ee3b00fc-9b6c-1035-9699-f962cc7890d6
creatorsName: cn=admin,dc=microblog,dc=com
createTimestamp: 20160420175619Z
entryCSN: 20160420175619.628227Z#000000#000#000000
modifiersName: cn=admin,dc=microblog,dc=com
modifyTimestamp: 20160420175619Z

dn: ou=departments,dc=microblog,dc=com
objectClass: organizationalUnit
ou: departments
structuralObjectClass: organizationalUnit
entryUUID: ee402492-9b6c-1035-969a-f962cc7890d6
creatorsName: cn=admin,dc=microblog,dc=com
createTimestamp: 20160420175619Z
entryCSN: 20160420175619.661905Z#000000#000#000000
modifiersName: cn=admin,dc=microblog,dc=com
modifyTimestamp: 20160420175619Z

dn: ou=management,dc=microblog,dc=com
objectClass: organizationalUnit
ou: departments
ou: management
structuralObjectClass: organizationalUnit
entryUUID: ee4032d4-9b6c-1035-969b-f962cc7890d6
creatorsName: cn=admin,dc=microblog,dc=com
createTimestamp: 20160420175619Z
entryCSN: 20160420175619.662271Z#000000#000#000000
modifiersName: cn=admin,dc=microblog,dc=com
modifyTimestamp: 20160420175619Z

dn: ou=edition,dc=microblog,dc=com
objectClass: organizationalUnit
ou: departments
ou: edition
structuralObjectClass: organizationalUnit
entryUUID: ee404cec-9b6c-1035-969c-f962cc7890d6
creatorsName: cn=admin,dc=microblog,dc=com
createTimestamp: 20160420175619Z
entryCSN: 20160420175619.662939Z#000000#000#000000
modifiersName: cn=admin,dc=microblog,dc=com
modifyTimestamp: 20160420175619Z

dn: ou=users,dc=microblog,dc=com
objectClass: organizationalUnit
ou: departments
ou: users
structuralObjectClass: organizationalUnit
entryUUID: ee4058f4-9b6c-1035-969d-f962cc7890d6
creatorsName: cn=admin,dc=microblog,dc=com
createTimestamp: 20160420175619Z
entryCSN: 20160420175619.663248Z#000000#000#000000
modifiersName: cn=admin,dc=microblog,dc=com
modifyTimestamp: 20160420175619Z

dn: uid=yorke,ou=employees,dc=microblog,dc=com
objectClass: inetOrgPerson
uid: yorke
cn: Thom Yorke
sn: Yorke
title: Administrador
userPassword:: eW9ya2U2OA==
employeeNumber: 1
mail: yorke@microblog.com
structuralObjectClass: inetOrgPerson
entryUUID: c028c3cc-a32b-1035-96a1-f962cc7890d6
creatorsName: cn=admin,dc=microblog,dc=com
createTimestamp: 20160430142954Z
entryCSN: 20160430142954.348299Z#000000#000#000000
modifiersName: cn=admin,dc=microblog,dc=com
modifyTimestamp: 20160430142954Z

dn: uid=brien,ou=employees,dc=microblog,dc=com
objectClass: inetOrgPerson
uid: brien
cn: Ed Brien
sn: Brien
title: Editor
userPassword:: YnJpZW42OA==
employeeNumber: 2
mail: brien@microblog.com
structuralObjectClass: inetOrgPerson
entryUUID: c0292592-a32b-1035-96a2-f962cc7890d6
creatorsName: cn=admin,dc=microblog,dc=com
createTimestamp: 20160430142954Z
entryCSN: 20160430142954.350802Z#000000#000#000000
modifiersName: cn=admin,dc=microblog,dc=com
modifyTimestamp: 20160430142954Z

dn: uid=green,ou=employees,dc=microblog,dc=com
objectClass: inetOrgPerson
uid: green
cn: Johnny Green
sn: Green
title: Autor
userPassword:: Z3JlZW43MQ==
employeeNumber: 3
mail: green@microblog.com
structuralObjectClass: inetOrgPerson
entryUUID: c0298924-a32b-1035-96a3-f962cc7890d6
creatorsName: cn=admin,dc=microblog,dc=com
createTimestamp: 20160430142954Z
entryCSN: 20160430142954.353349Z#000000#000#000000
modifiersName: cn=admin,dc=microblog,dc=com
modifyTimestamp: 20160430142954Z

dn: uid=selway,ou=employees,dc=microblog,dc=com
objectClass: inetOrgPerson
uid: selway
cn: Phil Selway
sn: Selway
title: Seguidor
userPassword:: c2Vsd2F5Njc=
employeeNumber: 4
mail: selway@microblog.com
structuralObjectClass: inetOrgPerson
entryUUID: c029b200-a32b-1035-96a4-f962cc7890d6
creatorsName: cn=admin,dc=microblog,dc=com
createTimestamp: 20160430142954Z
entryCSN: 20160430142954.354397Z#000000#000#000000
modifiersName: cn=admin,dc=microblog,dc=com
modifyTimestamp: 20160430142954Z

dn: uid=tqCL,ou=customers,dc=microblog,dc=com
objectClass: inetOrgPerson
uid: tqCL
cn: Tammy Queen
sn: Queen
title: Director
userPassword:: cXdlcnR5
postalAddress: 33 Russell Square, London, UK
telephoneNumber: +1 (210) 354-1661
mail: tqCL@my-ad.com
structuralObjectClass: inetOrgPerson
entryUUID: c7bef172-a32d-1035-96ba-f962cc7890d6
creatorsName: cn=admin,dc=microblog,dc=com
createTimestamp: 20160430144426Z
entryCSN: 20160430144426.070019Z#000000#000#000000
modifiersName: cn=admin,dc=microblog,dc=com
modifyTimestamp: 20160430144426Z

dn: uid=aiCL,ou=customers,dc=microblog,dc=com
objectClass: inetOrgPerson
uid: aiCL
cn: Andrew Ikard
sn: Ikard
title: Director
userPassword:: cXdlcnR5
postalAddress: Calle Martins Fontes, 71, Sao Paulo, Brazil
telephoneNumber: +1 (602) 433-5533
mail: aiCL@advert.com
structuralObjectClass: inetOrgPerson
entryUUID: c7bf2f2a-a32d-1035-96bb-f962cc7890d6
creatorsName: cn=admin,dc=microblog,dc=com
createTimestamp: 20160430144426Z
entryCSN: 20160430144426.071598Z#000000#000#000000
modifiersName: cn=admin,dc=microblog,dc=com
modifyTimestamp: 20160430144426Z

dn: uid=daPR,ou=suppliers,dc=microblog,dc=com
objectClass: inetOrgPerson
uid: daPR
cn: Dana Adams
sn: Adams
title: Comercial
userPassword:: cXdlcnR5
postalAddress: 765 4th Avenue, New York, USA
telephoneNumber: +44 1462 480000
mail: daPR@router-inc.com
structuralObjectClass: inetOrgPerson
entryUUID: c7bf53b0-a32d-1035-96bc-f962cc7890d6
creatorsName: cn=admin,dc=microblog,dc=com
createTimestamp: 20160430144426Z
entryCSN: 20160430144426.072534Z#000000#000#000000
modifiersName: cn=admin,dc=microblog,dc=com
modifyTimestamp: 20160430144426Z

dn: uid=akPR,ou=suppliers,dc=microblog,dc=com
objectClass: inetOrgPerson
uid: akPR
cn: Allan Kite
sn: Kite
title: Comercial
userPassword:: cXdlcnR5
postalAddress: 17 Yale Street, London, UK
telephoneNumber: +1 819-623-7999
mail: akPR@o-internet.com
structuralObjectClass: inetOrgPerson
entryUUID: c7bf6328-a32d-1035-96bd-f962cc7890d6
creatorsName: cn=admin,dc=microblog,dc=com
createTimestamp: 20160430144426Z
entryCSN: 20160430144426.072930Z#000000#000#000000
modifiersName: cn=admin,dc=microblog,dc=com
modifyTimestamp: 20160430144426Z