欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

Spring security 3.1 +JSF 2.0 . problem with

系統 1809 0

Hy .What i am trying to do is to integrate Spring security with a Jsf+spring IOC +hibernate application.I have managed to set the login page and filter some other pages.So far so good, but when i tried to put @Secured or @PreAuthorize annotation on methods inside managedBeans (inside Dao's the annotation do work), i realized they do absolutely nothing. I have read that i need FORCE class proxies. Spring uses proxy based aop,the managed bean implements an interface hence jdk dynamic proxy instead of class proxy is used. So i did this in my config file:

      
        <
      
      
        beans 
      
      
        xmlns
      
      
        ="http://www.springframework.org/schema/beans"
      
      
        

xmlns:xsi
      
      
        ="http://www.w3.org/2001/XMLSchema-instance"
      
      
        

    xmlns:aop
      
      
        ="http://www.springframework.org/schema/aop"
      
      
        **    

xsi:schemaLocation
      
      
        ="http://www.springframework.org/schema/beans 

http://www.springframework.org/schema/beans/spring-beans-2.5.xsd         

http://www.springframework.org/schema/aop 

    http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"
      
      
        >
      
      
        <
      
      
        aop:aspectj-autoproxy 
      
      
        proxy-target-class
      
      
        ="true"
      
      
        />
      
      
        

 //the rest of the beans

 
      
      
        </
      
      
        beans
      
      
        >
      
    

The applicationContext-security Xml looks like this:

      
        <?
      
      
        xml version="1.0" encoding="UTF-8"
      
      
        ?>
      
      
        <!--
      
      
         - Sample namespace-based configuration - - $Id: applicationContext-security.xml 

3019 2008-05-01 17:51:48Z luke_t $ 
      
      
        -->
      
      
        <
      
      
        beans:beans 
      
      
        xmlns
      
      
        ="http://www.springframework.org/schema/security"
      
      
        

xmlns:beans
      
      
        ="http://www.springframework.org/schema/beans"
      
      
         xmlns:xsi
      
      
        ="http://www.w3.org/2001/XMLSchema-instance"
      
      
        

xsi:schemaLocation
      
      
        ="http://www.springframework.org/schema/beans

       http://www.springframework.org/schema/beans/spring-beans-3.0.xsd

       http://www.springframework.org/schema/security

       http://www.springframework.org/schema/security/spring-security-3.1.xsd"
      
      
        >
      
      
        <
      
      
        global-method-security 
      
      
        secured-annotations
      
      
        ="enabled"
      
      
          jsr250-annotations
      
      
        ="enabled"
      
      
        />
      
      
        <
      
      
        http 
      
      
        pattern
      
      
        ="/css/**"
      
      
         security
      
      
        ="none"
      
      
        />
      
      
        <
      
      
        http 
      
      
        pattern
      
      
        ="/pages/login.xhtml"
      
      
         security
      
      
        ="none"
      
      
        />
      
      
        <
      
      
        http 
      
      
        auto-config
      
      
        ='false'
      
      
        >
      
      
        <
      
      
        intercept-url 
      
      
        pattern
      
      
        ="/pages/customer/**"
      
      
         access
      
      
        ='ROLE_SITE_ADMIN'
      
      
        />
      
      
        <
      
      
        intercept-url 
      
      
        pattern
      
      
        ="/pages/department/overhead*"
      
      
         access
      
      
        ='ROLE_SITE_ADMIN'
      
      
        />
      
      
        <
      
      
        intercept-url 
      
      
        pattern
      
      
        ="/**"
      
      
        

        access
      
      
        ='ROLE_SITE_ADMIN,ROLE_PROJECT_MANAGER,ROLE_DEPARTMENT_MANAGER,ROLE_ACCOUNTING'
      
      
        />
      
      
        <
      
      
        form-login 
      
      
        login-page
      
      
        ="/pages/login.xhtml"
      
      
        

        default-target-url
      
      
        ='/pages/reports.xhtml'
      
      
         always-use-default-target
      
      
        ='true'
      
      
        

        authentication-failure-handler-ref
      
      
        ="userLoginService"
      
      
        />
      
      
        <
      
      
        logout 
      
      
        invalidate-session
      
      
        ="true"
      
      
         logout-success-url
      
      
        ="/pages/login.xhtml"
      
      
        />
      
      
        </
      
      
        http
      
      
        >
      
      
        <
      
      
        authentication-manager
      
      
        >
      
      
        <
      
      
        authentication-provider 
      
      
        user-service-ref
      
      
        ='userLoginService'
      
      
        >
      
      
        <
      
      
        password-encoder 
      
      
        hash
      
      
        ="md5"
      
      
        />
      
      
        </
      
      
        authentication-provider
      
      
        >
      
      
        </
      
      
        authentication-manager
      
      
        >
      
      
        <
      
      
        beans:bean 
      
      
        id
      
      
        ="userLoginService"
      
      
         class
      
      
        ="com.evozon.demo.bean.SecureLoginService"
      
      
        >
      
      
        <
      
      
        beans:property 
      
      
        name
      
      
        ="defaultFailureUrl"
      
      
         value
      
      
        ="/pages/login.xhtml"
      
      
        />
      
      
        <
      
      
        beans:property 
      
      
        name
      
      
        ="userDao"
      
      
         ref
      
      
        ="userDao"
      
      
        />
      
      
        <
      
      
        beans:property 
      
      
        name
      
      
        ="loginReportDao"
      
      
         ref
      
      
        ="loginReportDao"
      
      
        />
      
      
        </
      
      
        beans:bean
      
      
        >
      
      
        </
      
      
        beans:beans
      
      
        >
      
    

Can someone tell my why the annotations do not work inside a managed bean,and how to resolve the problem ? ex:

      
        @PreAuthorize("ROLE_PROJECT_MANAGER")

public void aproveVacation(Vacation vacation) {...}
      
    

?

?

?

?

Answer:

The problem has been solved.The solution is to transform the Managed beans to Spring beans. Here is how :
web.xml does not need the jsf listener only the sprin ones :

      
        <
      
      
        listener
      
      
        >
      
      
        <
      
      
        listener-class
      
      
        >
      
      org.springframework.web.context.ContextLoaderListener
      
        </
      
      
        listener-class
      
      
        >
      
      
        </
      
      
        listener
      
      
        >
      
      
        <
      
      
        listener
      
      
        >
      
      
        <
      
      
        listener-class
      
      
        >
      
      org.springframework.web.context.request.RequestContextListener
      
        </
      
      
        listener-class
      
      
        >
      
      
        </
      
      
        listener
      
      
        >
      
    

The application context need this config to work at first :

      
        <
      
      
        beans 
      
      
        xmlns
      
      
        ="http://www.springframework.org/schema/beans"
      
      
        

xmlns:xsi
      
      
        ="http://www.w3.org/2001/XMLSchema-instance"
      
      
         xmlns:aop
      
      
        ="http://www.springframework.org/schema/aop"
      
      
        

xmlns:tx
      
      
        ="http://www.springframework.org/schema/tx"
      
      
         xmlns:context
      
      
        ="http://www.springframework.org/schema/context"
      
      
        

xsi:schemaLocation
      
      
        ="http://www.springframework.org/schema/beans 

http://www.springframework.org/schema/beans/spring-beans-2.5.xsd         

http://www.springframework.org/schema/aop 

http://www.springframework.org/schema/aop/spring-aop-3.0.xsd

http://www.springframework.org/schema/tx 

http://www.springframework.org/schema/tx/spring-tx-3.0.xsd

 http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"
      
      
        >
      
      
        <
      
      
        context:component-scan 
      
      
        base-package
      
      
        ="com.company.demo.bean"
      
      
        />
      
      
        <
      
      
        context:annotation-config 
      
      
        />
      
      
        <
      
      
        aop:config 
      
      
        proxy-target-class
      
      
        ="true"
      
      
        />
      
      
        

//other configs


      
      
        </
      
      
        beans
      
      
        >
      
    

Note that the first two need to define the base package for the spring beans (for the Components) and that the beans are annotated.The third config is needed to force the class proxy, here is why you need that .
Ok.once we know that we change the annotations from jsf managedBeans to Spring components :

      
        @ManagedBean

@SessionScoped


      
      
        public
      
      
        class
      
      
         UserLoginBean {



@ManagedProperty(name 
      
      = "userDao", value = "#{userDao}"
      
        )


      
      
        private
      
      
         UserDao userDao; 

}   
      
    

to:

      
        @Component

@Scope(
      
      "session"
      
        )

@Qualifier(
      
      "userLoginBean"
      
        )


      
      
        public
      
      
        class
      
      
         UserLoginBean  {



@Autowired


      
      
        private
      
      
         UserDao userDao;

}     
      
    

That's all.If you have already this config and doesn't work you should set <aop:config proxy-target-class="true" /> into your applicationContext.xml.

?

PS:if nothing happened, you can change the

      
        <
      
      
        sec:global-method-security 
      
      
        secured-annotations
      
      
        ="enabled"
      
      
         jsr250-annotations
      
      
        ="enabled"
      
      
        >
      
      
        </
      
      
        sec:global-method-security
      
      
        >
      
    

to

      
        <
      
      
        sec:global-method-security 
      
      
        pre-post-annotations
      
      
        ="enabled"
      
      
        >
      
      
        </
      
      
        sec:global-method-security
      
      
        >
      
    

?

Spring security 3.1 +JSF 2.0 . problem with annotating methods in ManagedBeans?


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 国产在线视频色综合 | 视频精品一区 | 一级毛片一 | 91精品国产综合久久精品 | youjizz欧美| 欧美第一视频 | 六月丁香婷婷天天在线 | 91免费看片| 九九99在线视频 | 亚洲午夜精品国产电影在线观看 | 免费看污又色又爽又黄视频 | 成人性爱视频在线观看 | 久草在线在线观看 | 精产国产伦理一二三区 | 亚洲福利 | 欧美日韩一区二区三区在线观看 | 色综合久久久久久久久五月性色 | 香蕉国产成版人视频在线观看 | 9久热这里只有精品视频在线观看 | www.黄色大片 | 日韩亚洲一区二区 | 新神奇四侠免费完整版在线观看 | 动漫福利在线观看 | 久久久.com | 国产日韩精品一区 | 天天色官网 | 欧美性爽xxxⅹbbbb | 欧美一级做a爰片免费视频 亚洲男人的天堂久久精品 色吟av | 国产精品亚洲综合 | 欧美成人生活片 | 国产成人精品视频免费 | 五月天色婷婷在线 | 午夜精品久久久久久99热软件 | 国产精品一区二区三区99 | 超碰激情| 黄色影视大全 | 久久视频在线免费观看 | 日韩精品亚洲人成在线播放 | 欧洲色吧 | 成人免费看黄网站yyy456 | a三级毛片 |