1. /*
  2. * @(#)MBeanTrustPermission.java 1.15 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 javax.management;
  8. import java.security.BasicPermission;
  9. /**
  10. * This permission represents "trust" in a signer or codebase.
  11. * <p>
  12. * MBeanTrustPermission contains a target name but no actions list.
  13. * A single target name, "register", is defined for this permission.
  14. * The target "*" is also allowed, permitting "register" and any future
  15. * targets that may be defined.
  16. * Only the null value or the empty string are allowed for the action
  17. * to allow the policy object to create the permissions specified in
  18. * the policy file.
  19. * <p>
  20. * If a signer, or codesource is granted this permission, then it is
  21. * considered a trusted source for MBeans. Only MBeans from trusted
  22. * sources may be registered in the MBeanServer.
  23. *
  24. * @since 1.5
  25. * @since.unbundled JMX 1.2
  26. */
  27. public class MBeanTrustPermission extends BasicPermission {
  28. private static final long serialVersionUID = -2952178077029018140L;
  29. /** <p>Create a new MBeanTrustPermission with the given name.</p>
  30. <p>This constructor is equivalent to
  31. <code>MBeanTrustPermission(name,null)</code>.</p>
  32. @param name the name of the permission. It must be
  33. "register" or "*" for this permission.
  34. @exception NullPointerException if the name is null.
  35. @exception IllegalArgumentException if the name is neither
  36. "register" nor "*".
  37. */
  38. public MBeanTrustPermission(String name) {
  39. this(name, null);
  40. }
  41. /** <p>Create a new MBeanTrustPermission with the given name.</p>
  42. @param name the name of the permission. It must be
  43. "register" or "*" for this permission.
  44. @param actions the actions for the permission. It must be
  45. null or <code>""</code>.
  46. @exception NullPointerException if the name is null.
  47. @exception IllegalArgumentException if the name is neither
  48. "register" nor "*"; or if <code>actions</code> is a non-null
  49. non-empty string.
  50. */
  51. public MBeanTrustPermission(String name, String actions) {
  52. super(name, actions);
  53. /* Check that actions is a null empty string */
  54. if (actions != null && actions.length() > 0)
  55. throw new IllegalArgumentException("MBeanTrustPermission " +
  56. "actions must be null: " +
  57. actions);
  58. if (!name.equals("register") && !name.equals("*"))
  59. throw new IllegalArgumentException("MBeanTrustPermission: " +
  60. "Unknown target name " +
  61. "[" + name + "]");
  62. }
  63. }