use of org.netxms.client.users.AuthCertificate in project netxms by netxms.
the class NXCSession method getCertificateList.
/**
* Get list of certificates
*
* @return List of certificates
* @throws IOException if socket I/O error occurs
* @throws NXCException if NetXMS server returns an error or operation was timed out
*/
public List<AuthCertificate> getCertificateList() throws IOException, NXCException {
final NXCPMessage msg = newMessage(NXCPCodes.CMD_GET_CERT_LIST);
sendMessage(msg);
final NXCPMessage response = waitForRCC(msg.getMessageId());
int count = response.getFieldAsInt32(NXCPCodes.VID_NUM_CERTIFICATES);
final List<AuthCertificate> list = new ArrayList<AuthCertificate>(count);
long varId = NXCPCodes.VID_CERT_LIST_BASE;
for (int i = 0; i < count; i++) {
list.add(new AuthCertificate(response, varId));
varId += 10;
}
return list;
}
use of org.netxms.client.users.AuthCertificate in project netxms by netxms.
the class CertificateView method deleteCertificate.
/**
* Delete selected certificate
*/
private void deleteCertificate() {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.isEmpty())
return;
if (!MessageDialogHelper.openConfirm(getSite().getShell(), Messages.get().CertificateView_Confirmation, Messages.get().CertificateView_AckDeleteCertif))
return;
final Object[] objects = selection.toArray();
new ConsoleJob(Messages.get().CertificateView_DeleteCertif, this, Activator.PLUGIN_ID, Activator.PLUGIN_ID) {
@Override
protected String getErrorMessage() {
return Messages.get().CertificateView_ErrorDeleteCert;
}
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
for (int i = 0; i < objects.length; i++) {
session.deleteCertificate(((AuthCertificate) objects[i]).getId());
}
}
}.start();
}
use of org.netxms.client.users.AuthCertificate in project netxms by netxms.
the class CertificateView method createActions.
/**
* Create actions
*/
private void createActions() {
actionRefresh = new RefreshAction(this) {
@Override
public void run() {
refreshCertificateList();
}
};
actionNew = new Action(Messages.get().CertificateView_CreateNewCertif) {
@Override
public void run() {
createCertificate();
}
};
actionNew.setImageDescriptor(SharedIcons.ADD_OBJECT);
actionEdit = new Action(Messages.get().CertificateView_EditCertifData) {
@Override
public void run() {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.size() != 1)
return;
final long certId = ((AuthCertificate) selection.getFirstElement()).getId();
AuthCertificate cert = certificates.get(certId);
if ((cert != null)) {
saveCertificate(cert);
}
}
};
actionEdit.setImageDescriptor(SharedIcons.EDIT);
actionDelete = new Action(Messages.get().CertificateView_DeleteCertif) {
@Override
public void run() {
deleteCertificate();
}
};
actionDelete.setImageDescriptor(SharedIcons.DELETE_OBJECT);
}
use of org.netxms.client.users.AuthCertificate in project netxms by netxms.
the class CertificateView method refreshCertificateList.
/**
* Refresh certificate list
*/
private void refreshCertificateList() {
final Display display = viewer.getControl().getDisplay();
new ConsoleJob(Messages.get(display).CertificateView_RefreshCertif, this, Activator.PLUGIN_ID, null, display) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final List<AuthCertificate> cl = session.getCertificateList();
runInUIThread(new Runnable() {
@Override
public void run() {
certificates.clear();
for (AuthCertificate c : cl) {
certificates.put(c.getId(), c);
}
viewer.setInput(certificates.values().toArray());
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().CertificateView_ErrorUnableGetCertifList;
}
}.start();
}
Aggregations