use of org.netxms.client.snmp.SnmpUsmCredential in project netxms by netxms.
the class NXCSession method updateSnmpUsmCredentials.
/**
* Update list of well-known SNMP USM credentials on server. Existing list
* will be replaced by given one.
*
* @param map New map of SNMP USM credentials
* @throws IOException if socket I/O error occurs
* @throws NXCException if NetXMS server returns an error or operation was timed out
*/
public void updateSnmpUsmCredentials(final Map<Integer, List<SnmpUsmCredential>> map) throws IOException, NXCException {
final NXCPMessage msg = newMessage(NXCPCodes.CMD_UPDATE_USM_CREDENTIALS);
long varId = NXCPCodes.VID_USM_CRED_LIST_BASE;
int count = 0, i;
for (List<SnmpUsmCredential> l : map.values()) {
if (l.isEmpty())
continue;
for (i = 0; i < l.size(); i++, varId += 10) {
l.get(i).fillMessage(msg, varId);
}
count += i;
}
msg.setFieldInt32(NXCPCodes.VID_NUM_RECORDS, count);
sendMessage(msg);
waitForRCC(msg.getMessageId());
}
use of org.netxms.client.snmp.SnmpUsmCredential in project netxms by netxms.
the class AddUsmCredDialog method okPressed.
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#okPressed()
*/
@Override
protected void okPressed() {
value = new SnmpUsmCredential();
value.setName(name.getText().trim());
value.setAuthMethod(authMethod.getSelectionIndex());
value.setPrivMethod(privMethod.getSelectionIndex());
value.setAuthPassword(authPasswd.getText());
value.setPrivPassword(privPasswd.getText());
super.okPressed();
}
use of org.netxms.client.snmp.SnmpUsmCredential in project netxms by netxms.
the class SnmpCredentials method removeUsmCredentials.
/**
* Remove selected SNMP USM credentials
*/
private void removeUsmCredentials() {
final List<SnmpUsmCredential> list = config.getUsmCredentials(zoneUIN);
IStructuredSelection selection = (IStructuredSelection) snmpUsmCredList.getSelection();
if (selection.size() > 0) {
for (Object o : selection.toList()) {
list.remove(o);
}
snmpUsmCredList.setInput(list.toArray());
setModified();
}
}
use of org.netxms.client.snmp.SnmpUsmCredential in project netxms by netxms.
the class SnmpUsmComparator method compare.
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
SnmpUsmCredential c1 = (SnmpUsmCredential) e1;
SnmpUsmCredential c2 = (SnmpUsmCredential) e2;
int result = c1.getName().compareToIgnoreCase(c2.getName());
if (result == 0) {
result = c1.getAuthMethod() - c2.getAuthMethod();
if (result == 0) {
result = c1.getPrivMethod() - c2.getPrivMethod();
}
}
return result;
}
use of org.netxms.client.snmp.SnmpUsmCredential in project netxms by netxms.
the class NXCSession method getSnmpUsmCredentials.
/**
* Get list of well-known SNMP USM (user security model) credentials
* configured on server.
*
* @return Map of SNMP USM credentials
* @throws IOException if socket I/O error occurs
* @throws NXCException if NetXMS server returns an error or operation was timed out
*/
public Map<Integer, List<SnmpUsmCredential>> getSnmpUsmCredentials() throws IOException, NXCException {
final NXCPMessage msg = newMessage(NXCPCodes.CMD_GET_USM_CREDENTIALS);
sendMessage(msg);
final NXCPMessage response = waitForRCC(msg.getMessageId());
int count = response.getFieldAsInt32(NXCPCodes.VID_NUM_RECORDS);
Map<Integer, List<SnmpUsmCredential>> map = new HashMap<Integer, List<SnmpUsmCredential>>(count);
List<SnmpUsmCredential> credentials = new ArrayList<SnmpUsmCredential>();
long varId = NXCPCodes.VID_USM_CRED_LIST_BASE;
SnmpUsmCredential cred;
int zoneId = 0;
for (int i = 0; i < count; i++, varId += 10) {
cred = new SnmpUsmCredential(response, varId);
if (i != 0 && zoneId != cred.getZoneId()) {
map.put(zoneId, credentials);
credentials = new ArrayList<SnmpUsmCredential>();
}
credentials.add(cred);
zoneId = cred.getZoneId();
}
if (count > 0)
map.put(zoneId, credentials);
return map;
}
Aggregations