Announcement Announcement Module
Collapse
No announcement yet.
ObjectDefinitionSource in spring security 3.0 Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

  • #2
    Please read the FAQ.

    Comment


    • #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

      Comment


      • #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

        Comment


        • #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?

          Comment


          • #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

            Comment

            Working...
            X