Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[geclipse-dev] Create a voms token from a file

Hi all,

I am back from vocation, it was nice..... But back to work!

As a continuation of the bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=235371 which has been solved. I'd like to be able to use srm:// URL on distant computing elements
to access file through EFS and srm protocol.

In order to do that I must be able to initialize a voms token from a file pointed by the X509_USER_PROXY environment variable on the computing elements. Here is the actual code to initialize a globus proxy:

public void initAuthentication() throws InternalProcessingError {
       File caDir = new File("/etc/grid-security/certificates/");

if(caDir.exists()) loadCACertFromDir(caDir);
       else
           loadCECertFromWeb();

       IAuthenticationTokenDescription desc;

       if(System.getenv().containsKey("X509_USER_PROXY")) {
File proxyFile = new File(System.getenv().get("X509_USER_PROXY"));
           desc = new GlobusProxyDescription( proxyFile );
       } else    desc = genDescriptionFromPreferences();


       IAuthenticationToken proxy;
       try {
proxy = AuthenticationTokenManager.getManager().createToken( desc );

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

       } catch (AuthenticationException e) {
           throw new InternalProcessingError(e);
       }

       AuthenticationTokenManager.getManager().setDefaultToken(proxy);

   }

private IAuthenticationTokenDescription genDescriptionFromPreferences() throws InternalProcessingError {
       String certPath = Preferences.userRoot().get("CertificatePath", "");
       String keyPath = Preferences.userRoot().get("KeyPath", "");
       String keyPass = Preferences.userRoot().get("KeyPassword", "");
       String fqan = Preferences.userRoot().get("Fqan", "");



       VomsProxyDescription desc = new VomsProxyDescription (
               new IVirtualOrganization[] { getVo() },
               new File(certPath),
               new File(keyPath)

       );

/* FullyQualifiedAttributeName fq = FullyQualifiedAttributeName.getFqan((VomsVirtualOrganization)vo, new String[] {"lcg1"}, null);
       desc.addFqan(fq);*/

       //desc.addFqan(FullyQualifiedAttributeName.getFqan(fqan));

       FullyQualifiedAttributeName fq;
       try {
           fq = FullyQualifiedAttributeName.getFqan(fqan);
       } catch (ProblemException e) {
           throw new InternalProcessingError(e,fqan);
       }

       List< FullyQualifiedAttributeName > ordering = new ArrayList<
       FullyQualifiedAttributeName >();
       ordering.add( fq );
       desc.setOrdering( ordering );


       desc.setLifetime( 86400 ); // In second, so one day here

       PasswordManager.registerPassword(keyPath, keyPass);

       return desc;
   }


Do you think it might be possible to implement this functionality for the voms tokens?

Cheers,
Romain


Back to the top