1. /*
  2. * @(#)SecureClassLoaderRepository.java 1.8 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package com.sun.jmx.mbeanserver;
  8. import javax.management.loading.ClassLoaderRepository;
  9. /**
  10. * Fix security hole in ClassLoaderRepository. This class wraps
  11. * the actual ClassLoaderRepository implementation so that
  12. * only the methods from {@link javax.management.loading.ClassLoaderRepository}
  13. * can be accessed (read-only).
  14. *
  15. * @since 1.5
  16. */
  17. public final class SecureClassLoaderRepository
  18. implements ClassLoaderRepository {
  19. private final ClassLoaderRepository clr;
  20. /**
  21. * Creates a new secure ClassLoaderRepository wrapping an
  22. * unsecure implementation.
  23. * @param clr Unsecure {@link ClassLoaderRepository} implementation
  24. * to wrap.
  25. **/
  26. public SecureClassLoaderRepository(ClassLoaderRepository clr) {
  27. this.clr=clr;
  28. }
  29. public final Class loadClass(String className)
  30. throws ClassNotFoundException {
  31. return clr.loadClass(className);
  32. }
  33. public final Class loadClassWithout(ClassLoader loader,
  34. String className)
  35. throws ClassNotFoundException {
  36. return clr.loadClassWithout(loader,className);
  37. }
  38. public final Class loadClassBefore(ClassLoader loader,
  39. String className)
  40. throws ClassNotFoundException {
  41. return clr.loadClassBefore(loader,className);
  42. }
  43. }