MyProxy myproxy = new MyProxy(myproxyHostname, myproxyPortNumber);
int lifeHours = myproxyLifeTime * SECS_PER_HOUR;
GSSCredential proxy = myproxy.get(myproxyUserName, myproxyPassword,
lifeHours);
GlobusCredential globusCred = null;
if (proxy instanceof GlobusGSSCredentialImpl) {
globusCred = ((GlobusGSSCredentialImpl) proxy)
.getGlobusCredential();
System.out.println("got proxy from myproxy for "
+ myproxyUserName + " with " + myproxyLifeTime
+ " lifetime.");
String uid = myproxyUserName;
if (proxyloc == null) {
System.out.println("uid: " + uid);
proxyloc = "/tmp/x509up_u" + uid;
}
File proxyfile = new File(proxyloc);
System.out.println("proxy location: " + proxyfile.getAbsolutePath());
if (proxyfile.exists() == false) {
String dirpath = proxyloc.substring(0, proxyloc
.lastIndexOf('/'));
File dir = new File(dirpath);
if (dir.exists() == false) {
dir.mkdirs();
System.out.println("new directory " + dirpath
+ " is created.");
}
proxyfile.createNewFile();
System.out.println("new proxy file " + proxyloc
+ " is created.");
}
FileOutputStream fout = new FileOutputStream(proxyfile);
globusCred.save(fout);
fout.close();
String osName = System.getProperty("os.name");
if (!osName.contains("Windows")) {
Runtime.getRuntime().exec("/bin/chmod 600 " + proxyloc);
}