FileDocCategorySizeDatePackage
RPIPFilter.javaAPI DocAzureus 3.0.3.47097Mon Jan 08 08:28:48 GMT 2007org.gudy.azureus2.pluginsimpl.remote.ipfilter

RPIPFilter

public class RPIPFilter extends RPObject implements IPFilter
author
parg

Fields Summary
protected transient IPFilter
delegate
public long
last_update_time
public int
number_of_ranges
public int
number_of_blocked_ips
Constructors Summary
protected RPIPFilter(IPFilter _delegate)

		super( _delegate );
	
Methods Summary
public RPReply_process(RPRequest request)

		String	method = request.getMethod();	
	
		Object[]	params = request.getParams();
		
		if ( method.equals( "createAndAddRange[String,String,String,boolean]")){
		
			IPRange range = delegate.createAndAddRange(
								(String)params[0],
								(String)params[1],
								(String)params[2],
								((Boolean)params[3]).booleanValue());
	
			if ( range == null ){
				
				return( new RPReply(null));
				
			}else{
				
				RPIPRange rp_range = RPIPRange.create( range );
			
				return( new RPReply( rp_range ));
			}
		}else if ( method.equals( "getRanges")){
				
				IPRange[] ranges = delegate.getRanges();
						
				RPIPRange[] rp_ranges = new RPIPRange[ranges.length];
				
				for (int i=0;i<ranges.length;i++){
					
					rp_ranges[i] = RPIPRange.create( ranges[i] );
				}
				
				return( new RPReply( rp_ranges ));
				
		}else if ( method.equals( "save" )){
		
			try{
				delegate.save();
					
				return(null );
				
			}catch( IPFilterException e ){
				
				return( new RPReply( e ));
			}
		}else if ( method.equals( "getInRangeAddressesAreAllowed")){
			
			return( new RPReply( new Boolean( delegate.getInRangeAddressesAreAllowed())));
			
		}else if ( method.equals( "setInRangeAddressesAreAllowed[boolean]")){
			
			delegate.setInRangeAddressesAreAllowed(((Boolean)params[0]).booleanValue());
			
			return( null );
			
		}else if ( method.equals( "isEnabled")){
			
			return( new RPReply( new Boolean( delegate.isEnabled())));
			
		}else if ( method.equals( "setEnabled[boolean]")){
			
			delegate.setEnabled(((Boolean)params[0]).booleanValue());
			
			return( null );
			
		}else if ( method.equals( "isInRange[String]")){
			
			return( new RPReply( new Boolean( delegate.isInRange((String)params[0]))));
		}
				
		throw( new RPException( "Unknown method: " + method ));
	
protected void_setDelegate(java.lang.Object _delegate)

		delegate = (IPFilter)_delegate;
		
		last_update_time				= delegate.getLastUpdateTime();
		number_of_ranges				= delegate.getNumberOfRanges();
		number_of_blocked_ips			= delegate.getNumberOfBlockedIPs();
	
public java.lang.Object_setLocal()

		return( _fixupLocal());
	
public voidaddRange(IPRange range)

		notSupported();
	
public voidban(java.lang.String IPAddress, java.lang.String text)

 		notSupported();
 	
public voidblock(java.lang.String IPAddress)

		notSupported();

	
public static IPFiltercreate(IPFilter _delegate)

		RPIPFilter	res =(RPIPFilter)_lookupLocal( _delegate );
		
		if ( res == null ){
			
			res = new RPIPFilter( _delegate );
		}
		
		return( res );
	
public IPRangecreateAndAddRange(java.lang.String description, java.lang.String start_ip, java.lang.String end_ip, boolean this_session_only)

		RPIPRange resp = (RPIPRange)_dispatcher.dispatch( 
							new RPRequest( 
									this, 
									"createAndAddRange[String,String,String,boolean]", 
									new Object[]{description,start_ip,end_ip,new Boolean(this_session_only)})).getResponse();
		
		resp._setRemote( _dispatcher );
		
		return( resp );

	
public IPRangecreateRange(boolean this_session_only)

		notSupported();
		
		return( null );
	
public IPBanned[]getBannedIPs()

 		notSupported();
 		
 		return( null );
 	
public IPBlocked[]getBlockedIPs()

		notSupported();
		
		return( null );
	
public java.io.FilegetFile()

		notSupported();
		
		return( null );
	
public booleangetInRangeAddressesAreAllowed()

		Boolean res = (Boolean)_dispatcher.dispatch( new RPRequest( this, "getInRangeAddressesAreAllowed", null )).getResponse();
				
		return( res.booleanValue());		
	
public longgetLastUpdateTime()

		
		return( last_update_time );
	
public intgetNumberOfBannedIPs()

		notSupported();
		
		return -1;
	
public intgetNumberOfBlockedIPs()

		return( number_of_blocked_ips );
	
public intgetNumberOfRanges()

		return( number_of_ranges );
	
public IPRange[]getRanges()

		RPIPRange[] resp = (RPIPRange[])_dispatcher.dispatch( 
				new RPRequest( 
						this, 
						"getRanges", 
						null)).getResponse();

		for (int i=0;i<resp.length;i++){
			
			resp[i]._setRemote( _dispatcher );
		}
		
		return( resp );
	
public booleanisEnabled()

		Boolean res = (Boolean)_dispatcher.dispatch( new RPRequest( this, "isEnabled", null )).getResponse();
		
		return( res.booleanValue());	
	
public booleanisInRange(java.lang.String IPAddress)

		Boolean res = (Boolean)_dispatcher.dispatch( new RPRequest( this, "isInRange[String]", new Object[]{IPAddress})).getResponse();
		
		return( res.booleanValue());	
	
public voidmarkAsUpToDate()

		notSupported();
	
public voidreload()

		notSupported();

	
public voidremoveRange(IPRange range)

		notSupported();
	
public voidsave()

		try{
			_dispatcher.dispatch( new RPRequest( this, "save", null )).getResponse();
						
		}catch( RPException e ){
			
			if ( e.getCause() instanceof IPFilterException ){
				
				throw((IPFilterException)e.getCause());
			}
			
			throw( e );
		}		
	
public voidsetEnabled(boolean value)

		_dispatcher.dispatch( new RPRequest( this, "setEnabled[boolean]", new Object[]{new Boolean(value)} )).getResponse();		
	
public voidsetInRangeAddressesAreAllowed(boolean value)

		_dispatcher.dispatch( new RPRequest( this, "setInRangeAddressesAreAllowed[boolean]", new Object[]{new Boolean(value)} )).getResponse();		
	
public voidunban(java.lang.String IPAddress)

		notSupported();