<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2963" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=394241207-05112006><FONT face=Arial
color=#0000ff size=2>Andy -</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=394241207-05112006><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=394241207-05112006><FONT face=Arial
color=#0000ff size=2>You can store the reference by assigning it to
something to which you'll have access when you need it. You'll "need it"
later, at times when OpenCms calls your code in response to new user requests or
other events. The easiest thing is to assign the CmsObject instance to a
static field of (e.g.) your module class, e.g.</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=394241207-05112006><FONT face=Arial color=#0000ff
size=2> private static final CmsObject
MY_STORED_CMSOBJECT;</FONT></SPAN></DIV>
<DIV><SPAN class=394241207-05112006><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=394241207-05112006><FONT face=Arial color=#0000ff size=2>But
beware: although several people have said this works for them, it's an
undocumented approach. It feels unsatisfactory because we're not told that
CmsObject is threadsafe, and by using a shared reference possibly to service
more than one request at the same time we're assuming that it is. If that
worries you, synchronise on your module class.</FONT></SPAN></DIV>
<DIV><SPAN class=394241207-05112006><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=394241207-05112006><FONT face=Arial color=#0000ff
size=2>Jon</FONT></SPAN></DIV>
<DIV><BR></DIV>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> Andy Bicksbo
[mailto:schlachtzeuger@gmail.com] <BR><B>Sent:</B> 04 November 2006
21:31<BR><B>To:</B> jonathan.woods@scintillance.com<BR><B>Subject:</B> Re:
[opencms-dev] Switching the user of cmsObject/Safety<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV>Hi</DIV>
<DIV>I think this would be a good soluation. But do you know how i can store the
object to use later. Does this (the initialize method of the I_CmsModuleAction)
work for ScheduledJobs as well?</DIV>
<DIV>Thanks</DIV>
<DIV>Andy<BR><BR> </DIV>
<DIV><SPAN class=gmail_quote>2006/10/19, Jonathan Woods <<A
href="mailto:jonathan.woods@scintillance.com">jonathan.woods@scintillance.com</A>>:</SPAN>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff size=2>If your
module registers a class implementing I_CmsModuleAction in
opencms-modules.xml, then that class will get instantiated and called on
module initialisation time ( e.g. at system start-up). Various methods
defined in the interface include as a parameter an instance of CmsObject, and
I believe the OpenCms runtime calls these methods (at start-up) using a
CmsObject which has administrative rights. In your module's
implementation of I_CmsModuleAction, you can store a reference to this
CmsObject to be used later. It doesn't feel like a neat solution, but I
believe people have used it successfully. </FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff size=2>There's
been discussion on this subject on this list in the past year - you might be
able to find something else by searching e.g. at <A
onclick="return top.js.OpenExtLink(window,event,this)"
href="http://www.nabble.com/OpenCMS---Dev-f654.html"
target=_blank>http://www.nabble.com/OpenCMS---Dev-f654.html</A>.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2>Jon</FONT></SPAN></DIV><BR>
<DIV lang=en-us dir=ltr align=left>
<HR>
<FONT face=Tahoma size=2><B>From:</B> <A
onclick="return top.js.OpenExtLink(window,event,this)"
href="mailto:opencms-dev-bounces@opencms.org"
target=_blank>opencms-dev-bounces@opencms.org</A> [mailto:<A
onclick="return top.js.OpenExtLink(window,event,this)"
href="mailto:opencms-dev-bounces@opencms.org" target=_blank>
opencms-dev-bounces@opencms.org</A>] <B>On Behalf Of </B>Andy
Bicksbo<BR><B>Sent:</B> 19 October 2006 13:57<BR><B>To:</B> The OpenCms
mailing list<BR><B>Subject:</B> [opencms-dev] Switching the user of
cmsObject/Safety<BR></FONT><BR> </DIV>
<DIV><SPAN class=e id=q_10e60cb425abbafe_1>
<DIV></DIV>
<DIV>Hi</DIV>
<DIV> </DIV>
<DIV>I worked on this the last days and i didn't find a possibility the get a
readble password out of an user. The Password is decoded into md5, i
think, and as far as i k´know, there isn't any possibility the retrieve a
md5 into human readable coding and there's nothing, where opencms retrieves a
password. I'm working currently on a component for opencms, where i need to
build a cmsobject with a user with admin rights, but i don't want to write a
user with it'S password into sourcecode( cmsObject.loginuser(String username,
String password)) nor to change the permissions of every file i have to alter
before doing stuff with it and afterwards. (The user, who should initiate this
component has no adminrights, so i have to switch the user of cmsObject)
</DIV>
<DIV> </DIV>
<DIV>At topic:<BR>But you can directly alter passwords in the db opencms
uses(CMS_USER)</DIV>
<DIV>At this point, i think it#s not very save, that the db connection stuff
is written readable in the opencms.properties file</DIV>
<DIV> </DIV>
<DIV>Does anybody know a solution?<BR> </DIV>
<DIV>Thanks for
listening<BR>Andy</DIV></SPAN></DIV></DIV><BR><BR>_______________________________________________<BR>This
mail is sent to you from the opencms-dev mailing list<BR>To change your list
options, or to unsubscribe from the list, please visit <BR><A
onclick="return top.js.OpenExtLink(window,event,this)"
href="http://lists.opencms.org/mailman/listinfo/opencms-dev"
target=_blank>http://lists.opencms.org/mailman/listinfo/opencms-dev</A><BR><BR></BLOCKQUOTE></DIV><BR></BODY></HTML>