Bug 602450

Summary: RFE: resource types 'Tomcat User' and 'Tomcat Group' are being created with extraneous double quotes
Product: [Other] RHQ Project Reporter: John Sefler <jsefler>
Component: PluginsAssignee: RHQ Project Maintainer <rhq-maint>
Status: CLOSED WONTFIX QA Contact: Mike Foley <mfoley>
Severity: low Docs Contact:
Priority: low    
Version: 3.0.0CC: ccrouch, jshaughn
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-05-29 20:24:58 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 593121    
Bug Blocks: 562434, 625146    
Attachments:
Description Flags
Notice that Tomcat Users and Groups are surrounded by double quotes, but not Tomcat Roles none

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.