Java_Connect_Cert.java
needed for doxygen linking
/*****************************************************************************************
*
* Java_Connect_Cert.java
*
******************************************************************************************/
import com.eruces.teagent.TEAgentSSLMConnection;
import com.eruces.teagent.TEAgentException;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.FileNotFoundException;
public class Java_Connect_Cert {
private String m_strServerName;
private int m_nPort;
private String m_strCertFile;
private String m_strPasswd;
private TEAgentSSLMConnection m_conn;
public void connect(String strServerName, int nPort, String strCertFile, String strPasswd) throws TEAgentException, FileNotFoundException
{
m_strServerName = strServerName;
m_nPort = nPort;
m_strCertFile = strCertFile;
m_strPasswd = strPasswd;
// Get a connection for native user
m_conn = new TEAgentSSLMConnection();
// Read pfx file
InputStream pfx = new FileInputStream(m_strCertFile);
// Make connection
m_conn.open(m_strServerName, m_nPort, pfx, m_strPasswd);
System.out.println("Connected to " + m_strServerName + " at " + m_nPort + " as certificate user.");
}
public void disconnect() throws TEAgentException
{
// Close connection
m_conn.close();
System.out.println("Disconnected from " + m_strServerName);
}
public static void main(String[] args)
{
try
{
Java_Connect_Cert java_connect = new Java_Connect_Cert();
// Need admin port of the Key Server. Provide a PKCS#12 private key file.
java_connect.connect("sampleserver", 8888, "CertP12.pfx", "password1A");
java_connect.disconnect();
}
catch (TEAgentException te)
{
te.printStackTrace();
}
catch (FileNotFoundException fnfe)
{
fnfe.printStackTrace();
}
}
}