Overriding attributeRepository using War overlay

55 views
Skip to first unread message

Sergei Kalmykov

unread,
Sep 15, 2016, 8:59:46 AM9/15/16
to CAS Community
Hi,

I'm playing with 5.0.0.RC2-SNAPSHOT, trying to migrate from CAS 4.1.0

With old xml configs and deployerConfigContext.xml I had my own specific attributeRepository bean in xml. It just worked with war overlay, all my code was embedded into cas-server via xml beans and component-scan in xml.
With spring-boot I wanted to repeat the same thing. I thought to use 

@ConditionalOnMissingBean(name = "attributeRepository")

and define my own bean via xml component-scan.
Unfortunately, it doesn't work. I suppose, CasCoreAuthenticationConfiguration have too high @Order and requires attributeRepository, so my component-scan starts too late.

@Order(value = Ordered.HIGHEST_PRECEDENCE) on my configuration and spring.autoconfigure.exclude doesn't help. The only workaround i found is to create my own boot application and totaly exclude CasPersonDirectoryAttributeRepositoryConfiguration with excludeFilters.

This way seems to be strange, I hope I'm missing something, but what?

Thanks!

Misagh Moayyed

unread,
Sep 15, 2016, 12:15:41 PM9/15/16
to Sergei Kalmykov, CAS Community

What does your old attribute repository bean look like? 


-- 
Misagh
--
You received this message because you are subscribed to the Google Groups "CAS Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cas-user+u...@apereo.org.
To post to this group, send email to cas-...@apereo.org.
Visit this group at https://groups.google.com/a/apereo.org/group/cas-user/.
To view this discussion on the web visit https://groups.google.com/a/apereo.org/d/msgid/cas-user/2004031b-afc0-4a06-8d61-5e204230f99b%40apereo.org.
For more options, visit https://groups.google.com/a/apereo.org/d/optout.

Sergei Kalmykov

unread,
Sep 16, 2016, 3:31:57 AM9/16/16
to Misagh Moayyed, CAS Community
I have one table with single row for one person. But it has multiple "username" columns like email, phone and nickname. And each of them have to exist in sql query. But SingleRowJdbcPersonAttributeDao#toSeedMap() generates WHERE clause like 'username = ?'.
Of course, I can use aggregated respository of multiple SingleRowJdbcPersonAttributeDaos and execute 3 queries with 'phone = ?', 'email = ?' etc instead of single sql query. But it seems wrong way to me.

2016-09-15 19:15 GMT+03:00 Misagh Moayyed <mmoa...@unicon.net>:

What does your old attribute repository bean look like? 


-- 
Misagh

From: Sergei Kalmykov <kalmyko...@gmail.com>
Reply: Sergei Kalmykov <kalmyko...@gmail.com>
Date: September 15, 2016 at 5:29:51 PM
To: CAS Community <cas-...@apereo.org>
Subject:  [cas-user] Overriding attributeRepository using War overlay
Hi,

I'm playing with 5.0.0.RC2-SNAPSHOT, trying to migrate from CAS 4.1.0

With old xml configs and deployerConfigContext.xml I had my own specific attributeRepository bean in xml. It just worked with war overlay, all my code was embedded into cas-server via xml beans and component-scan in xml.
With spring-boot I wanted to repeat the same thing. I thought to use 

@ConditionalOnMissingBean(name = "attributeRepository")

and define my own bean via xml component-scan.
Unfortunately, it doesn't work. I suppose, CasCoreAuthenticationConfiguration have too high @Order and requires attributeRepository, so my component-scan starts too late.

@Order(value = Ordered.HIGHEST_PRECEDENCE) on my configuration and spring.autoconfigure.exclude doesn't help. The only workaround i found is to create my own boot application and totaly exclude CasPersonDirectoryAttributeRepositoryConfiguration with excludeFilters.

This way seems to be strange, I hope I'm missing something, but what?

Thanks!
--
You received this message because you are subscribed to the Google Groups "CAS Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cas-user+unsubscribe@apereo.org.



--
С уважением, Калмыков Сергей.

Sergei Kalmykov

unread,
Sep 16, 2016, 3:50:48 AM9/16/16
to Misagh Moayyed, CAS Community
here is code for such dao:

public class MultipleLoginColumnsSingleRowJdbcPersonAttributeDao extends SingleRowJdbcPersonAttributeDao {

public MultipleLoginColumnsSingleRowJdbcPersonAttributeDao(final DataSource ds, final String sql) {
super(ds, sql);
setQueryType(QueryType.OR);
}

@Override
protected Map<String, List<Object>> toSeedMap(String uid) {
final List<Object> values = Collections.singletonList((Object) uid);
final Map<String, List<Object>> seed = new HashMap<>();
for (String usernameKey : this.getQueryAttributeMapping().keySet()) {
seed.put(usernameKey, values);
}
if (this.logger.isDebugEnabled()) {
this.logger.debug("Created seed map='" + seed + "' for uid='" + uid + "'");
}
return seed;
}
}

2016-09-16 10:31 GMT+03:00 Sergei Kalmykov <kalmyko...@gmail.com>:
I have one table with single row for one person. But it has multiple "username" columns like email, phone and nickname. And each of them have to exist in sql query. But SingleRowJdbcPersonAttributeDao#toSeedMap() generates WHERE clause like 'username = ?'.
Of course, I can use aggregated respository of multiple SingleRowJdbcPersonAttributeDaos and execute 3 queries with 'phone = ?', 'email = ?' etc instead of single sql query. But it seems wrong way to me.
2016-09-15 19:15 GMT+03:00 Misagh Moayyed <mmoa...@unicon.net>:

What does your old attribute repository bean look like? 


-- 
Misagh

From: Sergei Kalmykov <kalmyko...@gmail.com>
Reply: Sergei Kalmykov <kalmyko...@gmail.com>
Date: September 15, 2016 at 5:29:51 PM
To: CAS Community <cas-...@apereo.org>
Subject:  [cas-user] Overriding attributeRepository using War overlay
Hi,

I'm playing with 5.0.0.RC2-SNAPSHOT, trying to migrate from CAS 4.1.0

With old xml configs and deployerConfigContext.xml I had my own specific attributeRepository bean in xml. It just worked with war overlay, all my code was embedded into cas-server via xml beans and component-scan in xml.
With spring-boot I wanted to repeat the same thing. I thought to use 

@ConditionalOnMissingBean(name = "attributeRepository")

and define my own bean via xml component-scan.
Unfortunately, it doesn't work. I suppose, CasCoreAuthenticationConfiguration have too high @Order and requires attributeRepository, so my component-scan starts too late.

@Order(value = Ordered.HIGHEST_PRECEDENCE) on my configuration and spring.autoconfigure.exclude doesn't help. The only workaround i found is to create my own boot application and totaly exclude CasPersonDirectoryAttributeRepositoryConfiguration with excludeFilters.

This way seems to be strange, I hope I'm missing something, but what?

Thanks!
--
You received this message because you are subscribed to the Google Groups "CAS Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cas-user+u...@apereo.org.
--
С уважением, Калмыков Сергей.
Reply all
Reply to author
Forward
0 new messages