-
Sep 6th, 2010, 03:34 AM
#1
ObjectDefinitionSource in spring security 3.0
Hi,
I used ObjectDefinitionSource in acegi now i am working on spring security 3.0.
I came to know that ObjectDefinitionSource changed to SecurityMetadataSource. I want a example for retriving from data base. Is it the same as SecurityMetadataSource or any difference. Any working example for this.
Thanks
Naveen
-
Sep 6th, 2010, 05:46 AM
#2
-
Sep 7th, 2010, 01:58 AM
#3
Dear Luke,
Thanks for the reply I saw the FAQ where it is written we have to implement the FilterChainProxy. Is it the similar way, what we use to do in ACEGI security or there is any difference. Can you provide me what i have to implement in security.xml.
Thanks
Naveen
-
Sep 14th, 2010, 03:44 AM
#4
Hi,
I am implementing the securityMetadataSource from database i am having in my xx-security.xml
<property name="securityMetadataSource" ref="mySecureResourceFilter" >
<bean id="mySecureResourceFilter" class="com.project.controller.MyFilterSecurityMeta dataSource">
in the java class i am having the code as below:
public MyFilterSecurityMetadataSource() {
try{
loadResourceDefine();
}
catch(Exception e){
}
}
public void loadResourceDefine() throws Exception {
this.resourceMap = new HashMap<String, Collection<ConfigAttribute>>();
System.out.println("We are in the loadResourceDefine");
for (RbacRoleMVO item:this.rbacRoleMService.findAll()){
System.out.println("We are in loop");
System.out.println("The value of item is :"+item.getRoleName());
Collection<ConfigAttribute> atts = new ArrayList<ConfigAttribute>();
ConfigAttribute ca = new SecurityConfig(item.getRoleName());
atts.add(ca);
List<RbacResourceMVO> tActionList = rbacResourceMService.findByWhere(item.getId());
for(RbacResourceMVO tAction:tActionList){
System.out.println("We are in 2 loop");
this.resourceMap.put(tAction.getResourceName(), atts);
}
}
System.out.println("We are out of loop");
}
public Collection<ConfigAttribute> getAttributes(Object object) {
String url = ((FilterInvocation)object).getRequestUrl();
Iterator<String> it = resourceMap.keySet().iterator();
while(it.hasNext()){
String resUrl = it.next();
if(urlMatcher.pathMatchesUrl(url, resUrl)){
return resourceMap.get(url);
}
}
return null;
}
Where as it is not loading the URLs from database and considering the default URL /** and matching with it. So that any URLs is checking as shown below.
Candidate is: '/nscconf.htm'; pattern is /**; matched=true
I am thinking it is accepting the default URLs how to stop using default. Is there any error in my code above.
Thanks,
Naveen
-
Sep 14th, 2010, 10:26 AM
#5
Are you sure the constructor is being called, and that the catch block which squashes any exceptions isn't actually suppressing display of a real exception?
Peter Mularien | Blog
Author, Spring Security 3 (Book) - Packt Publishing, Available in print and eBook form
SCJP 5, Oracle DBA
Any postings are my own opinion, and should not be attributed to my employer or clients.
-
Sep 14th, 2010, 11:15 PM
#6
Dear pume,
Thanks for the reply. I am getting the error at : for (RbacRoleMVO item:this.rbacRoleMService.findAll()){ here rbacRoleMService is writing null.
When i am doing the @Autowired for RbacRoleMService it is giving error.
Could not autowire where as for other services autowired is working fine.
This is a spring error i think. May i know how to solve this.
Thanks
Naveen
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules