欧美三区_成人在线免费观看视频_欧美极品少妇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| 精品国产欧美一区二区 | 久久久国产视频 | 国产中文一区 | 国产日韩欧美在线观看不卡 | 亚洲精品一区二区三区精华液 | 欧美黄色xxx | 九九久久精品视频 | 国产精品v欧美精品v日韩精品 | 日韩在线视频免费观看 | 亚洲一区二区三区欧美 | 欧美精品www| 免费午夜不卡毛片 | 九九精品视频在线播放 | 九九av| 欧美黑人狂野猛交老妇 | 国产亚洲一区在线 |