-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi all, I use the last zkspring-security-3.0.jar library to secure my zk application. I worked on Domain Object Security (ACLs) and now i'm trying to integrate this in zk.
ZK have an utility class SecurityUtil.java that permit to interrogate the SpringSecurity mechanism to obtain information about permissions, See this for information.
Now when i call
SecurityUti.isAccessible("WRITE", domainObject)
All the needed objects are initialized by this code:
private static void initializeIfRequired() { if (_applicationContext != null) { return; } _applicationContext = SpringUtil.getApplicationContext(); Map map = new HashMap(); ApplicationContext context = _applicationContext; while (context != null) { map.putAll(context.getBeansOfType(AclService.class)); context = context.getParent(); } if (map.size() != 1) { throw new UiException( "Found incorrect number of AclService instances in application context - you must have only have one!"); } _aclService = (AclService) map.values().iterator().next(); map = _applicationContext.getBeansOfType(SidRetrievalStrategy.class); if (map.size() == 0) { _sidRetrievalStrategy = new SidRetrievalStrategyImpl(); } else if (map.size() == 1) { _sidRetrievalStrategy = (SidRetrievalStrategy) map.values().iterator().next(); } else { throw new UiException("Found incorrect number of SidRetrievalStrategy instances in application " + "context - you must have only have one!"); } map = _applicationContext.getBeansOfType(ObjectIdentityRetrievalStrategy.class); if (map.size() == 0) { _objectIdentityRetrievalStrategy = new ObjectIdentityRetrievalStrategyImpl(); } else if (map.size() == 1) { _objectIdentityRetrievalStrategy = (ObjectIdentityRetrievalStrategy) map.values().iterator().next(); } else { throw new UiException("Found incorrect number of ObjectIdentityRetrievalStrategy instances in " + "application context - you must have only have one!"); } }
but no initialization is present for permissionFactory.
The question is : Is this a bug or have I to initialize permissionFactory in another way?
At moment I solved this with a workaround, i rewrite the initializeIfRequired method and i inserted the initialization of the permissionFactory in this way:
if(permissionFactory==null){ permissionFactory= new DefaultPermissionFactory(); }
and now all works correcty.
Someone can help me? Thank you.
No one has ever had this problem or I was unclear in the exposition?
For this problem i opened an issue on zkspring google code project zkspring google code project.
I have also provided a simple solution to this issue.
Hello gesuinonapoli,
Actually I can not help because I have not happened yet, but I write for another purpose, I also want to apply security spring to my web project, but with connection to mysql database in this forum but nobody helps me or gives me codes clear to do so, took several weeks to try and so far I have not been able to achieve, if you so you can communicate you able to do my e [email protected] .... I would appreciate it.
I jaider2523 you can start following this two links:
1. Security Database Schema
2. Spring Security 3 database schemas for MySQL
the second one is a database security schema for mysql.
Then the the simple way to integrate spring-security and your mysql db is to put this into your applicationContext-security.xml.
This authentication-provider use a jdbc-user-service (but there 'are many others providers)
..... <security:authentication-provider> <security:jdbc-user-service data-source-ref="dataSource" authorities-by-username-query="INSERT HERE YOUR SELECT ON AUTHORITIES TABLE" users-by-username-query="INSERT HERE YOUR SELECT ON USER TABLE"/> <security:password-encoder hash="sha"> <security:salt-source user-property="login" /> </security:password-encoder> </security:authentication-provider> ...
Asked: 2011-04-10 11:52:26 +0800
Seen: 783 times
Last updated: Apr 20 '11