Bug 602450 - RFE: resource types 'Tomcat User' and 'Tomcat Group' are being created with extraneous double quotes
Summary: RFE: resource types 'Tomcat User' and 'Tomcat Group' are being created with e...
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: RHQ Project
Classification: Other
Component: Plugins
Version: 3.0.0
Hardware: All
OS: All
low
low
Target Milestone: ---
: ---
Assignee: RHQ Project Maintainer
QA Contact: Mike Foley
URL:
Whiteboard:
Depends On: jon-sprint11-bugs
Blocks: rhq_auto_blocker jon30-bugs
TreeView+ depends on / blocked
 
Reported: 2010-06-09 20:52 UTC by John Sefler
Modified: 2014-05-29 20:24 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-05-29 20:24:58 UTC
Embargoed:


Attachments (Terms of Use)
Notice that Tomcat Users and Groups are surrounded by double quotes, but not Tomcat Roles (225.73 KB, image/png)
2010-06-09 20:52 UTC, John Sefler
no flags Details

Description John Sefler 2010-06-09 20:52:31 UTC
Created attachment 422702 [details]
Notice that Tomcat Users and Groups are surrounded by double quotes, but not Tomcat Roles

Description of problem:
When creating a 'Tomcat User' or 'Tomcat Role', the resource name supplied at creation time ends up getting surrounded by double quotes.  Looks like a coding typo to me.  No other child resource names are augmented this way.

See the attached screenshot.


Version-Release number of selected component (if applicable):
 RHQ
version: 3.0.0-SNAPSHOT
build number: b346cc5 

How reproducible:
always

Steps to Reproduce:
1. Inventory a running Tomcat Server
2. Open the Tomcat Server > User Database
3. Create a Tomcat Role, User, and Group
  
Actual results:
The Tomcat User and Tomcat Group gets surrounded by double quotes 

Expected results:
The resource names created should match what the user specified (without double quotes).


Additional info:

Comment 1 Jay Shaughnessy 2010-06-21 21:16:23 UTC
I agree that this seems odd but I think it is working as expected. We don't augment the input in any way. You get the same behavior even if you create groups or users via JConsole.

I recommend closing this one as Not A Bug.

Comment 2 Ian Springer 2010-06-22 01:27:25 UTC
Are you sure? It looks like the following code is from TomcatUserDatabaseComponent.createResource() explicitly adds quotes around user and group names:

if (TomcatGroupComponent.RESOURCE_TYPE_NAME.equals(resourceTypeName)) {
                name = report.getResourceConfiguration().getSimple("groupname").getStringValue();
                objectName = String.format("Users:type=Group,groupname=\"%s\",database=UserDatabase", name);
                operation = "createGroup";
            } else if (TomcatRoleComponent.RESOURCE_TYPE_NAME.equals(resourceTypeName)) {
                name = report.getResourceConfiguration().getSimple("rolename").getStringValue();
                objectName = String.format("Users:type=Role,rolename=%s,database=UserDatabase", name);
                operation = "createRole";
            } else if (TomcatUserComponent.RESOURCE_TYPE_NAME.equals(resourceTypeName)) {
                name = report.getResourceConfiguration().getSimple("username").getStringValue();
                objectName = String.format("Users:type=User,username=\"%s\",database=UserDatabase", name);
                operation = "createUser";
            } else {
                throw new UnsupportedOperationException("Unsupported Resource type: " + resourceTypeName);
            }

Comment 3 Jay Shaughnessy 2010-06-22 13:17:27 UTC
If I recall correctly, I went through extra effort to treat the names in the same way Tomcat was presenting the names.  As I mentioned above, if you work explicitly with JConsole you will see the same dichotomy of quoted vs. non-quoted names for users and groups vs roles.

This is working as designed as I tried to mimic what I saw in JConsole.  I think a different representation in RHQ would be an RFE as opposed to a bug.

Comment 4 Corey Welton 2010-06-23 13:27:28 UTC
I agree with jsefler that things should look "clean" to the user, but if we are mimicking the appearance of however data is rendered in jconsole, this seems to be an explicit design decision.

Fixing this will have to take in several consideration:

* Whether edited data needs to be submitted back with quotes
* Whether it even matters, i.e., is the data stored in the xml files with extraneous quotes

Either way, I don't think this should/will be "fixed" in the present release, as it is currently designed to show parity with existing jconsole usage.  I will mark it as an RFE and move it back to NEW for future consideration.

Comment 5 John Sefler 2010-06-28 14:50:37 UTC
Seems to me that Jay's extra effort to "mimic what I saw in JConsole" is proliferating a JConsole bug.  If RHQ is really being used by a customer to manage Tomcat, then there is no reason for the user to be using JConsole and will therefore not care how resources are rendered in JConsole.  Consequently it will appear to the user that RHQ is inconsistently rendering Tomcat Users and Groups surrounded by double quotes and Tomcat Roles are not.

So what login id should be typed in at a Tomcat authentication prompt?  "tomcat" (with quotes) or tomcat (without quotes)?  According to RHQ, "tomcat" (with quotes) is the login id; which is wrong.

My vote is to render the resource names correctly regardless of how JConsole renders.

Comment 6 Jay Shaughnessy 2010-06-28 15:00:33 UTC
I don't think it's a JConsole bug, JConsole is an independent observer.  It's really what the TC mbean is doing here that is in question.  Is there a reported bug against this mbean behavior for TC?

I have nothing against rendering it differently but we need to prove in fact that the current impl is wrong, and leads to errors, as opposed to just not looking good.  We may be proliferating an issue in the TC mbean impl, but if so we should report an issue against TC in addition to any workaround we impl.

Comment 7 Ian Springer 2010-06-28 19:49:41 UTC
In this case, the [name] key property in the user and group MBean names has a "quoted value". The Javadoc of http://java.sun.com/j2se/1.5.0/docs/api/javax/management/ObjectName.html defines what a quoted value is. They are essentially something you can use when you need to escape characters which normally have a special meaning in ObjectNames (e.g. comma, asterisk, etc.). 

Typical user and group names would not need to be quoted,because they'd generally be alphanumeric. But if we wanted to be extra safe and quote the username in case it contains any illegal characters, we could do the following in TomcatUserDatabaseComponent.createResource():

String quotedUsername = ObjectName.quote(username);
String objectName = String.format("Users:type=User,username=%s,database=UserDatabase", quotedUsername);

In any case, I think we should update org.rhq.plugins.jmx.ObjectNameQueryUtility to more intelligently handle quoted key property values, so that if it is processing the ObjectName [Users:type=User,username=%name%,database=UserDatabase] and encounters an MBean named [Users:type=User,username="bob",database=UserDatabase], it sets the [name] plugin config prop to [bob], not ["bob"].

Comment 8 Jay Shaughnessy 2014-05-29 20:24:58 UTC
Closing due to inactivity.


Note You need to log in before you can comment on or make changes to this bug.