You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Alex O'Ree <al...@apache.org> on 2019/04/26 11:11:14 UTC

Jmx example for adding or removing users?

I am looking for a way to programmatically add or remove user accounts
using tomcats user xml file as a store without restarting tomcat. Can this
be done using jmx?

Re: Jmx example for adding or removing users?

Posted by John Dale <jc...@gmail.com>.
You're missing database driven roles based user authentication and
authorization.  :)

I commend you, sir, for attempting the tomcat default user management
save button!

On 5/9/19, Alex O'Ree <al...@apache.org> wrote:
> Well less than perfect. Tomcat out of the box is setup with the users xml
> file. What's exposed as mbeans is the
> "org.apache.catalina.mbeans.MemoryUserDatabaseMBean".
> I can add uses to it via mbean, however calling the "save" method does not
> update the tomcat-users.xml file. Am i missing something?
>
> On Fri, Apr 26, 2019 at 7:14 PM Alex O'Ree <al...@apache.org> wrote:
>
>> Ahh perfect, thanks.
>>
>> On Fri, Apr 26, 2019 at 12:34 PM Mark Thomas <ma...@apache.org> wrote:
>>
>>> On 26/04/2019 12:11, Alex O'Ree wrote:
>>> > I am looking for a way to programmatically add or remove user accounts
>>> > using tomcats user xml file as a store without restarting tomcat. Can
>>> this
>>> > be done using jmx?
>>> >
>>>
>>> Yes. Look under Users -> UserDatabase
>>>
>>> Mark
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Jmx example for adding or removing users?

Posted by Mark Thomas <ma...@apache.org>.
On 10/05/2019 13:52, Alex O'Ree wrote:
> According to this
> https://tomcat.apache.org/tomcat-8.5-doc/realm-howto.html#UserDatabaseRealm
> 
> It appears that xml file is loaded into a memory realm at start time. JMX
> changes are immediate, but is there an easy way to save the changes back to
> the xml file?

That would be the save() method on MemoryUserDatabase

Mark


> 
> Digging around in the source, I think the answer is no but I may have
> missed something. Can anyone confirm this?
> 
> 
> 
> On Fri, May 10, 2019 at 7:07 AM Alex O'Ree <sp...@gmail.com> wrote:
> 
>> Ahh i missed the exception, had the logs redirected. thanks
>>
>> On Fri, May 10, 2019 at 3:46 AM Mark Thomas <ma...@apache.org> wrote:
>>
>>> On 10/05/2019 03:45, Alex O'Ree wrote:
>>>> Well less than perfect. Tomcat out of the box is setup with the users
>>> xml
>>>> file. What's exposed as mbeans is the
>>>> "org.apache.catalina.mbeans.MemoryUserDatabaseMBean".
>>>> I can add uses to it via mbean, however calling the "save" method does
>>> not
>>>> update the tomcat-users.xml file. Am i missing something?
>>>
>>> The MemoryUserDatabase is read-only by default. The attempt to save your
>>> changes should have triggered an exception with an appropriate error
>>> message.
>>>
>>> Mark
>>>
>>>
>>>>
>>>> On Fri, Apr 26, 2019 at 7:14 PM Alex O'Ree <al...@apache.org> wrote:
>>>>
>>>>> Ahh perfect, thanks.
>>>>>
>>>>> On Fri, Apr 26, 2019 at 12:34 PM Mark Thomas <ma...@apache.org> wrote:
>>>>>
>>>>>> On 26/04/2019 12:11, Alex O'Ree wrote:
>>>>>>> I am looking for a way to programmatically add or remove user
>>> accounts
>>>>>>> using tomcats user xml file as a store without restarting tomcat. Can
>>>>>> this
>>>>>>> be done using jmx?
>>>>>>>
>>>>>>
>>>>>> Yes. Look under Users -> UserDatabase
>>>>>>
>>>>>> Mark
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>>>
>>>>>>
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>>
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Jmx example for adding or removing users?

Posted by Alex O'Ree <al...@apache.org>.
According to this
https://tomcat.apache.org/tomcat-8.5-doc/realm-howto.html#UserDatabaseRealm

It appears that xml file is loaded into a memory realm at start time. JMX
changes are immediate, but is there an easy way to save the changes back to
the xml file?

Digging around in the source, I think the answer is no but I may have
missed something. Can anyone confirm this?



On Fri, May 10, 2019 at 7:07 AM Alex O'Ree <sp...@gmail.com> wrote:

> Ahh i missed the exception, had the logs redirected. thanks
>
> On Fri, May 10, 2019 at 3:46 AM Mark Thomas <ma...@apache.org> wrote:
>
>> On 10/05/2019 03:45, Alex O'Ree wrote:
>> > Well less than perfect. Tomcat out of the box is setup with the users
>> xml
>> > file. What's exposed as mbeans is the
>> > "org.apache.catalina.mbeans.MemoryUserDatabaseMBean".
>> > I can add uses to it via mbean, however calling the "save" method does
>> not
>> > update the tomcat-users.xml file. Am i missing something?
>>
>> The MemoryUserDatabase is read-only by default. The attempt to save your
>> changes should have triggered an exception with an appropriate error
>> message.
>>
>> Mark
>>
>>
>> >
>> > On Fri, Apr 26, 2019 at 7:14 PM Alex O'Ree <al...@apache.org> wrote:
>> >
>> >> Ahh perfect, thanks.
>> >>
>> >> On Fri, Apr 26, 2019 at 12:34 PM Mark Thomas <ma...@apache.org> wrote:
>> >>
>> >>> On 26/04/2019 12:11, Alex O'Ree wrote:
>> >>>> I am looking for a way to programmatically add or remove user
>> accounts
>> >>>> using tomcats user xml file as a store without restarting tomcat. Can
>> >>> this
>> >>>> be done using jmx?
>> >>>>
>> >>>
>> >>> Yes. Look under Users -> UserDatabase
>> >>>
>> >>> Mark
>> >>>
>> >>> ---------------------------------------------------------------------
>> >>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> >>> For additional commands, e-mail: users-help@tomcat.apache.org
>> >>>
>> >>>
>> >
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>

Re: Jmx example for adding or removing users?

Posted by Alex O'Ree <sp...@gmail.com>.
Ahh i missed the exception, had the logs redirected. thanks

On Fri, May 10, 2019 at 3:46 AM Mark Thomas <ma...@apache.org> wrote:

> On 10/05/2019 03:45, Alex O'Ree wrote:
> > Well less than perfect. Tomcat out of the box is setup with the users xml
> > file. What's exposed as mbeans is the
> > "org.apache.catalina.mbeans.MemoryUserDatabaseMBean".
> > I can add uses to it via mbean, however calling the "save" method does
> not
> > update the tomcat-users.xml file. Am i missing something?
>
> The MemoryUserDatabase is read-only by default. The attempt to save your
> changes should have triggered an exception with an appropriate error
> message.
>
> Mark
>
>
> >
> > On Fri, Apr 26, 2019 at 7:14 PM Alex O'Ree <al...@apache.org> wrote:
> >
> >> Ahh perfect, thanks.
> >>
> >> On Fri, Apr 26, 2019 at 12:34 PM Mark Thomas <ma...@apache.org> wrote:
> >>
> >>> On 26/04/2019 12:11, Alex O'Ree wrote:
> >>>> I am looking for a way to programmatically add or remove user accounts
> >>>> using tomcats user xml file as a store without restarting tomcat. Can
> >>> this
> >>>> be done using jmx?
> >>>>
> >>>
> >>> Yes. Look under Users -> UserDatabase
> >>>
> >>> Mark
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >>> For additional commands, e-mail: users-help@tomcat.apache.org
> >>>
> >>>
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Jmx example for adding or removing users?

Posted by Mark Thomas <ma...@apache.org>.
On 10/05/2019 03:45, Alex O'Ree wrote:
> Well less than perfect. Tomcat out of the box is setup with the users xml
> file. What's exposed as mbeans is the
> "org.apache.catalina.mbeans.MemoryUserDatabaseMBean".
> I can add uses to it via mbean, however calling the "save" method does not
> update the tomcat-users.xml file. Am i missing something?

The MemoryUserDatabase is read-only by default. The attempt to save your
changes should have triggered an exception with an appropriate error
message.

Mark


> 
> On Fri, Apr 26, 2019 at 7:14 PM Alex O'Ree <al...@apache.org> wrote:
> 
>> Ahh perfect, thanks.
>>
>> On Fri, Apr 26, 2019 at 12:34 PM Mark Thomas <ma...@apache.org> wrote:
>>
>>> On 26/04/2019 12:11, Alex O'Ree wrote:
>>>> I am looking for a way to programmatically add or remove user accounts
>>>> using tomcats user xml file as a store without restarting tomcat. Can
>>> this
>>>> be done using jmx?
>>>>
>>>
>>> Yes. Look under Users -> UserDatabase
>>>
>>> Mark
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>>
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Jmx example for adding or removing users?

Posted by Alex O'Ree <al...@apache.org>.
Well less than perfect. Tomcat out of the box is setup with the users xml
file. What's exposed as mbeans is the
"org.apache.catalina.mbeans.MemoryUserDatabaseMBean".
I can add uses to it via mbean, however calling the "save" method does not
update the tomcat-users.xml file. Am i missing something?

On Fri, Apr 26, 2019 at 7:14 PM Alex O'Ree <al...@apache.org> wrote:

> Ahh perfect, thanks.
>
> On Fri, Apr 26, 2019 at 12:34 PM Mark Thomas <ma...@apache.org> wrote:
>
>> On 26/04/2019 12:11, Alex O'Ree wrote:
>> > I am looking for a way to programmatically add or remove user accounts
>> > using tomcats user xml file as a store without restarting tomcat. Can
>> this
>> > be done using jmx?
>> >
>>
>> Yes. Look under Users -> UserDatabase
>>
>> Mark
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>

Re: Jmx example for adding or removing users?

Posted by Alex O'Ree <al...@apache.org>.
Ahh perfect, thanks.

On Fri, Apr 26, 2019 at 12:34 PM Mark Thomas <ma...@apache.org> wrote:

> On 26/04/2019 12:11, Alex O'Ree wrote:
> > I am looking for a way to programmatically add or remove user accounts
> > using tomcats user xml file as a store without restarting tomcat. Can
> this
> > be done using jmx?
> >
>
> Yes. Look under Users -> UserDatabase
>
> Mark
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Jmx example for adding or removing users?

Posted by Mark Thomas <ma...@apache.org>.
On 26/04/2019 12:11, Alex O'Ree wrote:
> I am looking for a way to programmatically add or remove user accounts
> using tomcats user xml file as a store without restarting tomcat. Can this
> be done using jmx?
> 

Yes. Look under Users -> UserDatabase

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org