aslcore/src/org/gcube/application/framework/core/util/UserCredential.java

43 lines
1.3 KiB
Java

package org.gcube.application.framework.core.util;
import java.io.File;
import org.gcube.vomanagement.vomsAdmin.impl.VOMSAdminImpl;
import org.gcube.vomanagement.vomsClient.impl.CredentialsManagerImpl;
import org.gridforum.jgss.ExtendedGSSCredential;
/**
* @author Valia Tsagkalidou (NKUA)
*
*/
public class UserCredential {
/**
* Retrieves credential for users
* @param username the user name for which it will retrieve credential
* @param DLname DLname
* @return the GSS Credential
*/
public static ExtendedGSSCredential getCredential(String username, String DLname)
{
CredentialsManagerImpl man = null;
try {
String sharedDir = Settings.getInstance().getProperty("sharedDir");
System.out.println("file " + sharedDir + "/vomsAPI.properties exists: "+ new File(sharedDir + "/vomsAPI.properties").exists());
man = new CredentialsManagerImpl(sharedDir + "/vomsAPI.properties");
// VOMSAdminImpl vomsAdm = new VOMSAdminImpl(sharedDir + "/vomsAPI.properties");
// man = new CredentialsManagerImpl(vomsAdm);
} catch (Exception e1) {
e1.printStackTrace();
}
ExtendedGSSCredential cred = null;
try {
//TODO: put a real password there...
cred = man.getCredentials(username, "", DLname);
} catch (Exception e) {
e.printStackTrace();
}
return cred;
}
}