aboutsummaryrefslogtreecommitdiff
path: root/libjava/classpath/javax/management/MBeanPermission.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/javax/management/MBeanPermission.java')
-rw-r--r--libjava/classpath/javax/management/MBeanPermission.java201
1 files changed, 100 insertions, 101 deletions
diff --git a/libjava/classpath/javax/management/MBeanPermission.java b/libjava/classpath/javax/management/MBeanPermission.java
index 076ac86..10813e4 100644
--- a/libjava/classpath/javax/management/MBeanPermission.java
+++ b/libjava/classpath/javax/management/MBeanPermission.java
@@ -113,7 +113,7 @@ import java.util.TreeSet;
* represent <code>null</code>. When this occurs in a
* required permission, anything may match it. When this
* forms part of a permission held by the user, it only
- * matches another <code>null</code> value.
+ * matches another <code>null</code> value.
* </p>
* <p>The list of valid actions is as follows:</p>
* <ul>
@@ -152,7 +152,7 @@ public class MBeanPermission
* The list of actions associated with this permission.
*/
private String actions;
-
+
/**
* The list of actions as an ordered set.
*/
@@ -166,7 +166,7 @@ public class MBeanPermission
/**
* Initialise the set of valid actions.
*/
- static
+ static
{
validSet = new HashSet<String>();
validSet.add("addNotificationListener");
@@ -232,11 +232,11 @@ public class MBeanPermission
* @param actions the actions associated with this permission.
*/
public MBeanPermission(String className, String member,
- ObjectName name, String actions)
+ ObjectName name, String actions)
{
- this((className == null ? "-" : className) + "#"
- + (member == null ? "-" : member) + "["
- + (name == null ? "-" : name.toString()) + "]", actions);
+ this((className == null ? "-" : className) + "#"
+ + (member == null ? "-" : member) + "["
+ + (name == null ? "-" : name.toString()) + "]", actions);
}
/**
@@ -251,9 +251,9 @@ public class MBeanPermission
{
if (obj instanceof MBeanPermission)
{
- MBeanPermission p = (MBeanPermission) obj;
- return (p.getName().equals(getName()) &&
- p.getActions().equals(actions));
+ MBeanPermission p = (MBeanPermission) obj;
+ return (p.getName().equals(getName()) &&
+ p.getActions().equals(actions));
}
return false;
}
@@ -269,9 +269,9 @@ public class MBeanPermission
CPStringBuilder builder = new CPStringBuilder();
while (it.hasNext())
{
- builder.append(it.next());
- if (it.hasNext())
- builder.append(",");
+ builder.append(it.next());
+ if (it.hasNext())
+ builder.append(",");
}
return builder.toString();
}
@@ -312,7 +312,7 @@ public class MBeanPermission
* of this permission. If the <code>queryMBeans</code> action is presented,
* the <code>queryNames</code> action is implied.</li>
* </ul>
- *
+ *
* @param p the permission to check that this permission implies.
* @return true if this permission implies <code>p</code>.
*/
@@ -320,21 +320,21 @@ public class MBeanPermission
{
if (p instanceof MBeanPermission)
{
- MBeanPermission mp = (MBeanPermission) p;
- NameHolder pName = new NameHolder(mp.getName());
- NameHolder name = new NameHolder(getName());
- if (!(name.equals(pName)))
- return false;
- for (String nextAction : mp.actionSet)
- {
- boolean found = actions.contains(nextAction);
- if (!found)
- if (nextAction.equals("queryNames"))
- found = actions.contains("queryMBeans");
- if (!found)
- return false;
- }
- return true;
+ MBeanPermission mp = (MBeanPermission) p;
+ NameHolder pName = new NameHolder(mp.getName());
+ NameHolder name = new NameHolder(getName());
+ if (!(name.equals(pName)))
+ return false;
+ for (String nextAction : mp.actionSet)
+ {
+ boolean found = actions.contains(nextAction);
+ if (!found)
+ if (nextAction.equals("queryNames"))
+ found = actions.contains("queryMBeans");
+ if (!found)
+ return false;
+ }
+ return true;
}
return false;
}
@@ -373,47 +373,47 @@ public class MBeanPermission
int memberIndex = name.indexOf("#");
int onIndex = name.indexOf("[");
if (onIndex == -1)
- {
- if (memberIndex == -1)
- className = name;
- else
- {
- className = name.substring(0, memberIndex);
- member = name.substring(memberIndex + 1);
- }
- }
+ {
+ if (memberIndex == -1)
+ className = name;
+ else
+ {
+ className = name.substring(0, memberIndex);
+ member = name.substring(memberIndex + 1);
+ }
+ }
else
- {
- if (memberIndex == -1)
- {
- className = name.substring(0, onIndex);
- objectName = name.substring(onIndex + 1,
- name.length() - 1);
- }
- else
- {
- className = name.substring(0, memberIndex);
- member = name.substring(memberIndex + 1, onIndex);
- objectName = name.substring(onIndex + 1,
- name.length() - 1);
- }
- }
+ {
+ if (memberIndex == -1)
+ {
+ className = name.substring(0, onIndex);
+ objectName = name.substring(onIndex + 1,
+ name.length() - 1);
+ }
+ else
+ {
+ className = name.substring(0, memberIndex);
+ member = name.substring(memberIndex + 1, onIndex);
+ objectName = name.substring(onIndex + 1,
+ name.length() - 1);
+ }
+ }
if (className.equals("-"))
- className = null;
+ className = null;
if (member.equals("-"))
- member = null;
+ member = null;
if (objectName == null || objectName.equals("-"))
- this.objectName = null;
+ this.objectName = null;
else
- try
- {
- this.objectName = new ObjectName(objectName);
- }
- catch (MalformedObjectNameException e)
- {
- throw (Error)
- (new InternalError("Invalid object name.").initCause(e));
- }
+ try
+ {
+ this.objectName = new ObjectName(objectName);
+ }
+ catch (MalformedObjectNameException e)
+ {
+ throw (Error)
+ (new InternalError("Invalid object name.").initCause(e));
+ }
}
/**
@@ -436,46 +436,46 @@ public class MBeanPermission
* object name of this name holder is a pattern,
* {@link ObjectName#apply(ObjectName)} may be used as well.</li>
* </ul>
- *
+ *
* @param obj the object to compare with this.
* @return true if the above holds.
*/
public boolean equals(Object obj)
{
if (obj instanceof NameHolder)
- {
- NameHolder nh = (NameHolder) obj;
- boolean cn = false;
- String ocn = nh.getClassName();
- if (ocn == null || className.equals("*"))
- cn = true;
- else
- {
- int wcIndex = className.indexOf("*");
- if (wcIndex != -1)
- cn = ocn.startsWith(className.substring(0, wcIndex));
- else
- cn = ocn.equals(className);
- }
- boolean m = false;
- String om = nh.getMember();
- if (om == null || member.equals("*"))
- m = true;
- else
- m = om.equals(member);
- boolean on = false;
- ObjectName oon = nh.getObjectName();
- if (oon == null)
- on = true;
- else if (objectName.isPattern())
- on = objectName.apply(oon);
- else
- on = oon.equals(objectName);
- return (cn && m && on);
- }
+ {
+ NameHolder nh = (NameHolder) obj;
+ boolean cn = false;
+ String ocn = nh.getClassName();
+ if (ocn == null || className.equals("*"))
+ cn = true;
+ else
+ {
+ int wcIndex = className.indexOf("*");
+ if (wcIndex != -1)
+ cn = ocn.startsWith(className.substring(0, wcIndex));
+ else
+ cn = ocn.equals(className);
+ }
+ boolean m = false;
+ String om = nh.getMember();
+ if (om == null || member.equals("*"))
+ m = true;
+ else
+ m = om.equals(member);
+ boolean on = false;
+ ObjectName oon = nh.getObjectName();
+ if (oon == null)
+ on = true;
+ else if (objectName.isPattern())
+ on = objectName.apply(oon);
+ else
+ on = oon.equals(objectName);
+ return (cn && m && on);
+ }
return false;
}
-
+
/**
* Returns the class name.
*/
@@ -540,11 +540,10 @@ public class MBeanPermission
{
for (String action : actionSet)
{
- if (!(validSet.contains(action)))
- throw new IllegalArgumentException("Invalid action "
- + action + " found.");
+ if (!(validSet.contains(action)))
+ throw new IllegalArgumentException("Invalid action "
+ + action + " found.");
}
}
}
-