init();
String proxyLocation = null;
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.debug("got proxy from myproxy for " + username + " with " + lifetime + " lifetime.");
String uid = username;
// uid = XpolaUtil.getSysUserid();
log.debug("uid: " + uid);
proxyLocation = "/tmp/x509up_u" + uid + UUID.randomUUID().toString();
log.debug("proxy location: " + proxyLocation);
File proxyfile = new File(proxyLocation);
if (!proxyfile.exists()) {
String dirpath = proxyLocation.substring(0, proxyLocation.lastIndexOf('/'));
File dir = new File(dirpath);
if (!dir.exists()) {
if (dir.mkdirs()) {
log.debug("new directory " + dirpath + " is created.");
} else {
log.error("error in creating directory " + dirpath);
}
}
if (!proxyfile.createNewFile()) {
log.error("Unable to create proxy file. File - " + proxyfile.getAbsolutePath());
} else {
log.debug("new proxy file " + proxyLocation + " is created. File - " + proxyfile.getAbsolutePath());
}
}
FileOutputStream fout = null;
try {
fout = new FileOutputStream(proxyfile);
globusCred.save(fout);
} finally {
if (fout != null) {
fout.close();
}
}