| 1 20 21 package com.methodhead.shim; 22 23 import org.apache.struts.action.Action; 24 import org.apache.struts.action.ActionMapping; 25 import org.apache.struts.action.ActionForm; 26 import org.apache.struts.action.ActionForward; 27 import org.apache.log4j.Logger; 28 29 import javax.servlet.http.HttpServletRequest ; 30 import javax.servlet.http.HttpServletResponse ; 31 32 import com.methodhead.aikp.IntKey; 33 import com.methodhead.auth.AuthPolicy; 34 import com.methodhead.util.OperationContext; 35 import com.methodhead.sitecontext.SiteContext; 36 import com.methodhead.auth.AuthUtil; 37 import org.apache.commons.lang.StringUtils; 38 39 public class LoginAction 40 extends 41 com.methodhead.auth.LoginAction { 42 43 45 47 49 51 protected ActionForward doLogin( 52 OperationContext op, 53 AuthPolicy policy ) 54 throws 55 Exception { 56 57 ActionForward forward = super.doLogin( op, policy ); 61 62 if ( AuthUtil.getUser( op.request ) != null ) { 66 67 String site = ( String )op.form.get( "site" ); 71 72 if ( !StringUtils.isBlank( site ) ) { 73 74 if ( logger_.isDebugEnabled() ) { 75 logger_.debug( "Setting up shim session for site \"" + site + "\"" ); 76 } 77 78 SiteContext context = new SiteContext(); 82 83 String path = ""; 84 if ( site.indexOf( "/" ) != -1 ) { 85 String [] strings = site.split( "/" ); 86 if ( strings.length == 2 ) { 87 site = strings[ 0 ]; 88 path = strings[ 1 ]; 89 } 90 } 91 92 if ( context.loadForDomainAndPath( site, path ) ) 93 ShimUtils.setUpShimSession( op.request, context ); 94 } 95 } 96 97 return forward; 98 } 99 100 protected ActionForward doLogout( 101 OperationContext op, 102 AuthPolicy policy ) 103 throws 104 Exception { 105 106 ActionForward forward = super.doLogout( op, policy ); 107 108 if ( logger_.isDebugEnabled() ) { 109 logger_.debug( "Tearing down shim session" ); 110 } 111 112 ShimUtils.tearDownShimSession( op.request ); 113 114 return forward; 115 } 116 117 119 121 private static Logger logger_ = Logger.getLogger( LoginAction.class ); 122 } 123 | Popular Tags |