Search in sources :

Example 1 with AuthCertificate

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;
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage) ArrayList(java.util.ArrayList) AuthCertificate(org.netxms.client.users.AuthCertificate) ConnectionPoint(org.netxms.client.topology.ConnectionPoint) AccessPoint(org.netxms.client.objects.AccessPoint)

Example 2 with AuthCertificate

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();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) AuthCertificate(org.netxms.client.users.AuthCertificate) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Example 3 with AuthCertificate

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);
}
Also used : Action(org.eclipse.jface.action.Action) RefreshAction(org.netxms.ui.eclipse.actions.RefreshAction) RefreshAction(org.netxms.ui.eclipse.actions.RefreshAction) AuthCertificate(org.netxms.client.users.AuthCertificate) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 4 with AuthCertificate

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();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) AuthCertificate(org.netxms.client.users.AuthCertificate) List(java.util.List) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) Display(org.eclipse.swt.widgets.Display)

Aggregations

AuthCertificate (org.netxms.client.users.AuthCertificate)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Action (org.eclipse.jface.action.Action)1 Display (org.eclipse.swt.widgets.Display)1 NXCPMessage (org.netxms.base.NXCPMessage)1 AccessPoint (org.netxms.client.objects.AccessPoint)1 ConnectionPoint (org.netxms.client.topology.ConnectionPoint)1 RefreshAction (org.netxms.ui.eclipse.actions.RefreshAction)1