import com.eruces.teagent.TEAgentConnection;
import com.eruces.teagent.TEAgentException;
import com.eruces.teagent.TEAgentConnectionFactory;
import com.eruces.teadmin.Administration;
import com.eruces.teadmin.AdminException;
import com.eruces.teadmin.UserAndPasswordInfo;
public class Java_Admin_Principal_AclTemplate_remove {
private String m_strServerName;
private int m_nPort;
private String m_strUsername;
private String m_strPasswd;
private TEAgentConnection m_conn;
public void test_removeACLTemplate() throws TEAgentException, AdminException {
Administration admin = new Administration();
admin.attachConnection(m_conn);
UserAndPasswordInfo testUser = (UserAndPasswordInfo) admin.getUserByName("testuser");
System.out.println(testUser.toString());
System.out.println("AclTemplateId = " + testUser.getAclTemplateId() );
if (testUser.getAclTemplateId() == 0) {
System.out.println("No AclTemplate was assigned to this principal." );
return;
}
testUser.removeAclTemplate();
admin.updatePrincipal(testUser);
System.out.println(testUser.toString());
System.out.println("AclTemplateId = " + testUser.getAclTemplateId() );
admin.detachConnection();
}
public void connect(String strServerName, int nPort, String strUsername, String strPasswd) throws TEAgentException {
m_strServerName = strServerName;
m_nPort = nPort;
m_strUsername = strUsername;
m_strPasswd = strPasswd;
m_conn = TEAgentConnectionFactory.getInstance(TEAgentConnectionFactory.SECURE_USER_PASSWORD);
m_conn.open(m_strServerName, m_nPort, m_strUsername, m_strPasswd);
System.out.println("Connected to " + m_strServerName + " at " + m_nPort + " as " + m_strUsername);
}
public void disconnect() throws TEAgentException {
m_conn.close();
System.out.println("Disconnected from " + m_strServerName);
}
public static void main(String[] args) {
try {
Java_Admin_Principal_AclTemplate_remove test = new Java_Admin_Principal_AclTemplate_remove();
test.connect("sampleserver", 8888, "admin", "password1A");
test.test_removeACLTemplate();
test.disconnect();
}
catch (TEAgentException te) {
System.out.println("TEAgentException encountered: ");
te.printStackTrace();
}
catch (AdminException adminex) {
System.out.println("AdminException encountered: ");
adminex.printStackTrace();
}
catch (Exception ex) {
System.out.println("Exception encountered: ");
ex.printStackTrace();
}
}
}