1 16 package org.apache.cocoon.webapps.authentication.acting; 17 18 import java.util.Map ; 19 20 import org.apache.avalon.framework.parameters.Parameters; 21 import org.apache.avalon.framework.thread.ThreadSafe; 22 import org.apache.cocoon.acting.ServiceableAction; 23 import org.apache.cocoon.environment.Redirector; 24 import org.apache.cocoon.environment.SourceResolver; 25 import org.apache.cocoon.webapps.authentication.AuthenticationManager; 26 import org.apache.cocoon.webapps.authentication.user.UserHandler; 27 28 34 public final class LoggedInAction 35 extends ServiceableAction 36 implements ThreadSafe { 37 38 public Map act(Redirector redirector, 39 SourceResolver resolver, 40 Map objectModel, 41 String source, 42 Parameters par) 43 throws Exception { 44 if (this.getLogger().isDebugEnabled() ) { 45 this.getLogger().debug("BEGIN act resolver="+resolver+ 46 ", objectModel="+objectModel+ 47 ", source="+source+ 48 ", par="+par); 49 } 50 51 Map map = null; 52 String handlerName = par.getParameter("handler", null); 53 AuthenticationManager authManager = null; 54 55 final boolean testNotLoggedIn = par.getParameterAsBoolean("negate-result", false); 56 57 try { 58 authManager = (AuthenticationManager) this.manager.lookup(AuthenticationManager.ROLE); 59 UserHandler handler = authManager.isAuthenticated(handlerName); 60 if ( testNotLoggedIn ) { 61 if ( handler == null ) { 62 map = EMPTY_MAP; 63 } 64 } else { 65 if ( handler != null ) { 66 map = EMPTY_MAP; 67 } 68 } 69 } finally { 70 this.manager.release( authManager); 71 } 72 73 if (this.getLogger().isDebugEnabled() ) { 74 this.getLogger().debug("END act map="+map); 75 } 76 77 return map; 78 } 79 80 } 81 | Popular Tags |