Creating a Key with an ACL Template
Creating a key with an ACL Template
Sample_User_Operations.java
The following code sample illustrates how to create a key with an ACL based on an ACL Template and return the T-Tag (hidden link).
import com.eruces.teagent.TEAgentConnection;
import com.eruces.teagent.TEKey;
public class Sample_User_Operations {
public static String createKey(TEAgentConnection conn, String temp_name) {
String ttag = null;
try {
TEKey admin_key = new TEKey();
admin_key.attachConnection(conn);
ttag = admin_key.createKey(temp_name);
admin_key.detachConnection();
System.out.println("Key created with template \"" + temp_name + "\" and T-Tag \"" + ttag + "\".");
}
catch (Exception e) {
e.printStackTrace();
}
return ttag;
}
}
//
//private TEAgentConnection m_conn;
//
//
//public void connect_native(String strServerName, int nPort, String strUsername, String strPasswd) throws TEAgentException
//{
// // Get a SSL connection instance
// m_conn = TEAgentConnectionFactory.getInstance(TEAgentConnectionFactory.SECURE_USER_PASSWORD);
//
// // Make connection
// m_conn.open(strServerName, nPort, strUsername, strPasswd);
//
// System.out.println("Connected to " + strServerName + " at " + nPort + " as " + strUsername);
//}
//
//public void connect_native_admin(String strServerName, int nPort, String strUsername, String strPasswd) throws TEAgentException
//{
// m_conn = TEAgentConnectionFactory.getInstance(TEAgentConnectionFactory.SECURE_USER_PASSWORD);
//
// // Connect to server.
// m_conn.open(strServerName, nPort, strUsername, strPasswd);
// System.out.println("Connected to " + strServerName + " at " + nPort + " as " + strUsername);
//}
//
//
//public void connect_cert(String strServerName, int nPort, String strCertFile, String strPasswd) throws Exception
//{
// try {
// // Get a connection for native user
// TEAgentSSLMConnection sslmConn = new TEAgentSSLMConnection();
//
// // Read pfx file
// InputStream pfx = new FileInputStream(strCertFile);
//
// // Make connection
// sslmConn.open(strServerName, nPort, pfx, strPasswd);
// m_conn = sslmConn;
//
// System.out.println("Connected to " + strServerName + " at " + nPort + " as certificate user.");
// }
// catch(FileNotFoundException fnfex) {
// throw new Exception(fnfex.getMessage());
// }
//}
//
//public void disconnect() throws TEAgentException
//{
// // Close connection
// m_conn.close();
// System.out.println("Disconnected from server ");
//}
//
//
//public void testCreateKey() throws TEAgentException, Exception {
//
// System.out.println();
// System.out.println("Create key:");
// TEKey teKey = new TEKey();
// connect_native("sampleserver", 8888, "ls", "password");
// //connect_cert("sampleserver", 8888, "C:\\Documents and Settings\\Administrator\\pkcs12_private_key.pfx", "password");
// teKey.attachConnection(m_conn);
// String strACLTemplateName = "";
// String strTT = teKey.createKey(strACLTemplateName);
// teKey.detachConnection();
// disconnect();
//
// System.out.println("Key was created, strTT = " + strTT);
//}