001 /* MBeanTrustPermission.java -- Represents a trusted bean source. 002 Copyright (C) 2006 Free Software Foundation, Inc. 003 004 This file is part of GNU Classpath. 005 006 GNU Classpath is free software; you can redistribute it and/or modify 007 it under the terms of the GNU General Public License as published by 008 the Free Software Foundation; either version 2, or (at your option) 009 any later version. 010 011 GNU Classpath is distributed in the hope that it will be useful, but 012 WITHOUT ANY WARRANTY; without even the implied warranty of 013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014 General Public License for more details. 015 016 You should have received a copy of the GNU General Public License 017 along with GNU Classpath; see the file COPYING. If not, write to the 018 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 019 02110-1301 USA. 020 021 Linking this library statically or dynamically with other modules is 022 making a combined work based on this library. Thus, the terms and 023 conditions of the GNU General Public License cover the whole 024 combination. 025 026 As a special exception, the copyright holders of this library give you 027 permission to link this library with independent modules to produce an 028 executable, regardless of the license terms of these independent 029 modules, and to copy and distribute the resulting executable under 030 terms of your choice, provided that you also meet, for each linked 031 independent module, the terms and conditions of the license of that 032 module. An independent module is a module which is not derived from 033 or based on this library. If you modify this library, you may extend 034 this exception to your version of the library, but you are not 035 obligated to do so. If you do not wish to do so, delete this 036 exception statement from your version. */ 037 038 package javax.management; 039 040 import java.security.BasicPermission; 041 042 /** 043 * Represents the permission held by a trusted source of 044 * management beans. For a bean to be added to a management 045 * server, the source of that bean must hold this permission. 046 * It has a target, but no actions. Valid values for the target 047 * are <code>"register"</code> and <code>"*"</code>, the latter 048 * representing both the existing <code>"register"</code> target 049 * and any future targets. 050 * 051 * @author Andrew John Hughes (gnu_andrew@member.fsf.org) 052 * @since 1.5 053 */ 054 public class MBeanTrustPermission 055 extends BasicPermission 056 { 057 058 /** 059 * Compatible with JDK 1.5 060 */ 061 private static final long serialVersionUID = -2952178077029018140L; 062 063 /** 064 * Constructs a {@link MBeanTrustPermission} with the given target. 065 * The target must be either <code>"register"</code> or <code>"*"</code>. 066 * The actions of the permission default to <code>null</code>, 067 * so this is equivalent to calling 068 * <code>MBeanTrustPermission(target, null)</code>. 069 * 070 * @param target the target of this permission. 071 * @throws NullPointerException if <code>target</code> is null. 072 * @throws IllegalArgumentException if the target is other than 073 * <code>"register"</code> or <code>"*"</code>. 074 * @see #MBeanTrustPermission(String, String) 075 */ 076 public MBeanTrustPermission(String target) 077 { 078 this(target, null); 079 } 080 081 /** 082 * Constructs a {@link MBeanTrustPermission} with the given target 083 * and actions. The target must be either <code>"register"</code> 084 * or <code>"*"</code>. The actions must be either <code>null</code> 085 * or the empty string, <code>""</code>. 086 * 087 * @param target the target of this permission. 088 * @param actions the actions for this permission. 089 * @throws NullPointerException if <code>target</code> is null. 090 * @throws IllegalArgumentException if the target is other than 091 * <code>"register"</code> or <code>"*"</code> 092 * or actions is other than 093 * <code>null</code> or <code>""</code>. 094 */ 095 public MBeanTrustPermission(String target, String actions) 096 { 097 super(target, actions); 098 if ((!(target.equals("register"))) && 099 (!(target.equals("*")))) 100 throw new IllegalArgumentException("The target must be 'register' or '*'"); 101 if (actions != null && !(actions.length() == 0)) 102 throw new IllegalArgumentException("The actions must be null or ''"); 103 } 104 105 }