FileDocCategorySizeDatePackage
WebPluginAccessController.javaAPI DocAzureus 3.0.3.43437Thu Feb 09 19:43:24 GMT 2006org.gudy.azureus2.ui.webplugin

WebPluginAccessController

public class WebPluginAccessController extends Object implements RPRequestAccessController
author
parg

Fields Summary
protected boolean
view_mode
Constructors Summary
public WebPluginAccessController(PluginInterface pi)

        String mode_str = pi.getPluginconfig().getPluginStringParameter( WebPlugin.CONFIG_MODE, ((WebPlugin)pi.getPlugin()).CONFIG_MODE_DEFAULT );

        view_mode = !mode_str.equalsIgnoreCase( WebPlugin.CONFIG_MODE_FULL );
    
Methods Summary
public voidcheckAccess(java.lang.String name, RPRequest request)

        String  method = request.getMethod();

        // System.out.println( "request: " + name + "/" + method );

        if ( view_mode ){

            /*
            request: PluginInterface/getDownloadManager
            request: PluginInterface/getPluginconfig
            request: PluginConfig/getPluginStringParameter[String,String]
            request: DownloadManager/getDownloads
            request: PluginConfig/getPluginIntParameter[String,int]
            request: PluginInterface/getIPFilter
            request: PluginConfig/setPluginParameter[String,int]
            request: PluginConfig/save
            */

            boolean ok = false;

            if ( name.equals( "PluginInterface" )){

                ok  =   method.equals( "getPluginconfig" ) ||
                        method.equals( "getDownloadManager" ) ||
                        method.equals( "getIPFilter" );

            }else if ( name.equals( "DownloadManager" )){

                ok  =   method.equals( "getDownloads" );

            }else if ( name.equals( "PluginConfig" )){

                if (    method.startsWith( "getPlugin") ||
                        method.equals( "save" )){

                    ok  = true;

                }else if ( method.equals( "setPluginParameter[String,int]" )){

                    String  param = (String)request.getParams()[0];

                    ok = param.equals( "MDConfigModel:refresh_period" );
                }
            }


            if ( !ok ){
                throw new RPMethodAccessDeniedException();
            }
        }
    
public voidcheckUploadAllowed()

        if ( view_mode ){
            throw new RPMethodAccessDeniedException();
        }