Hi All,
I am tryting to cobble up a resolver that in my understanding returns a
principal based on one single piece of id, namely user id.
I am trying to modify the existing CredentialsToLdapAttributePrincipalResolver
and
AbstractLdapPersonDirectoryCredentialsToPrincipalResolver.
First things first: Is it an accpeted practice? My modified source files retain
all credits to the respective authors, and I am not making money out of them.
Right now, it is in such a crude stage that I doubt it will be accepted, but I
do plan to share them with the community, if I am successful, and if it is
useful.
Progressing very slowly, and now I am stuck with this.
Trained eyes can probably tell or make a guess based on their experiences.
Especially the original authors (Scott Battaglia, Jan Van der Velpen and
Marvin S. Addison).
Error log:
//-------------------------------------
Error creating bean with name
'org.jasig.cas.authentication.principal.CredentialsToJdbcAttributePrincipalResolver#4f5264db'
defined in
ServletContext resource [/WEB-INF/deployerConfigContext.xml]: Initialization of
bean failed; nested exception is
org.springframework.beans.factory.BeanInitializationException:
Bean state is invalid: jdbcTemplate - may not be null; searchBase - may not be
null
//------------------------------------
I changed a method in
AbstractLdapPersonDirectoryCredentialsToPrincipalResolver.java to make a Jdbc
version:
//Method to set the datasource and generate a JdbcTemplate.
//@param dataSource the datasource to use.
public final void setContextSource(final DataSource dataSource) {
this.jdbcTemplate = new JdbcTemplate(dataSource);
}
Earlier, I had made a name change:
/** JdbcTemplate to execute jdbc queries. */
@NotNull
private JdbcTemplate jdbcTemplate;
Some items from the deployerConfigContext:
//----------------------------------------------------
<property name="credentialsToPrincipalResolvers">
<list>
<!-- Coming from parentCAS -->
<bean
class="org.jasig.cas.authentication.principal.CredentialsToJdbcAttributePrincipalResolver">
<property name="credentialsToPrincipalResolver">
<bean
class="myorg.cas.PrincipalBearingCredentialsToPrincipalResolver" />
</property>
<property name="filter" value="(mappingField=%u)" />
<property name="principalAttributeName" value="userId" />
<property name="tableUserTable"><value>userTable</value></property>
<property name="fieldUserId"><value>userId</value></property>
<property name="fieldEmail"><value>email</value></property>
</bean>
<!-- For local log in -->
<bean
class="org.jasig.cas.authentication.principal.UsernamePasswordCredentialsToPrincipalResolver"
/>
</list>
</property>
<property name="authenticationHandlers">
<list>
<!-- authentication from parentCAS -->
<bean class="org.myorg.PrincipalBearingCredentialsAuthenticationHandler"/>
<!-- Local -->
<bean
class="org.jasig.cas.adaptors.jdbc.SearchModeSearchDatabaseAuthenticationHandler">
<property name="tableUserTable"><value>userTable</value></property>
<property name="fieldUserId"><value>userId</value></property>
<property name="fieldEmail"><value>email</value></property>
<property name="dataSource" ref="dataSource"/>
</bean>
<bean
class="org.jasig.cas.adaptors.jdbc.QueryDatabaseAuthenticationHandler">
<property name="dataSource" ref="dataSource" />
<property name="sql" value="select email from userTable where
lower(userId) = lower(?)" />
</bean>
</list>
</property>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
...
...
</bean>
<bean id="attributeRepository"
class="org.jasig.services.persondir.support.StubPersonAttributeDao">
<property name="backingMap">
<map>
<entry key="uid" value="uid" />
<entry key="eduPersonAffiliation" value="eduPersonAffiliation" />
<entry key="groupMembership" value="groupMembership" />
</map>
</property>
</bean>
<bean id="userDetailsService"
class="org.springframework.security.userdetails.memory.InMemoryDaoImpl">
<property name="userMap">
<value>
</value>
</property>
</bean>
//--------------------------------------
Now, what did I do (or rather, didn't do) to deserve "Bean state is invalid"
error?
In the original CredentialsToLDAPAttributePrincipalResolver, I changed
resolveFromLdap to make "resolveFromJdbc", basically creating a Jdbc
connection, executing it and returning a principal.
**
I am sorry for a long post and I thank you for taking time to read.
Cheers.
--
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