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

📄 logonsoapbindingimpl.java

📁 一个数据挖掘软件ALPHAMINERR的整个过程的JAVA版源代码
💻 JAVA
字号:
/*
 *    This program is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation; either version 2 of the License, or
 *    (at your option) any later version.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with this program; if not, write to the Free Software
 *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

/**
 * LogonSoapBindingImpl.java
 *
 * This file was auto-generated from WSDL
 * by the Apache Axis WSDL2Java emitter.
 */

package eti.bi.alphaminer.core.storage;
 

import javax.security.auth.Subject;
import javax.security.auth.login.LoginContext;
import javax.security.auth.login.LoginException;

import org.apache.axis.MessageContext;
import org.apache.axis.session.Session;
import eti.bi.common.Constants;
import eti.bi.common.System.SysConfig;
import eti.bi.common.System.SysLog;

public class LogonSoapBindingImpl implements Logon{

	private LoginContext m_LoginContext = null;
		
	String m_ConfigName = SysConfig.getProperty("loginconfig");


    public void logon(String aUsername, String aPassword) throws java.rmi.RemoteException 
    {
    	SysLog.debug("java.security.auth.login.config="+System.getProperty("java.security.auth.login.config"));
    	SysLog.debug("m_ConfigName="+m_ConfigName);

    	MessageContext aMessageContext = MessageContext.getCurrentContext();
    	Session session = null;
    	if (aMessageContext != null)		//the client is a web service client
    	{
	    	session = aMessageContext.getSession();
	    	SysLog.debug("session="+session);
	    	if (session!=null && session.get(Constants.AUTH_SUBJECT_KEY)!=null)
	    	{
	    		// already authenticated
	    		SysLog.debug("Already authenticated.");
	    		return;
	    	}
    	}
    	    	
 //   	PresetCallbackHandler aCallbackHandler = new PresetCallbackHandler(aUsername, aPassword);
    	try
		{
			if (m_LoginContext == null)
			{
//				m_LoginContext = new LoginContext(m_ConfigName, aCallbackHandler);
			}

			m_LoginContext.login();
			/*
			if (aLoginContext.getSubject()!=null && aLoginContext.getSubject().getPrincipals()!=null)
			{
				for (Iterator i = aLoginContext.getSubject().getPrincipals().iterator(); i.hasNext();)
				{
					log.debug("Principal="+i.next());
				}
			}
			*/
			
			Subject aSubject = m_LoginContext.getSubject();
			if (session != null)
			{
				session.set(Constants.AUTH_SUBJECT_KEY, aSubject);
			}
			SysLog.debug("Successfully authenticated. Subject="+aSubject);
		} 
		catch (LoginException e)
		{
			SysLog.error(e);			
			//throw new AppException(e);
		}
		catch (Exception e)
		{
			SysLog.error(e);
			//throw new SysException(e);
		}
		
    }

    public void logoff() throws java.rmi.RemoteException 
    {
    	if (m_LoginContext == null)
    		return;
    		
		try
		{
			m_LoginContext.logout();

	    	MessageContext aMessageContext = MessageContext.getCurrentContext();
	    	Session session = null;
			
	    	if (aMessageContext != null)		//the client is a web service client
	    	{
		    	session = aMessageContext.getSession();
		    	SysLog.debug("session="+session);
		    	if (session!=null)
		    	{
		    		session.remove(Constants.AUTH_SUBJECT_KEY);
		    	}
	    	}
			
		} catch (LoginException e)
		{
		}
    }
    
    public Object getSubject() throws java.rmi.RemoteException
    {
    	if (m_LoginContext != null)
    	{
    		return m_LoginContext.getSubject();
    	}
    	else
    	{
    		return null;
    	}
    }

}

⌨️ 快捷键说明

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