Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: AW: [geclipse-dev] Token creation


Stuempert, Mathias IWR a écrit :
Hi Romain,
Hi Mathias,
In principle it is very simple to create a token with g-Eclipse:

IAuthenticationTokenDescription desc = new VomsProxyDescription();
AuthTokenRequest request = new AuthTokenRequest( desc, "This is me", "I need a VOMS proxy" );
IAuthenticationToken token = AbstractAuthTokenProvider.staticRequestToken( request );

Assuming you are not in headless mode and the UI is available this will open the token wizard in VOMS mode asking the user to specify a certificate, key and passphrase. You could also encode default VO, certificate and key in your VomsProxyDescription:

IAuthenticationTokenDescription desc = new VomsProxyDescription(
  new IVirtualOrganization[] { myvo },
  mycert,
  mykey
);

If you would like to directly create a VOMS proxy without UI interaction (i.e. you already know your VO, certificate and key) you should do something like this:

VomsProxyDescription desc = VomsProxyDescription(
  new IVirtualOrganization[] { myvo },
  mycert,
  mykey
);
AuthenticationTokenManager manager = AuthenticationTokenManager.getManager();
VomsProxy proxy = ( VomsProxy ) manager.createToken( desc );

If you create the token with the manager it will cache this token for you and manage the tokens lifecycle. The token can afterwards be retrieved with

VomsProxy proxy = ( VomsProxy ) manager.findToken( desc );

If you do not need the token management capabilities of g-Eclipse you could simply do something like:

VomsProxyDescription desc = VomsProxyDescription(
  new IVirtualOrganization[] { myvo },
  mycert,
  mykey
);
VomsProxy proxy = ( VomsProxy ) desc.createToken();

Depending on the method you are chosing you may have to validate and to activate your token after the creation:

if ( ! proxy.isValid() ) {
  proxy.validate( null );
}
if ( ! proxy.isActive() ) {
  proxy.setActive( true, null );
}

You can find a lot of useful code examples in the following classes:

eu.geclipse.core.auth.CoreAuthTokenProvider
eu.geclipse.ui.UIAuthTokenProvider

Hope that helps,
That helps a lot, but I get an exception during the token validation. I think it requires geclipse UI bundle.

Is there another way to deal with it?


The code:

           VomsProxyDescription desc = new VomsProxyDescription(
                   new IVirtualOrganization[] { biomed },
                   new File("/home/reuillon/.globus/usercert.pem"),
                   new File("/home/reuillon/.globus/userkey.pem")
           );

AuthTokenRequest request = new AuthTokenRequest( desc, "This is me", "I need a VOMS proxy" ); IAuthenticationToken token = AbstractAuthTokenProvider.staticRequestToken( request );


// AuthenticationTokenManager authManager = AuthenticationTokenManager.getManager();
           VomsProxy proxy = ( VomsProxy ) desc.createToken(  );


           if ( ! proxy.isValid() ) {
               proxy.validate( null );
           }
           if ( ! proxy.isActive() ) {
               proxy.setActive( true, null );
           }



The exception:

!SESSION 2008-05-14 15:08:24.121 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.6.0_06
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=fr_FR
Framework arguments: -product SimExplorer_OSGI_Application.product file:/home/reuillon/jobTest.xml Command-line arguments: -product SimExplorer_OSGI_Application.product -data /home/reuillon/workspace/../runtime-SimExplorer_OSGI_Application.product -dev file:/home/reuillon/workspace/.metadata/.plugins/org.eclipse.pde.core/SimExplorer_OSGI_Application.product/dev.properties -os linux -ws gtk -arch x86 file:/home/reuillon/jobTest.xml

!ENTRY eu.geclipse.core 4 0 2008-05-14 15:08:48.214
!MESSAGE Plug-in "eu.geclipse.ui" was unable to instantiate class "eu.geclipse.ui.UIAuthTokenProvider".
!STACK 1
org.eclipse.core.runtime.CoreException: Plug-in "eu.geclipse.ui" was unable to instantiate class "eu.geclipse.ui.UIAuthTokenProvider". at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.throwException(RegistryStrategyOSGI.java:180) at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:172) at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:788) at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243) at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:51) at eu.geclipse.core.auth.AbstractAuthTokenProvider.getHighestPriorityProvider(AbstractAuthTokenProvider.java:99) at eu.geclipse.core.auth.AbstractAuthTokenProvider.staticRequestToken(AbstractAuthTokenProvider.java:64) at fr.cemagref.simexplorer.ide.osgi.processors.JobLauncherProcessor.process(JobLauncherProcessor.java:454) at fr.cemagref.simexplorer.ide.core.processors.modular.ProcessorsList.process(ProcessorsList.java:54) at fr.cemagref.simexplorer.ide.core.IDEModularApplication.run(IDEModularApplication.java:41) at fr.cemagref.simexplorer.service.loader.EFSSimulationLoaderImpl.run(EFSSimulationLoaderImpl.java:26) at fr.cemagref.simexplorer.service.application.SimExplorer.start(SimExplorer.java:49) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:169) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:508)
   at org.eclipse.equinox.launcher.Main.basicRun(Main.java:447)
   at org.eclipse.equinox.launcher.Main.run(Main.java:1173)
   at org.eclipse.equinox.launcher.Main.main(Main.java:1148)
org.eclipse.core.runtime.CoreException[1]: java.lang.IllegalStateException: Workbench has not been created yet.
   at org.eclipse.ui.PlatformUI.getWorkbench(PlatformUI.java:92)
at eu.geclipse.ui.UIAuthTokenProvider.<init>(UIAuthTokenProvider.java:193) at eu.geclipse.ui.UIAuthTokenProvider.<init>(UIAuthTokenProvider.java:184)
   at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
   at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
   at java.lang.Class.newInstance0(Class.java:355)
   at java.lang.Class.newInstance(Class.java:308)
at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:170) at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:788) at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243) at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:51) at eu.geclipse.core.auth.AbstractAuthTokenProvider.getHighestPriorityProvider(AbstractAuthTokenProvider.java:99) at eu.geclipse.core.auth.AbstractAuthTokenProvider.staticRequestToken(AbstractAuthTokenProvider.java:64) at fr.cemagref.simexplorer.ide.osgi.processors.JobLauncherProcessor.process(JobLauncherProcessor.java:454) at fr.cemagref.simexplorer.ide.core.processors.modular.ProcessorsList.process(ProcessorsList.java:54) at fr.cemagref.simexplorer.ide.core.IDEModularApplication.run(IDEModularApplication.java:41) at fr.cemagref.simexplorer.service.loader.EFSSimulationLoaderImpl.run(EFSSimulationLoaderImpl.java:26) at fr.cemagref.simexplorer.service.application.SimExplorer.start(SimExplorer.java:49) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:169) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:508)
   at org.eclipse.equinox.launcher.Main.basicRun(Main.java:447)
   at org.eclipse.equinox.launcher.Main.run(Main.java:1173)
   at org.eclipse.equinox.launcher.Main.main(Main.java:1148)
!SUBENTRY 1 org.eclipse.equinox.registry 4 1 2008-05-14 15:08:48.215
!MESSAGE Plug-in "eu.geclipse.ui" was unable to instantiate class "eu.geclipse.ui.UIAuthTokenProvider".
!STACK 0
java.lang.IllegalStateException: Workbench has not been created yet.
   at org.eclipse.ui.PlatformUI.getWorkbench(PlatformUI.java:92)
at eu.geclipse.ui.UIAuthTokenProvider.<init>(UIAuthTokenProvider.java:193) at eu.geclipse.ui.UIAuthTokenProvider.<init>(UIAuthTokenProvider.java:184)
   at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
   at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
   at java.lang.Class.newInstance0(Class.java:355)
   at java.lang.Class.newInstance(Class.java:308)
at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:170) at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:788) at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243) at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:51) at eu.geclipse.core.auth.AbstractAuthTokenProvider.getHighestPriorityProvider(AbstractAuthTokenProvider.java:99) at eu.geclipse.core.auth.AbstractAuthTokenProvider.staticRequestToken(AbstractAuthTokenProvider.java:64) at fr.cemagref.simexplorer.ide.osgi.processors.JobLauncherProcessor.process(JobLauncherProcessor.java:454) at fr.cemagref.simexplorer.ide.core.processors.modular.ProcessorsList.process(ProcessorsList.java:54) at fr.cemagref.simexplorer.ide.core.IDEModularApplication.run(IDEModularApplication.java:41) at fr.cemagref.simexplorer.service.loader.EFSSimulationLoaderImpl.run(EFSSimulationLoaderImpl.java:26) at fr.cemagref.simexplorer.service.application.SimExplorer.start(SimExplorer.java:49) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:169) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:508)
   at org.eclipse.equinox.launcher.Main.basicRun(Main.java:447)
   at org.eclipse.equinox.launcher.Main.run(Main.java:1173)
   at org.eclipse.equinox.launcher.Main.main(Main.java:1148)

!ENTRY org.eclipse.osgi 4 0 2008-05-14 15:08:48.226
!MESSAGE Application error
!STACK 1
java.lang.NullPointerException
   at eu.geclipse.globus.auth.GlobusProxy.validate(GlobusProxy.java:236)
at fr.cemagref.simexplorer.ide.osgi.processors.JobLauncherProcessor.process(JobLauncherProcessor.java:462) at fr.cemagref.simexplorer.ide.core.processors.modular.ProcessorsList.process(ProcessorsList.java:54) at fr.cemagref.simexplorer.ide.core.IDEModularApplication.run(IDEModularApplication.java:41) at fr.cemagref.simexplorer.service.loader.EFSSimulationLoaderImpl.run(EFSSimulationLoaderImpl.java:26) at fr.cemagref.simexplorer.service.application.SimExplorer.start(SimExplorer.java:49) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:169) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:508)
   at org.eclipse.equinox.launcher.Main.basicRun(Main.java:447)
   at org.eclipse.equinox.launcher.Main.run(Main.java:1173)
   at org.eclipse.equinox.launcher.Main.main(Main.java:1148)


Rom.


Mathias

Dr. Mathias Stümpert
Project Coordinator
g-Eclipse Project (IST-034327)
Karlsruhe Institute of Technology (KIT)
Steinbuch Centre for Computing (SCC)
Hermann-von-Helmholtz-Platz 1
76344 Eggenstein-Leopoldshafen
Phone: +49 7247 828610
Fax: +49 7247 824972
Email: mathias.stuempert@xxxxxxxxxx

-----Ursprüngliche Nachricht-----
Von: geclipse-dev-bounces@xxxxxxxxxxx [mailto:geclipse-dev-bounces@xxxxxxxxxxx] Im Auftrag von reuillon
Gesendet: Mittwoch, 14. Mai 2008 10:54
An: Developer mailing list
Betreff: [geclipse-dev] Token creation

Hi all,

I'd like to write a code creating a token from a voms certificate using geclipse classes. I think I should use the AuthenticationTokenManager but I cannot get through with it. May you point at me source codes that will help me?

Thanks,
Rom
_______________________________________________
geclipse-dev mailing list
geclipse-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/geclipse-dev
_______________________________________________
geclipse-dev mailing list
geclipse-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/geclipse-dev




Back to the top