MyProxy myproxy = new MyProxy( hostname, port );
GSSCredential proxy =
myproxy.get(username, password, lifetime);
GlobusCredential globusCred = null;
if(proxy instanceof GlobusGSSCredentialImpl) {
globusCred =
((GlobusGSSCredentialImpl)proxy).getGlobusCredential();
log.info("got proxy from myproxy for " + username
+ " with " + lifetime + " lifetime.");
// InputStream is = Runtime.getRuntime().exec( "/bin/env").getInputStream();
// BufferedReader in
// = new BufferedReader(new InputStreamReader(is));
// String str;
// while((str = in.readLine()) != null) {
// if(str.startsWith("X509_USER_PROXY=")) {
// proxyloc = str.substring("X509_USER_PROXY=".length());
// }
// }
// // proxyloc = XpolaUtil.getSysEnv("X509_USER_PROXY");
// log.info("proxy location0: " + proxyloc);
if(proxyloc == null) {
String uid = XpolaUtil.getSysUserid();
log.info("uid: " + uid);
proxyloc = "/tmp/x509up_u" + uid;
}
log.info("proxy location: " + proxyloc);
File proxyfile = new File(proxyloc);
if(proxyfile.exists() == false) {
String dirpath = proxyloc.substring(0, proxyloc.lastIndexOf('/'));
File dir = new File(dirpath);
if(dir.exists() == false) {
dir.mkdirs();
log.info("new directory " + dirpath + " is created.");
}
proxyfile.createNewFile();
log.info("new proxy file " + proxyloc + " is created.");
}
FileOutputStream fout = new FileOutputStream(proxyfile);
globusCred.save(fout);
fout.close();
Runtime.getRuntime().exec( "/bin/chmod 600 " + proxyloc );
log.info("proxy file renewed");
System.out.println("Proxy file renewed to "+ proxyloc + " for the user "+ username