[ mx4j-Bugs-1116450 ] spec ambiguity? security check for getDomains()

"SourceForge.net" <[email protected]>
Newsgroups gmane.comp.java.mx4j.devel
Message-ID <[email protected]>
Bugs item #1116450, was opened at 2005-02-04 21:23
Message generated for change (Comment added) made by emcmanus
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=450647&aid=1116450&group_id=47745

Category: JMX implementation
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Jeremy Boynes (jboynes)
Assigned to: Nobody/Anonymous (nobody)
Summary: spec ambiguity? security check for getDomains()

Initial Comment:
Currently MBS.getDomains() does not perform any
security check which is a bug. However, the JavaDoc for
J2SE1.5 and J2EE1.4 are different.

The JavaDoc for J2SE1.5 says:
For the getDomains method, the caller's permissions
must imply MBeanPermission(null, null, name,
"getDomains"). Additionally, for each domain d in the
returned array, if the caller's permissions do not
imply MBeanPermission(null, null, new
ObjectName("d:x=x"), "getDomains"), the domain is
eliminated from the array. Here, x=x is any key=value
pair, needed to satisfy ObjectName's constructor but
not otherwise relevant.

For J2EE1.4:
For the getDomains method, the caller's permissions
must imply MBeanPermission(null, null, name,
"getDomains"). Additionally, for each domain d in the
returned array, if the caller's permissions do not
imply MBeanPermission(null, null, new
ObjectName("d:x=x"), "queryMBeans"), the domain is
eliminated from the array. Here, x=x is any key=value
pair, needed to satisfy ObjectName's constructor but
not otherwise relevant.

Note difference between "getDomains" and "queryMBeans"

Moreover, JDK1.5 seems to first check for
(null,null,null, "getDomains") and then for each
returned domain check (null, null, new
ObjectName(domain, "x", "x"), "getDomains")

Below is an impl of getDomains() that mimics JDK1.5.

   public String[] getDomains()
   {
      SecurityManager sm = System.getSecurityManager();
      if (sm != null)
      {
         sm.checkPermission(new MBeanPermission(null,
null, null, "getDomains"));
      }
      Set keys;
      synchronized (domains)
      {
         keys = new HashSet(domains.keySet());
      }
      if (sm != null)
      {
         for (Iterator i = keys.iterator(); i.hasNext();)
         {
            String domain = (String) i.next();
            try
            {
               ObjectName name = new ObjectName(domain,
"x", "x");
               sm.checkPermission(new
MBeanPermission(null, null, name, "getDomains"));
            } catch (SecurityException e)
            {
               i.remove();
               continue;
            } catch (MalformedObjectNameException e)
            {
               throw new AssertionError();
            }
         }
      }
      return (String[])keys.toArray(new
String[keys.size()]);
   }


----------------------------------------------------------------------

Comment By: Eamonn McManus (emcmanus)
Date: 2005-02-07 11:31

Message:
Logged In: YES 
user_id=770046

This was an error in the original JMX spec v1.2. See:
<http://java.sun.com/products/JavaManagement/jmx-1.2-errata.html#getdomains>
Of course the check is against "getDomains", not "queryMBeans".

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=450647&aid=1116450&group_id=47745


-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.