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

📄 serviceproxy.java

📁 移动Agent编程工具Naplet
💻 JAVA
字号:
/** @<#>ServiceProxy.java version 0.0.1, 1/1/2003
 *
 * THIS PROGRAM IS FREE SOFTWARE; YOU CAN DISTRIBUTE IT AND/OR
 * MODIFY IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE
 * AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION.
 *
 * 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.
 *
 * Copyright (c) 2000-2003 Wayne State University. All Rights Reserved.
 */
package naplet.resource;

import naplet.*;
import naplet.serviceChannel.*;

import java.util.*;
import javax.security.auth.Subject;

/**
 * The <code>ServiceProxy</code> class provides a collection of
 * service channels to privileged services and handlers
 * to non-privileged services.
 *
 * @version 0.16, 1/1/2003
 * @author C.Xu
 */

public class ServiceProxy
{
	private ServiceChannelList pvgServiceChannelList;
	private ServiceHandlerList appServiceHandlerList;

	public ServiceProxy( Map pvgChannelList, Map appHandlerList )
	{
		pvgServiceChannelList = new ServiceChannelList( pvgChannelList );
		appServiceHandlerList = new ServiceHandlerList( appHandlerList );
	}

	public ServiceChannel getServiceChannel( String name )
			throws ServiceAccessException 
	{

		return getServiceChannel( null, name );
	}

	public ServiceChannel getServiceChannel( Subject s, String name )
			throws ServiceAccessException 
	{

		ServiceChannel ch = null;
		// Check permission
		if ( true )
		{
			ch = pvgServiceChannelList.get( name );
			if ( ch == null )
			{
				throw new ServiceAccessException ( "Service " + name +
												  " does not exist" );
			}
		}
		else
		{
			throw new ServiceAccessException ( "Access to service " + name +
											  " is denied" );
		}
		return ch;
	}

	public AppService getServiceHandler( String name )
			throws ServiceAccessException 
	{
		return getServiceHandler( null, name );
	}

	public AppService getServiceHandler( Subject s, String name )
			throws ServiceAccessException 
	{

		AppService handler = null;
		// Check permission
		if ( true )
		{
			handler = appServiceHandlerList.get( name );
			if ( handler == null )
			{
				throw new ServiceAccessException ( "Service " + name +
												  " doesn't exist" );
			}
		}
		else
		{
			throw new ServiceAccessException ( "Access to service " + name +
											  " is denied" );
		}
		return handler;
	}
}

⌨️ 快捷键说明

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