⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 httpuserid.java

📁 esri的ArcGIS Server超级学习模板程序(for java)
💻 JAVA
字号:
package com.esri.solutions.jitk.common.personalization;

import java.security.Principal;

import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;

import org.apache.log4j.Logger;

import com.esri.solutions.jitk.personalization.data.IUser;
import com.esri.solutions.jitk.personalization.data.IUserId;

/**
 * Implementation of {@link IUser} to represent a User from an
 * HTTP request.  The user's name is retrieved from the <code>UserPrincipal</code>
 * property of the Http Request.
 * 
 * <p>
 * This implementation retrieves the User Principal from the {@link ExternalContext}
 * object, so all of its restrictions apply.
 * </p>
 */
public class HttpUserId implements IUserId  {
	private static final Logger _logger = Logger.getLogger(HttpUserId.class);
	/**
	 * 
	 */
	private static final long serialVersionUID = -4127340782137753788L;
	
	/**
	 * Reference to User Principal
	 */
	private Principal m_principal;
	
	/**
	 * Constructs a new <code>HttpUserId</code> object.  The User Principal
	 * is retrieved from the {@link ExternalContext}.
	 */
	public HttpUserId () {
		FacesContext fc = null;
		fc = FacesContext.getCurrentInstance();
		m_principal = fc.getExternalContext().getUserPrincipal();
	}
	
	/*
	 * (non-Javadoc)
	 * @see com.esri.solutions.jitk.personalization.data.IUser#getUsername()
	 */
	public String getUsername() {
		return m_principal.getName();
	}
	
	
	public void setUsername (String username) {
		_logger.warn("Username being set to " + username + " via configuration, ignoring");
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -