@Override public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException { if (checkClientTrustedIntern(x509Certificates)) return; try { trustManager.checkClientTrusted(x509Certificates, s); } catch (CertificateException cex) { tlstmCounters.fireIncrementCounter(new CounterEvent(this, SnmpConstants.snmpTlstmSessionOpenErrors)); tlstmCounters.fireIncrementCounter(new CounterEvent(this, SnmpConstants.snmpTlstmSessionInvalidClientCertificates)); logger.warn("Client certificate validation failed for '"+x509Certificates[0]+"'"); throw cex; } }
private void updateStatusInfo(int securityLevel, StatusInformation statusInfo, CounterEvent event) { if (statusInfo != null) { statusInfo.setSecurityLevel(new Integer32(securityLevel)); statusInfo.setErrorIndication(new VariableBinding(event.getOid(), event.getCurrentValue())); } }
public void incrementCounter(CounterEvent event) { if ((event.getOid().startsWith(usmStatsPrefix)) && (event.getOid().size() > usmStatsPrefix.size())) { Counter32 current = (Counter32) usmStats[event.getOid().get(usmStatsPrefix.size())-1].getValue(); current.increment(); event.setCurrentValue((Counter32)current.clone()); } }
public synchronized void incrementCounter(CounterEvent event) { OID id = event.getOid(); Counter32 counter = counters.get(id); if (counter == null) { if (countRegisteredOnly) { return; } counter = new Counter32(event.getIncrement()); counters.put(id, counter); } else { counter.increment(event.getIncrement()); } // write back current value event.setCurrentValue((Variable) counter.clone()); }
public void responseReceived() { this.responseReceived = true; if (waitTime != null) { CounterSupport counterSupport = getCounterSupport(); if (counterSupport != null) { long increment = (System.nanoTime()-waitTime.getIncrement())/SnmpConstants.MILLISECOND_TO_NANOSECOND; waitTime.setIncrement(increment); counterSupport.fireIncrementCounter(waitTime); if (waitTimeTarget != null) { waitTimeTarget.setIncrement(increment); counterSupport.fireIncrementCounter(waitTimeTarget); } } } }
private void sendUnknownPDUHandlersReport(CommandResponderEvent command) { logger.info("No PDU handler found for request "+command); CounterEvent counter = new CounterEvent(this, SnmpConstants.snmpUnknownPDUHandlers); fireIncrementCounter(counter); if ((command.getMessageProcessingModel() == MessageProcessingModel.MPv3) && (command.getPDU() instanceof ScopedPDU)) { ScopedPDU request = (ScopedPDU) command.getPDU(); ScopedPDU report = new ScopedPDU(); report.setContextEngineID(request.getContextEngineID()); report.setContextName(request.getContextName()); report.setType(PDU.REPORT); report.add(new VariableBinding(counter.getOid(), counter.getCurrentValue())); sendResponse(command, report); } else { PDU resp = (PDU) command.getPDU().clone(); resp.setErrorStatus(PDU.genErr); sendResponse(command, resp); } }
public void run() { if (forwarder.forward(request)) { PDU response = request.getResponsePDU(); if (response != null) { sendResponse(request.getCommandEvent(), response); } } else if (request.getProxyType() != ProxyForwarder.PROXY_TYPE_NOTIFY) { // proxy drop CounterEvent cevent = new CounterEvent(this, SnmpConstants.snmpProxyDrops); fireIncrementCounter(cevent); CommandResponderEvent cre = request.getCommandEvent(); if ((cre.getMessageProcessingModel() == MPv3.ID) && (cre.getStateReference() != null)) { ScopedPDU reportPDU = new ScopedPDU(); reportPDU.setType(PDU.REPORT); reportPDU.setContextEngineID(request.getContextEngineID()); reportPDU.setContextName(request.getContext()); reportPDU.add(new VariableBinding(SnmpConstants.snmpProxyDrops, cevent.getCurrentValue())); sendResponse(request.getCommandEvent(), reportPDU); } } }
responseTimeEvent = new CounterEvent(this, SnmpConstants.snmp4jStatsResponseProcessTime, incomingAddress, System.nanoTime()); long increment = (System.nanoTime()-responseTimeEvent.getIncrement())/SnmpConstants.MILLISECOND_TO_NANOSECOND; responseTimeEvent.setIncrement(increment); fireIncrementCounter(responseTimeEvent);
private void sendUnknownPDUHandlersReport(CommandResponderEvent command) { logger.info("No PDU handler found for request " + command); CounterEvent counter = new CounterEvent(this, SnmpConstants.snmpUnknownPDUHandlers); fireIncrementCounter(counter); if ((command.getMessageProcessingModel() == MessageProcessingModel.MPv3) && (command.getPDU() instanceof ScopedPDU)) { ScopedPDU request = (ScopedPDU) command.getPDU(); ScopedPDU report = new ScopedPDU(); report.setContextEngineID(request.getContextEngineID()); report.setContextName(request.getContextName()); report.setType(PDU.REPORT); report.add(new VariableBinding(counter.getOid(), counter.getCurrentValue())); sendResponse(command, report); } else { PDU resp = (PDU) command.getPDU().clone(); resp.setErrorStatus(PDU.genErr); sendResponse(command, resp); } }
public synchronized void incrementCounter(CounterEvent event) { OID id = event.getOid(); Counter32 counter = counters.get(id); if (counter == null) { if (countRegisteredOnly) { return; } counter = new Counter32(event.getIncrement()); counters.put(id, counter); } else { counter.increment(event.getIncrement()); } // write back current value event.setCurrentValue((Variable) counter.clone()); }
public void run() { if (forwarder.forward(request)) { PDU response = request.getResponsePDU(); if (response != null) { sendResponse(request.getCommandEvent(), response); } } else if (request.getProxyType() != ProxyForwarder.PROXY_TYPE_NOTIFY) { // proxy drop CounterEvent cevent = new CounterEvent(this, SnmpConstants.snmpProxyDrops); fireIncrementCounter(cevent); CommandResponderEvent cre = request.getCommandEvent(); if ((cre.getMessageProcessingModel() == MPv3.ID) && (cre.getStateReference() != null)) { ScopedPDU reportPDU = new ScopedPDU(); reportPDU.setType(PDU.REPORT); reportPDU.setContextEngineID(request.getContextEngineID()); reportPDU.setContextName(request.getContext()); reportPDU.add(new VariableBinding(SnmpConstants.snmpProxyDrops, cevent.getCurrentValue())); sendResponse(request.getCommandEvent(), reportPDU); } } }
responseTimeEvent = new CounterEvent(this, SnmpConstants.snmp4jStatsResponseProcessTime, incomingAddress, System.nanoTime()); long increment = (System.nanoTime() - responseTimeEvent.getIncrement()) / SnmpConstants.MILLISECOND_TO_NANOSECOND; responseTimeEvent.setIncrement(increment); fireIncrementCounter(responseTimeEvent);
public void responseReceived() { this.responseReceived = true; if (waitTime != null) { CounterSupport counterSupport = getCounterSupport(); if (counterSupport != null) { long increment = (System.nanoTime() - waitTime.getIncrement()) / SnmpConstants.MILLISECOND_TO_NANOSECOND; waitTime.setIncrement(increment); counterSupport.fireIncrementCounter(waitTime); if (waitTimeTarget != null) { waitTimeTarget.setIncrement(increment); counterSupport.fireIncrementCounter(waitTimeTarget); } } } }
CounterEvent event = new CounterEvent(this, SnmpConstants. usmStatsUnknownEngineIDs); fireIncrementCounter(event); statusInfo.setSecurityLevel(new Integer32(securityLevel)); statusInfo.setErrorIndication(new VariableBinding(event.getOid(), event.getCurrentValue())); CounterEvent event = new CounterEvent(this, SnmpConstants.usmStatsUnknownUserNames); fireIncrementCounter(event); statusInfo.setSecurityLevel(new Integer32(SecurityLevel.NOAUTH_NOPRIV)); statusInfo.setErrorIndication(new VariableBinding(event.getOid(), event.getCurrentValue())); new CounterEvent(this, SnmpConstants.usmStatsUnknownUserNames); fireIncrementCounter(event); if (statusInfo != null) { statusInfo.setSecurityLevel(new Integer32(SecurityLevel.NOAUTH_NOPRIV)); statusInfo.setErrorIndication(new VariableBinding(event.getOid(), event.getCurrentValue())); new CounterEvent(this, SnmpConstants.usmStatsUnsupportedSecLevels); fireIncrementCounter(event); statusInfo.setSecurityLevel(new Integer32(SecurityLevel.NOAUTH_NOPRIV)); statusInfo.setErrorIndication(new VariableBinding(event.getOid(), event.getCurrentValue())); return SnmpConstants.SNMPv3_USM_UNSUPPORTED_SECURITY_LEVEL;
protected SshSession openSession(SshAddress address, TransportStateReference tmStateReference, int maxMessageSize) { // RFC 5592 §5.3: // 1. Increment snmpSshtmSessionOpens counter. fireIncrementCounter(new CounterEvent(this, SnmpConstants.snmpSshtmSessionOpens)); // 2. return transportAdapter.openClientSession(tmStateReference, maxMessageSize); }
public void incrementCounter(CounterEvent event) { if ((event.getOid().startsWith(usmStatsPrefix)) && (event.getOid().size() > usmStatsPrefix.size())) { Counter32 current = (Counter32) usmStats[event.getOid().get(usmStatsPrefix.size())-1].getValue(); current.increment(); event.setCurrentValue((Counter32)current.clone()); } }
private void updateStatusInfo(int securityLevel, StatusInformation statusInfo, CounterEvent event) { if (statusInfo != null) { statusInfo.setSecurityLevel(new Integer32(securityLevel)); statusInfo.setErrorIndication(new VariableBinding(event.getOid(), event.getCurrentValue())); } }
CounterEvent event = new CounterEvent(this, SnmpConstants. usmStatsUnknownEngineIDs); fireIncrementCounter(event); statusInfo.setSecurityLevel(new Integer32(securityLevel)); statusInfo.setErrorIndication(new VariableBinding(event.getOid(), event.getCurrentValue())); CounterEvent event = new CounterEvent(this, SnmpConstants.usmStatsUnknownUserNames); fireIncrementCounter(event); statusInfo.setSecurityLevel(new Integer32(SecurityLevel.NOAUTH_NOPRIV)); statusInfo.setErrorIndication(new VariableBinding(event.getOid(), event.getCurrentValue())); new CounterEvent(this, SnmpConstants.usmStatsUnknownUserNames); fireIncrementCounter(event); if (statusInfo != null) { statusInfo.setErrorIndication(new VariableBinding(event.getOid(), event.getCurrentValue())); new CounterEvent(this, SnmpConstants.usmStatsUnsupportedSecLevels); fireIncrementCounter(event); if (SNMP4JSettings.getReportSecurityLevelStrategy() == statusInfo.setErrorIndication(new VariableBinding(event.getOid(), event.getCurrentValue())); return SnmpConstants.SNMPv3_USM_UNSUPPORTED_SECURITY_LEVEL;
@Override public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException { if (preCheckServerTrusted(x509Certificates)) return; try { trustManager.checkServerTrusted(x509Certificates, s); } catch (CertificateException cex) { tlstmCounters.fireIncrementCounter(new CounterEvent(this, SnmpConstants.snmpTlstmSessionOpenErrors)); tlstmCounters.fireIncrementCounter(new CounterEvent(this, SnmpConstants.snmpTlstmSessionUnknownServerCertificate)); logger.warn("Server certificate validation failed for '"+x509Certificates[0]+"'"); throw cex; } postCheckServerTrusted(x509Certificates); }
public void incrementCounter(CounterEvent event) { Counter32 current = null; if (oidSnmpUnknownSecurityModels.equals(event.getOid())) { current = snmpUnknownSecurityModels.getValue(); } else if (oidSnmpUnknownPDUHandlers.equals(event.getOid())) { current = snmpUnknownPDUHandlers.getValue(); } else if (oidSnmpInvalidMsgs.equals(event.getOid())) { current = snmpInvalidMsgs.getValue(); } if (current != null) { current.increment(); event.setCurrentValue((Counter32) current.clone()); } } //--AgentGen END