その後,妙に肥大化して次のようになりました.
public static final String PACKAGE = "com.semcode.stuvie.web."; public static final String COMMON_PACKAGE = PACKAGE + "common"; public static final String ADMIN_PACKAGE = PACKAGE + "admin"; public static final String STUDENT_PACKAGE = PACKAGE + "student"; public static final String TEACHER_PACKAGE = PACKAGE + "teacher"; private S2Container container; private AuthenticationDto authenticationDto; public Class invoke(MethodInvocation invocation) throws Throwable { this.setAuthenticationDto(); String referer = invocation.getClass().getName(); AuthenticationDto auth = this.getAuthenticationDto(); if (auth == null || auth.isAuthenticated() == false) { if(referer.startsWith(ADMIN_PACKAGE)){ return com.semcode.stuvie.web.admin.LoginPage.class; }else{ return com.semcode.stuvie.web.LoginPage.class; } } if(referer.startsWith(COMMON_PACKAGE) == false){ if(auth.isAdministrator() && referer.startsWith(ADMIN_PACKAGE) == false){ return com.semcode.stuvie.web.admin.LoginPage.class; }else if((auth.isStudent() && referer.startsWith(STUDENT_PACKAGE) == false) || (auth.isTeacher() && referer.startsWith(TEACHER_PACKAGE) == false)){ return com.semcode.stuvie.web.LoginPage.class; } } return (Class)invocation.proceed(); }
・・・もっとスマートな方法があるような気がするけど・・・!
それから,懸案だった,/student/index.htmlにアクセスして権限がないとき,/login.htmlではなく/student/login.htmlにリダイレクトされる問題は・・・解決せずに!
RewriteEngine on RewriteRule ^(.*)/$ $1/index.html RewriteRule ^/stuvie/(.+) /$1 RewriteRule ^/student/.*?login.html /login.html [R] RewriteRule ^/teacher/.*?login.html /login.html [R] RewriteRule ^/admin/.+?/login.html /admin/login.html [R] RewriteRule ^/(.+)\.(.+) balancer://ajp-balancer/$1.$2 [P,L]
とかしてごまかしました.うーん・・・
そういえば,教授に「Teedaはどれくらい持つの」ときかれたので,「気合次第です*grin*」って言っておいた.フレームワークをまったく使わずにきたってのもすごいなぁとおもう.そんなもんなのかなぁ.