@@ -0,0 +1,1361 @@
+package edu.usc.glidein.util;%0A%0Aimport java.io.File;%0Aimport java.io.FileInputStream;%0Aimport java.io.FileOutputStream;%0Aimport java.io.IOException;%0A%0Aimport org.globus.gsi.GlobusCredential;%0Aimport org.globus.gsi.GlobusCredentialException;%0A%0Apublic class CredentialUtil%0A%7B%0A%09public static void save(GlobusCredential credential, File file) %0A%09throws IOException%0A%09%7B%0A%09%09// Create the file if it doesn't exist%0A%09%09file.createNewFile();%0A%09%09%0A%09%09// Change file permissions%0A%09%09CommandLine chmod = new CommandLine();%0A%09%09chmod.setExecutable(new File(%22/bin/chmod%22));%0A%09%09chmod.addArgument(%22600%22);%0A%09%09chmod.addArgument(file.getAbsolutePath());%0A%09%09chmod.execute();%0A%09%09int exitCode = chmod.getExitCode();%0A%09%09if(exitCode != 0)%7B%0A%09%09%09throw new IOException(%0A%09%09%09%09%09%22Unable to change proxy permissions%5Cn%5Cn%22+%0A%09%09%09%09%09%22Stdout:%5Cn%22+chmod.getOutput()+%0A%09%09%09%09%09%22Stderr:%5Cn%22+chmod.getError());%0A%09%09%7D%0A%09%09%0A%09%09// Save the credential to the file%0A%09%09FileOutputStream pstream = %0A%09%09%09new FileOutputStream(file);%0A%09%09credential.save(pstream);%0A%09%09pstream.close();%0A%09%7D%0A%09%0A%09public static GlobusCredential load(File file) %0A%09throws IOException%0A%09%7B%0A%09%09try %7B%0A%09%09%09FileInputStream fis = new FileInputStream(file);%0A%09%09%09GlobusCredential cred = new GlobusCredential(fis);%0A%09%09%09fis.close();%0A%09%09%09return cred;%0A%09%09%7D catch (GlobusCredentialException gce) %7B%0A%09%09%09IOException ioe = new IOException(%22Invalid credential%22);%0A%09%09%09ioe.initCause(gce);%0A%09%09%09throw ioe;%0A%09%09%7D%0A%09%7D%0A%7D%0A

Add credential util to store and load GlobusCredentials from files. Automatically changes permissions of file.