Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  
  /*
  * JBoss, Home of Professional Open Source
  * Copyright 2005, JBoss Inc., and individual contributors as indicated
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
 package org.jboss.remoting.network;
 
 
 
A NetworkRegistryWrapper is used to wrap an MBean proxy that implements org.jboss.remoting.network.NetworkRegistryWrapper. If necessary, each call will go through an AccessController.doPrivileged() call.

Author(s):
Ron Sigal
Version:
$Revision: 1.1 $

Copyright May 6, 2008

 
 public class NetworkRegistryWrapper implements NetworkRegistryMBean
 {
    private NetworkRegistryMBean proxy;
    
    {
       this. = proxy;
    }
    
    public void addServer(final Identity identityfinal ServerInvokerMetadata[] invokers)
    {
       if (SecurityUtility.skipAccessControl())
       {
           .addServer(identityinvokers);
           return;
       }
 
       AccessController.doPrivilegednew PrivilegedAction()
       {
          public Object run()
          {
             .addServer(identityinvokers);
             return null;
          }
       });
    }
 
    public void changeDomain(final String newDomain)
    {
       if (SecurityUtility.skipAccessControl())
       {
           .changeDomain(newDomain);
           return;
       }
 
       AccessController.doPrivilegednew PrivilegedAction()
       {
          public Object run()
          {
             .changeDomain(newDomain);
             return null;
          }
       });
    }
    
    public NetworkInstance[] getServers()
    {
      if (SecurityUtility.skipAccessControl())
      {
          return .getServers();
      }
      return (NetworkInstance[]) AccessController.doPrivilegednew PrivilegedAction()
      {
         public Object run()
         {
            return .getServers();
         }
      });
   }
   public boolean hasServer(final Identity identity)
   {
      if (SecurityUtility.skipAccessControl())
      {
          return .hasServer(identity);
      }
      return ((Boolean) AccessController.doPrivilegednew PrivilegedAction()
      {
         public Object run()
         {
            return new Boolean(.hasServer(identity));
         }
      })).booleanValue();
   }
   public NetworkInstance[] queryServers(final NetworkFilter filter)
   {
      if (SecurityUtility.skipAccessControl())
      {
          return .queryServers(filter);
      }
      return (NetworkInstance[]) AccessController.doPrivilegednew PrivilegedAction()
      {
         public Object run()
         {
            return .queryServers(filter);
         }
      });
   }
   public void removeServer(final Identity identity)
   {
      if (SecurityUtility.skipAccessControl())
      {
          .removeServer(identity);
          return;
      }
      AccessController.doPrivilegednew PrivilegedAction()
      {
         public Object run()
         {
            .removeServer(identity);
            return null;
         }
      });
   }
   public void updateServer(final Identity identityfinal ServerInvokerMetadata[] invokers)
   {
      if (SecurityUtility.skipAccessControl())
      {
          .updateServer(identityinvokers);
          return;
      }
      AccessController.doPrivilegednew PrivilegedAction()
      {
         public Object run()
         {
            .updateServer(identityinvokers);
            return null;
         }
      });
   }
   
   public void addNotificationListener(final NotificationListener listener,
                                       final NotificationFilter filter,
                                       final Object handback)
   {
      if (SecurityUtility.skipAccessControl())
      {
          .addNotificationListener(listenerfilterhandback);
          return;
      }
      try
      {
         AccessController.doPrivilegednew PrivilegedExceptionAction()
         {
            public Object run() throws IllegalArgumentException
            {
               .addNotificationListener(listenerfilterhandback);
               return null;
            }
         });
      }
      catch (PrivilegedActionException e)
      {
         throw (IllegalArgumentExceptione.getCause();
      }
   }
   {
      if (SecurityUtility.skipAccessControl())
      {
          return .getNotificationInfo();
      }
      return (MBeanNotificationInfo[]) AccessController.doPrivilegednew PrivilegedAction()
      {
         public Object run()
         {
            return .getNotificationInfo();
         }
      });
   }
   public void removeNotificationListener(final NotificationListener listener)
   {
      if (SecurityUtility.skipAccessControl())
      {
          .removeNotificationListener(listener);
          return;
      }
      try
      {
         AccessController.doPrivilegednew PrivilegedExceptionAction()
         {
            public Object run() throws ListenerNotFoundException
            {
               .removeNotificationListener(listener);
               return null;
            }
         });
      }
      catch (PrivilegedActionException e)
      {
         throw (ListenerNotFoundExceptione.getCause();
      }
   }
   
   public void postDeregister()
   {
      if (SecurityUtility.skipAccessControl())
      {
          .postDeregister();
          return;
      }
      AccessController.doPrivilegednew PrivilegedAction()
      {
         public Object run()
         {
            .postDeregister();
            return null;
         }
      });
   }
   public void postRegister(final Boolean registrationDone)
   {
      if (SecurityUtility.skipAccessControl())
      {
          .postRegister(registrationDone);
          return;
      }
      AccessController.doPrivilegednew PrivilegedAction()
      {
         public Object run()
         {
            .postRegister(registrationDone);
            return null;
         }
      });
   }
   public void preDeregister() throws Exception
   {
      if (SecurityUtility.skipAccessControl())
      {
          .preDeregister();
          return;
      }
      try
      {
         AccessController.doPrivilegednew PrivilegedExceptionAction()
         {
            public Object run() throws Exception
            {
               .preDeregister();
               return null;
            }
         });
      }
      catch (PrivilegedActionException e)
      {
         throw (Exceptione.getCause();
      }
   }
   public ObjectName preRegister(final MBeanServer serverfinal ObjectName name)
   throws Exception
   {
      if (SecurityUtility.skipAccessControl())
      {
          return .preRegister(servername);
      }
      try
      {
         return (ObjectName) AccessController.doPrivilegednew PrivilegedExceptionAction()
         {
            public Object run() throws Exception
            {
               return .preRegister(servername);
            }
         });
      }
      catch (PrivilegedActionException e)
      {
         throw (Exceptione.getCause();
      }
   }
New to GrepCode? Check out our FAQ X