水水水水水水水水水水水水

By 生活丶伱卟懂 at 2014-04-25 18:56:48 • 565次点击

package com.wondersgroup.wssip.application.login;

import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.wondersgroup.framework.core.web.struts2.action.BaseAjaxAction;
import com.wondersgroup.framework.core.web.struts2.interceptor.LoginInterceptor;
import com.wondersgroup.wssip.application.SessionConstants;
import com.wondersgroup.wssuap.client.dc.ZoneResource;
import com.wondersgroup.wssuap.client.dc.ZoneResourceService;
import com.wondersgroup.wssuap.client.domain.DomainService;
import com.wondersgroup.wssuap.client.organ.OrganService;
import com.wondersgroup.wssuap.client.user.UserService;
import com.wondersgroup.wssuap.core.authentic.connector.AuthenticationUser;
import com.wondersgroup.wssuap.core.base.model.BaseUapOrganNode;
import com.wondersgroup.wssuap.core.base.model.bo.UapDomain;
import com.wondersgroup.wssuap.core.base.model.bo.UapUser;

import edu.yale.its.tp.cas.client.filter.CASFilter;

public class SSORedirectAction extends BaseAjaxAction {

	private UserService userService;
	private String redirectUrl;


		String loginName = (String) getServletRequest().getSession().getAttribute(CASFilter.CAS_FILTER_USER);
		if(loginName ==null){
				loginName =this.getServletRequest().getParameter(\\\"loginName\\\");
		}
		log.info(String.format(\\\"SSORedirectAction,loginName:%s\\\", loginName));
		UapUser uapUser =null;
		if (loginName != null) {
			AuthenticationUser user = userService.getUserByLoginname(loginName);
			if (user instanceof UapUser) {
				uapUser = (UapUser) user;
				createBusinessContext(uapUser);
				return SUCCESS;
			}else{
				return ERROR;
			}
		}else{
			return ERROR;
		}
		
		
	}

	/**
	 * @param securityUser
	 */
	@SuppressWarnings(\\\"unchecked\\\")
	protected void createBusinessContext(UapUser uapUser) {
		String macAddress = getServletRequest().getParameter(\\\"macAddress\\\");

		// 设置Session
		getSession().put(LoginInterceptor.SECURITY_LOGIN_NAME,
				uapUser.getLoginName());
		getSession().put(SessionConstants.WSSIP_OPERATOR, uapUser);
		getSession().put(SessionConstants.WSSIP_OPERATOR_ID,
				String.valueOf(uapUser.getUserid()));
		getSession().put(SessionConstants.WSSIP_OPERATOR_NAME,
				uapUser.getName());
		if (StringUtils.isNotEmpty(macAddress)) {
			getSession().put(SessionConstants.WSSIP_CLIENT_MACADDRESS,
					macAddress);
		}
		
		String ipAddress = getServletRequest().getParameter(\\\"ip\\\");
		if (StringUtils.isNotEmpty(ipAddress)) {
			getSession().put(SessionConstants.WSSIP_CLIENT_IPADDRESS,ipAddress);
		}

		/**
		 * 缓存 domainCode和applicationCode
		 */
		getSession().put(SessionConstants.WSSUAP_DOMAIN_CODE, domainCode);
		getSession().put(SessionConstants.WSSUAP_APPLICATION_CODE,
				applicationCode);

		/**
		 * 缓存组织信息
		 */
		BaseUapOrganNode[] organNodes = organService.getUserOrgans(uapUser

		getSession().put(SessionConstants.WSSUAP_ZONE_RESOURCE, zoneResources);
	}

	public void setUserService(UserService userService) {
		this.userService = userService;
);
		    if(pos!=-1){
		    	SSOUrl=SSOUrl.substring(0, pos);
		    }
		    System.out.println(SSOUrl);
	}

}


登录 后发表评论