`
zybing
  • 浏览: 447772 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Roller:访问用户的博客 --RequestMappingFilter 负责转向

阅读更多

在Roller中,访问博客,通过  http://roller/blogname 来进行访问的

 

roller是工程的名字,blogname是所需要访问的网志。

 

在roller中,通过filer进行URL转向:

在web.xml中有这么一段配置:

     <!-- 请求的Request可能会被一系列的RequestMapper进行检查,可能会隐含的被转到不同的处理地点   ?  -->    
    <filter>    
        <filter-name>RequestMappingFilter</filter-name>    
        <filter-class>org.apache.roller.weblogger.ui.rendering.filters.RequestMappingFilter</filter-class>    
    </filter>    

 配置了RequestMappingFilter,这个filter就是管理转向的。

 

这个filter在init中,读取“rendering.rollerRequestMappers”,"rendering.userRequestMappers",这是负责转向的处理类。

 

缺省的: rendering.rollerRequestMappers配置为:org.apache.roller.weblogger.ui.rendering.WeblogRequestMapper,

在 方法:handleRequest 中对url进行处理:

 

通过:calculateForwardUrl 进行处理

 

根据不同的处理要求,跳转到不同的servlet:

 

如果是看某人的blog: 到: /roller-ui/rendering/page(/blogname)

 

 

 

 

------------

在WeblogRequestMapper,首先定义一些roller自己使用的目录名称(用户还可以定义自己的):

如: roller-ui,images,theme,themes等等,这些都不做特别的转向

 

 

 

 

 

 

 

 

 

 

 

 

分享到:
评论
8 楼 zybing 2010-09-03  
cxwujian 写道
非常感谢你的解答。

好吧,我把问题简化:
如何控制访问权,设置某个博客只对登录用户可读
例如:http://localhost:8080/Roller/wujian是访问的wujian的博客,我如何设置wujian的博客只对登录用户可读。




这个就用acegi就可以了。
在acegi中,判断访问的博客,是否你需要限制的博客,如果需要,执行登陆,
如果不需要登陆的博客,就直接放行。

这个需要自己编程。

----------------------
如果需要限制的博客不多的话,可以直接写在acegi的权限控制的设置中,把需要限制的URL全部列出来就可以了。
这样只要访问这些URL,就会判断session是否登陆过
7 楼 cxwujian 2010-09-02  
非常感谢你的解答。

好吧,我把问题简化:
如何控制访问权,设置某个博客只对登录用户可读
例如:http://localhost:8080/Roller/wujian是访问的wujian的博客,我如何设置wujian的博客只对登录用户可读。


6 楼 zybing 2010-09-02  
cxwujian 写道
       <value>  
            PATTERN_TYPE_APACHE_ANT   
            /roller-ui/login-redirect**=admin,editor   
            /roller-ui/profile**=admin,editor   
            /roller-ui/createWeblog**=admin,editor   
            /roller-ui/menu**=admin,editor   
            /roller-ui/authoring/**=admin,editor   
            /roller-ui/admin/**=admin   
            /rewrite-status*=admin   
        </value>  


例如第一个 /roller-ui/login-redirect**=admin,editor 
/roller-ui/login-redirect应该是在struts.xml里面配置的吧。
roller-ui是namespace,而login-redirect是action

如果是访问别人的博客例如http://localhost:8080/Roller/wujian
这个我怎么配置?是不是也需要写个action ?我就是不知道访问别人的博客是访问的哪个jsp页面。也不知道是用到的哪个方法。麻烦指点一下,谢谢!


------------------------------
第一个问题:
   这个URL和struts无关,就是访问的Http URL路径。
   只有先通过acegi的权限验证后,才会有struts进行具体的处理。

------------------------------
第二个问题:
   第二个问题没有看懂什么意思。
   访问不同的用户的博客页面,在传入的URL中指定了访问的是谁的博客页面
   如果是自己的页面,则有编辑功能,如果没有则只有浏览的功能






5 楼 cxwujian 2010-09-02  
       <value>  
            PATTERN_TYPE_APACHE_ANT   
            /roller-ui/login-redirect**=admin,editor   
            /roller-ui/profile**=admin,editor   
            /roller-ui/createWeblog**=admin,editor   
            /roller-ui/menu**=admin,editor   
            /roller-ui/authoring/**=admin,editor   
            /roller-ui/admin/**=admin   
            /rewrite-status*=admin   
        </value>  


例如第一个 /roller-ui/login-redirect**=admin,editor 
/roller-ui/login-redirect应该是在struts.xml里面配置的吧。
roller-ui是namespace,而login-redirect是action

如果是访问别人的博客例如http://localhost:8080/Roller/wujian
这个我怎么配置?是不是也需要写个action ?我就是不知道访问别人的博客是访问的哪个jsp页面。也不知道是用到的哪个方法。麻烦指点一下,谢谢!
4 楼 zybing 2010-09-02  
cxwujian 写道
1、如何控制访问权,设置某个博客只对某些登录用户可读
    我觉得是在acegi里面配置类似“/roller-ui/login-redirect**=admin,editor”的一个东西,但是前面这个路径我该去哪里配置呢?
我看了你的帖子,我是这样写的:/roller-ui/rendering/page/**=admin,editor,
但是我访问http://localhost:8080/Roller/wujian/照样可以不登陆就可访问。
请教!
2、如何把用户、博客内容通过web service传给别的系统
    这个我就更摸不着头脑了。

希望你能帮我解答一下,感激不尽!
顺便介绍下我自己:
09年做过半年SSH软件开发
2010年初到现在用的是Tapestry+hibernate+Spring

也就是大半年不接触struts2了,而且对acegi不了解。



在acegi的配置文件: security.xml中,有一段对认证的配置,
通过这些URL进来的,都需要通过验证
    <!-- ======================== AUTHENTICATION ======================= -->
    
    <!-- Note the order that entries are placed against the objectDefinitionSource is critical.
         The FilterSecurityInterceptor will work from the top of the list down to the FIRST pattern that matches the request URL.
         Accordingly, you should place MOST SPECIFIC (ie a/b/c/d.*) expressions first, with LEAST SPECIFIC (ie a/.*) expressions last -->
    <bean id="filterInvocationInterceptor" class="org.acegisecurity.intercept.web.FilterSecurityInterceptor">
        <property name="authenticationManager" ref="authenticationManager"/>
        <property name="accessDecisionManager" ref="accessDecisionManager"/>
         <property name="objectDefinitionSource">
            <value>
                PATTERN_TYPE_APACHE_ANT
                /roller-ui/login-redirect**=admin,editor
                /roller-ui/profile**=admin,editor
                /roller-ui/createWeblog**=admin,editor
                /roller-ui/menu**=admin,editor
                /roller-ui/authoring/**=admin,editor
                /roller-ui/admin/**=admin
                /rewrite-status*=admin
            </value>
                <!-- Add this to above list for LDAP/SSO configuration -->
                <!-- /roller-ui/user.do*=register -->
        </property>
    </bean>



在这里配置的URL,都会通过acegi的验证,如果没有通过验证,会跳到定义的登陆页面上

你说的前面的路径指的是什么?这里只需要配置从对应的应用根目录中配置即可。


3 楼 cxwujian 2010-08-31  
1、如何控制访问权,设置某个博客只对某些登录用户可读
    我觉得是在acegi里面配置类似“/roller-ui/login-redirect**=admin,editor”的一个东西,但是前面这个路径我该去哪里配置呢?
我看了你的帖子,我是这样写的:/roller-ui/rendering/page/**=admin,editor,
但是我访问http://localhost:8080/Roller/wujian/照样可以不登陆就可访问。
请教!
2、如何把用户、博客内容通过web service传给别的系统
    这个我就更摸不着头脑了。

希望你能帮我解答一下,感激不尽!
顺便介绍下我自己:
09年做过半年SSH软件开发
2010年初到现在用的是Tapestry+hibernate+Spring

也就是大半年不接触struts2了,而且对acegi不了解。
2 楼 zybing 2010-08-31  
cxwujian 写道
你好,可以加QQ好友向你请教一下Roller的问题么?看了你的帖子学习到很多。


直接留言吧,上班时候公司不允许开QQ
1 楼 cxwujian 2010-08-30  
你好,可以加QQ好友向你请教一下Roller的问题么?看了你的帖子学习到很多。

相关推荐

Global site tag (gtag.js) - Google Analytics