<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6487610366632106849</id><updated>2012-02-16T16:52:18.776+09:00</updated><category term='Acegi Struts2'/><category term='Struts2 TIPS'/><title type='text'>Struts2+Spring2+Acegi+Tiles2+iBatis</title><subtitle type='html'>Struts2 + Spring2 + Acegi + Tiles2 + iBatis の TIPS</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://fullstack-java.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6487610366632106849/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://fullstack-java.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>JaguarXK</name><uri>http://www.blogger.com/profile/08200665885690303909</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>5</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6487610366632106849.post-1326453516744204777</id><published>2007-10-28T10:32:00.001+09:00</published><updated>2007-10-28T10:40:39.147+09:00</updated><title type='text'>Acegiとの連携2</title><content type='html'>こちらのInterceptorの方がシンプルだな&lt;br /&gt;&lt;br /&gt;tutorial/AuthzInterceptor.java&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;package tutorial;&lt;br /&gt;&lt;br /&gt;import org.acegisecurity.AccessDeniedException;&lt;br /&gt;import org.acegisecurity.taglibs.velocity.Authz;&lt;br /&gt;import org.acegisecurity.taglibs.velocity.AuthzImpl;&lt;br /&gt;import tutorial.acegi.AuthzAware;&lt;br /&gt; &lt;br /&gt;import com.opensymphony.xwork2.ActionInvocation;&lt;br /&gt;import com.opensymphony.xwork2.interceptor.Interceptor;&lt;br /&gt; &lt;br /&gt;public class AuthzInterceptor implements Interceptor {&lt;br /&gt;  String allowroles;&lt;br /&gt;  String denyroles;&lt;br /&gt;        public void destroy() {&lt;br /&gt;        }&lt;br /&gt; &lt;br /&gt;        public void init() {&lt;br /&gt;        }&lt;br /&gt;        public void setAllowedRoles(String allowroles) {&lt;br /&gt;            this.allowroles = allowroles;&lt;br /&gt;        }&lt;br /&gt;        public void setDeniedRoles(String denyroles) {&lt;br /&gt;            this.denyroles = denyroles;&lt;br /&gt;        }&lt;br /&gt;        &lt;br /&gt;        public String intercept(ActionInvocation invocation)&lt;br /&gt;                throws Exception {&lt;br /&gt;         &lt;br /&gt;          Object act = invocation.getAction(); &lt;br /&gt;          if (allowroles != null || denyroles != null || act instanceof AuthzAware ) {&lt;br /&gt;            Authz authz = new AuthzImpl();&lt;br /&gt;            if (allowroles != null ) {&lt;br /&gt;           if (!authz.anyGranted(allowroles)) {&lt;br /&gt;            throw new AccessDeniedException("not allow");&lt;br /&gt;           }&lt;br /&gt;            }&lt;br /&gt;            if (denyroles != null ) {&lt;br /&gt;           if (authz.anyGranted(denyroles)) {&lt;br /&gt;            throw new AccessDeniedException("deny");&lt;br /&gt;           }&lt;br /&gt;            }&lt;br /&gt;                  if (act instanceof AuthzAware) {&lt;br /&gt;                        AuthzAware authzAware = (AuthzAware)invocation.getAction();&lt;br /&gt;                        authzAware.setAuthz(authz);&lt;br /&gt;                  }&lt;br /&gt;          }&lt;br /&gt; &lt;br /&gt;                return invocation.invoke();&lt;br /&gt;        }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;これを struts.xml で&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;            &amp;lt;interceptor name="role_admin"&lt;br /&gt;                class="tutorial.AuthzInterceptor"&amp;gt;&lt;br /&gt;             &amp;lt;param name="allowedRoles"&gt;ROLE_ADMIN&amp;lt;/param&amp;gt;&lt;br /&gt;            &amp;lt;/interceptor&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;として action で interceptor-ref すればいい&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6487610366632106849-1326453516744204777?l=fullstack-java.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fullstack-java.blogspot.com/feeds/1326453516744204777/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6487610366632106849&amp;postID=1326453516744204777' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6487610366632106849/posts/default/1326453516744204777'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6487610366632106849/posts/default/1326453516744204777'/><link rel='alternate' type='text/html' href='http://fullstack-java.blogspot.com/2007/10/acegi_28.html' title='Acegiとの連携2'/><author><name>JaguarXK</name><uri>http://www.blogger.com/profile/08200665885690303909</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6487610366632106849.post-3821759303540424436</id><published>2007-10-28T06:14:00.000+09:00</published><updated>2007-10-28T06:31:44.033+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Acegi Struts2'/><title type='text'>Acegiとの連携</title><content type='html'>filterは Acegi、 Struts2の順に適用する必要があるが、これだとAcegiのAccessDeniedExceptionがStrutsで処理できない&lt;br /&gt;&lt;br /&gt;なので、Struts2の Interceptor として実装した&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;package tutorial;&lt;br /&gt;&lt;br /&gt;import javax.servlet.FilterChain;&lt;br /&gt;import javax.servlet.ServletException;&lt;br /&gt;import javax.servlet.ServletRequest;&lt;br /&gt;import javax.servlet.ServletResponse;&lt;br /&gt;import javax.servlet.http.HttpServletRequest;&lt;br /&gt;import javax.servlet.http.HttpServletResponse;&lt;br /&gt;&lt;br /&gt;import org.acegisecurity.intercept.AbstractSecurityInterceptor;&lt;br /&gt;import org.acegisecurity.intercept.InterceptorStatusToken;&lt;br /&gt;import org.acegisecurity.intercept.ObjectDefinitionSource;&lt;br /&gt;import org.acegisecurity.intercept.web.FilterInvocation;&lt;br /&gt;import org.acegisecurity.intercept.web.FilterInvocationDefinitionSource;&lt;br /&gt;import org.apache.struts2.ServletActionContext;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;import com.opensymphony.xwork2.ActionInvocation;&lt;br /&gt;import com.opensymphony.xwork2.interceptor.Interceptor;&lt;br /&gt;&lt;br /&gt;public class AcegiFilterSecurityInterceptor  extends AbstractSecurityInterceptor implements Interceptor, FilterChain {&lt;br /&gt;    private FilterInvocationDefinitionSource objectDefinitionSource;&lt;br /&gt;    private boolean observeOncePerRequest = true;&lt;br /&gt;    &lt;br /&gt;    public void destroy() {&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public void init() {&lt;br /&gt;    }&lt;br /&gt;    public Class getSecureObjectClass() {&lt;br /&gt;        return FilterInvocation.class;&lt;br /&gt;    }&lt;br /&gt;    public void doFilter(ServletRequest request, ServletResponse response) throws java.io.IOException,ServletException {&lt;br /&gt;    }&lt;br /&gt;    public String intercept(ActionInvocation actionInvocation) throws Exception {&lt;br /&gt;        HttpServletRequest req = ServletActionContext.getRequest();&lt;br /&gt;        HttpServletResponse res = ServletActionContext.getResponse();&lt;br /&gt;        FilterInvocation fi = new FilterInvocation(req, res, this );&lt;br /&gt;&lt;br /&gt;        InterceptorStatusToken token = super.beforeInvocation(fi);&lt;br /&gt;&lt;br /&gt;        String ans;&lt;br /&gt;        try {&lt;br /&gt;            ans = actionInvocation.invoke();&lt;br /&gt;        } finally {&lt;br /&gt;            super.afterInvocation(token, null);&lt;br /&gt;        }&lt;br /&gt;        return ans;&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    public boolean isObserveOncePerRequest() {&lt;br /&gt;        return observeOncePerRequest;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public ObjectDefinitionSource obtainObjectDefinitionSource() {&lt;br /&gt;        return this.objectDefinitionSource;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public void setObjectDefinitionSource(FilterInvocationDefinitionSource newSource) {&lt;br /&gt;        this.objectDefinitionSource = newSource;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public void setObserveOncePerRequest(boolean observeOncePerRequest) {&lt;br /&gt;        this.observeOncePerRequest = observeOncePerRequest;&lt;br /&gt;    }   &lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;として exception の interceptor の後に呼び出す。&lt;br /&gt;すると AccessDeneid exception を struts2 で補足できる。&lt;br /&gt;※Acegiのフィルタチェインには  filterSecurityInterceptor を書かない&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6487610366632106849-3821759303540424436?l=fullstack-java.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fullstack-java.blogspot.com/feeds/3821759303540424436/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6487610366632106849&amp;postID=3821759303540424436' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6487610366632106849/posts/default/3821759303540424436'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6487610366632106849/posts/default/3821759303540424436'/><link rel='alternate' type='text/html' href='http://fullstack-java.blogspot.com/2007/10/acegi.html' title='Acegiとの連携'/><author><name>JaguarXK</name><uri>http://www.blogger.com/profile/08200665885690303909</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6487610366632106849.post-7310242601734850401</id><published>2007-10-23T02:36:00.000+09:00</published><updated>2007-10-23T02:38:43.840+09:00</updated><title type='text'>propertiesファイル</title><content type='html'>Action に class を記述していないと、アクションクラスやパッケージに関連した properties ファイは読んでくれない。当たり前だけどはまりました。&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6487610366632106849-7310242601734850401?l=fullstack-java.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fullstack-java.blogspot.com/feeds/7310242601734850401/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6487610366632106849&amp;postID=7310242601734850401' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6487610366632106849/posts/default/7310242601734850401'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6487610366632106849/posts/default/7310242601734850401'/><link rel='alternate' type='text/html' href='http://fullstack-java.blogspot.com/2007/10/properties.html' title='propertiesファイル'/><author><name>JaguarXK</name><uri>http://www.blogger.com/profile/08200665885690303909</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6487610366632106849.post-8746068690570836470</id><published>2007-10-22T01:08:00.000+09:00</published><updated>2007-10-22T01:11:24.022+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Struts2 TIPS'/><title type='text'>setXXXX されたくないパラメータ</title><content type='html'>":" + 名前 とかにすると setXXXX が呼ばれなくなる&lt;br /&gt; 例） :del とかの名前をつけるとそれらのパラメータは setが呼ばれなくなるので&lt;br /&gt;　セッターが無いとかのエラーがいちいち出なくていい&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6487610366632106849-8746068690570836470?l=fullstack-java.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fullstack-java.blogspot.com/feeds/8746068690570836470/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6487610366632106849&amp;postID=8746068690570836470' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6487610366632106849/posts/default/8746068690570836470'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6487610366632106849/posts/default/8746068690570836470'/><link rel='alternate' type='text/html' href='http://fullstack-java.blogspot.com/2007/10/setxxxx.html' title='setXXXX されたくないパラメータ'/><author><name>JaguarXK</name><uri>http://www.blogger.com/profile/08200665885690303909</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6487610366632106849.post-1733718445584518139</id><published>2007-10-21T02:34:00.000+09:00</published><updated>2007-10-21T02:38:16.100+09:00</updated><title type='text'>s:paramのvalue</title><content type='html'>&lt;span style="font-family:courier new;"&gt;&amp;lt;s:param name="id" value="xxx"&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;xxxは expressionなので普通の文字列を設定したい場合は&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;s:param name="id"&amp;gt;xxx&amp;lt;/s:param&amp;gt;&lt;/span&gt;&lt;br /&gt;とする。&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6487610366632106849-1733718445584518139?l=fullstack-java.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fullstack-java.blogspot.com/feeds/1733718445584518139/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6487610366632106849&amp;postID=1733718445584518139' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6487610366632106849/posts/default/1733718445584518139'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6487610366632106849/posts/default/1733718445584518139'/><link rel='alternate' type='text/html' href='http://fullstack-java.blogspot.com/2007/10/sparamvalue.html' title='s:paramのvalue'/><author><name>JaguarXK</name><uri>http://www.blogger.com/profile/08200665885690303909</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
