Bug 602450 - RFE: resource types 'Tomcat User' and 'Tomcat Group' are being created with extraneous double quotes
RFE: resource types 'Tomcat User' and 'Tomcat Group' are being created with e...
Status: CLOSED WONTFIX
Product: RHQ Project
Classification: Other
Component: Plugins (Show other bugs)
3.0.0
All All
low Severity low (vote)
: ---
: ---
Assigned To: RHQ Project Maintainer
Mike Foley
:
Depends On: jon-sprint11-bugs
Blocks: rhq_auto_blocker jon30-bugs
  Show dependency treegraph
 
Reported: 2010-06-09 16:52 EDT by John Sefler
Modified: 2014-05-29 16:24 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2014-05-29 16:24:58 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


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 16:52 EDT, John Sefler
no flags Details

  None (edit)
Description John Sefler 2010-06-09 16:52:31 EDT
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 17:16:23 EDT
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-21 21:27:25 EDT
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 09:17:27 EDT
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 09:27:28 EDT
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 10:50:37 EDT
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 11:00:33 EDT
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 15:49:41 EDT
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 16:24:58 EDT
Closing due to inactivity.

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