Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » How To Get Example SecurePreferencesFactory to work
How To Get Example SecurePreferencesFactory to work [message #127505] Thu, 12 March 2009 21:14 Go to next message
Andy is currently offline AndyFriend
Messages: 47
Registered: July 2009
Member
Hi,

I tried running the following code which will eventually get put into a
plugin.

ISecurePreferences root = SecurePreferencesFactory.getDefault();
ISecurePreferences node = root.node("cvs/eclipse.org");
node.put("password", myPassword, true);


But when I run it I just get a stack trace that appears as follows:

Exception in thread "main" java.lang.NullPointerException




at
org.eclipse.equinox.internal.security.storage.SecurePreferen cesMapper.open(SecurePreferencesMapper.java:67)

at
org.eclipse.equinox.internal.security.storage.SecurePreferen cesMapper.getDefault(SecurePreferencesMapper.java:44)

at
org.eclipse.equinox.security.storage.SecurePreferencesFactor y.getDefault(SecurePreferencesFactory.java:50)

at
com.nuwavetech.vfs.security.PreferencesManager.main(Preferen cesManager.java:13)




I tried looking into if anyone else had this issue or for a more complete
example and came across this:

http://dev.eclipse.org/mhonarc/lists/equinox-dev/msg05026.ht ml

but that didn't seem to answer the question, at least when it came to
pointing out an actual working example. Any ideas? Thanks,

Andy
Re: How To Get Example SecurePreferencesFactory to work [message #127548 is a reply to message #127505] Fri, 13 March 2009 15:27 Go to previous messageGo to next message
Andy is currently offline AndyFriend
Messages: 47
Registered: July 2009
Member
I thought I would post this followup. No matter what I do I get this Null
pointer error. The javadoc says that the
SecurePreferencesFactory.getDefault() will return null if the application
was unable to create the secure preferences. The problem is that there is
a .keyring file located in the default location in eclipse and I also
tried using the -keyring and -password command line arguments when
starting eclipse. It did create a new .keyring file in the new location I
specified on the command line so it wouldn't appear to me that the method
call is failing because it can't find the keyring file.

Any idea why the null pointer? Thanks in advance.

Andy
Re: How To Get Example SecurePreferencesFactory to work [message #127574 is a reply to message #127505] Fri, 13 March 2009 21:10 Go to previous messageGo to next message
Oleg Besedin is currently offline Oleg BesedinFriend
Messages: 41
Registered: July 2009
Member
Hi Andy,
That is an odd place to get an NPE. From the code, the only way to get that
would be to remove "Lazy Activation" flag from the
"org.eclipse.equinox.security" bundle or to set launch configuration to
disable its lazy activation.

If you have this bundle checked out in your workspace, check that its
manifest.mf file has "Bundle-ActivationPolicy: lazy". If you modified launch
configuration from the default, it is worth checking that too.

If problem persist, be sure to open a bug against Equinox/Security with a
sample of your code and launch configuration that reproduces the problem.

Sincerely,
Oleg Besedin


"Andy " <andrewnbenjamin@hotmail.com> wrote in message
news:bc3066e55b372d3a379f4308b853f289$1@www.eclipse.org...
> Hi,
>
> I tried running the following code which will eventually get put into a
> plugin.
> ISecurePreferences root = SecurePreferencesFactory.getDefault();
> ISecurePreferences node = root.node("cvs/eclipse.org");
> node.put("password", myPassword, true);
>
>
> But when I run it I just get a stack trace that appears as follows:
>
> Exception in thread "main" java.lang.NullPointerException
>
>
>
> at
> org.eclipse.equinox.internal.security.storage.SecurePreferen cesMapper.open(SecurePreferencesMapper.java:67)
>
> at
> org.eclipse.equinox.internal.security.storage.SecurePreferen cesMapper.getDefault(SecurePreferencesMapper.java:44)
>
> at
> org.eclipse.equinox.security.storage.SecurePreferencesFactor y.getDefault(SecurePreferencesFactory.java:50)
>
> at
> com.nuwavetech.vfs.security.PreferencesManager.main(Preferen cesManager.java:13)
>
>
>
>
> I tried looking into if anyone else had this issue or for a more complete
> example and came across this:
>
> http://dev.eclipse.org/mhonarc/lists/equinox-dev/msg05026.ht ml
>
> but that didn't seem to answer the question, at least when it came to
> pointing out an actual working example. Any ideas? Thanks,
>
> Andy
>
Re: How To Get Example SecurePreferencesFactory to work [message #127625 is a reply to message #127574] Mon, 16 March 2009 15:41 Go to previous messageGo to next message
Andy is currently offline AndyFriend
Messages: 47
Registered: July 2009
Member
Oleg,

I can't seem to find that particular mf file. I am trying to develop this
against the RCP version of Eclipse, specifically Version: 3.4.1
Build id: M20080911-1700.

I tried searching through the base install and couldn't find any reference
to "lazy" in an MF file. I also tried downloading the Eclipse source
eclipse-sourceBuild-srcIncluded-3.4.2.zip and the subclipse-source_1.4.2
(to see how the passwords were stored in that app) but couldn't find any
references to ISecurePreferences in either of those zip files to see a
working example of the preferences being modified. I could find the
files but nothing in the references to them as in something actually
storing a username and password.

Is there some other dependency that I am missing? Everything compiles fine
since I imported the jar files with the classes that it complained about
before. Is there a working standalone example of storing a password in a
repository and then pulling it back out of the repository? Also, I
haven't changed any of my run configurations so I have no idea how to
disable lazy activation.

Thanks,

Andy
Re: How To Get Example SecurePreferencesFactory to work [message #127637 is a reply to message #127625] Mon, 16 March 2009 19:34 Go to previous messageGo to next message
Oleg Besedin is currently offline Oleg BesedinFriend
Messages: 41
Registered: July 2009
Member
Hi Andy,
I replied in the bug you opened:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=268842

Sincerely,
Oleg Besedin

"Andy " <andrewnbenjamin@hotmail.com> wrote in message
news:3f89d5ca449abe24a23b715edb0a0b80$1@www.eclipse.org...
> Oleg,
>
> I can't seem to find that particular mf file. I am trying to develop this
> against the RCP version of Eclipse, specifically Version: 3.4.1
> Build id: M20080911-1700.
> I tried searching through the base install and couldn't find any reference
> to "lazy" in an MF file. I also tried downloading the Eclipse source
> eclipse-sourceBuild-srcIncluded-3.4.2.zip and the subclipse-source_1.4.2
> (to see how the passwords were stored in that app) but couldn't find any
> references to ISecurePreferences in either of those zip files to see a
> working example of the preferences being modified. I could find the
> files but nothing in the references to them as in something actually
> storing a username and password.
>
> Is there some other dependency that I am missing? Everything compiles fine
> since I imported the jar files with the classes that it complained about
> before. Is there a working standalone example of storing a password in a
> repository and then pulling it back out of the repository? Also, I
> haven't changed any of my run configurations so I have no idea how to
> disable lazy activation.
>
> Thanks,
>
> Andy
>
>
>
>
Re: How To Get Example SecurePreferencesFactory to work [message #127650 is a reply to message #127637] Tue, 17 March 2009 16:07 Go to previous messageGo to next message
Andy is currently offline AndyFriend
Messages: 47
Registered: July 2009
Member
Thanks for those comments on the bug. I moved the code into the plugin I
was working on and managed to get it to work - once. Then I encountered
an odd error.

I added the following to the plugin under the "dependencies" tab /
Imported Packages:

org.eclipse.equinox.security.auth;version="1.0.0",
org.eclipse.equinox.security.auth.credentials;version="1.0.0 ",
org.eclipse.equinox.security.auth.module;version="1.0.0",
org.eclipse.equinox.security.storage;version="1.0.0",
org.eclipse.equinox.security.storage.provider;version="1.0.0 "

and then ran the plugin. The plugin worked and I was able to put a
password in the secure repository and also pull the password back out of
the node.

The odd part is that now there is a red x on the top folder for my project
in the Package Explorer window but no red x on a lower folder like you
normally have when there is a nested error. Also, I can find no reason
for the error. When I make any changes now the changes are not picked up
and I keep getting the message about how I have errors in my project when
I try and run the plugin.

I went and pulled the equinox security packages out of my plugin and the
red x disappeared (and so did the functionality of using the password
repository). So anyway, it appears that there is something in those
packages that is working once, and then failing for some odd reason. Do
you have any idea why that might be happening? Thanks again,

Andy
Re: How To Get Example SecurePreferencesFactory to work [message #127694 is a reply to message #127650] Wed, 18 March 2009 17:18 Go to previous message
Andy is currently offline AndyFriend
Messages: 47
Registered: July 2009
Member
I thought I would post the solution to the problem I ran into above. The
issue above has to do with importing the jar files twice. Make sure that
the jar files are only referenced from within the Dependencies\Imported
Packages in the plugin.xml and not also referenced from if you right mouse
on the project root and select Java build path and add the jars again
under the libraries path. The plug-in dependencies node should already
have the jar file available for you in the project.
Previous Topic:Log4j and OSGI
Next Topic:org.eclipse.test with dependency on org.eclipse.ui
Goto Forum:
  


Current Time: Thu Apr 25 06:50:42 GMT 2024

Powered by FUDForum. Page generated in 0.03787 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top