*/
package org.opendaylight.openflowplugin.applications.topology.lldp.utils;
-import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.hash.HashCode;
import com.google.common.hash.HashFunction;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
-import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
-import java.util.Objects;
+import java.util.Optional;
import org.apache.commons.lang3.ArrayUtils;
import org.opendaylight.mdsal.eos.binding.api.Entity;
import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService;
import org.opendaylight.mdsal.eos.common.api.EntityOwnershipState;
import org.opendaylight.openflowplugin.applications.topology.lldp.LLDPActivator;
-import org.opendaylight.openflowplugin.libraries.liblldp.BufferException;
import org.opendaylight.openflowplugin.libraries.liblldp.Ethernet;
import org.opendaylight.openflowplugin.libraries.liblldp.LLDP;
import org.opendaylight.openflowplugin.libraries.liblldp.LLDPTLV;
try {
ethPkt.deserialize(payload, 0, payload.length * NetUtils.NUM_BITS_IN_A_BYTE);
} catch (PacketException e) {
- LOG.warn("Failed to decode LLDP packet {}", e);
+ LOG.warn("Failed to decode LLDP packet", e);
return nodeConnectorRef;
}
* @param nodeConnectorId the NodeConnectorId
* @return extra authenticator for lldp security
*/
- public static byte[] getValueForLLDPPacketIntegrityEnsuring(final NodeConnectorId nodeConnectorId)
- throws NoSuchAlgorithmException {
+ public static byte[] getValueForLLDPPacketIntegrityEnsuring(final NodeConnectorId nodeConnectorId) {
String finalKey;
if (LLDPActivator.getLldpSecureKey() != null && !LLDPActivator.getLldpSecureKey().isEmpty()) {
finalKey = LLDPActivator.getLldpSecureKey();
return hashedValue.asBytes();
}
- private static boolean checkExtraAuthenticator(LLDP lldp, NodeConnectorId srcNodeConnectorId)
- throws NoSuchAlgorithmException, BufferException {
+ private static boolean checkExtraAuthenticator(LLDP lldp, NodeConnectorId srcNodeConnectorId) {
final LLDPTLV hashLldptlv = lldp.getCustomTLV(LLDPTLV.createSecSubTypeCustomTLVKey());
boolean secAuthenticatorOk = false;
if (hashLldptlv != null) {
}
private static boolean isLLDP(final byte[] packet) {
- if (Objects.isNull(packet) || packet.length < MINIMUM_LLDP_SIZE) {
+ if (packet == null || packet.length < MINIMUM_LLDP_SIZE) {
return false;
}
Preconditions.checkNotNull(eos, "Entity ownership service must not be null");
EntityOwnershipState state = null;
- java.util.Optional<EntityOwnershipState> status = getCurrentOwnershipStatus(eos, nodeId);
+ Optional<EntityOwnershipState> status = getCurrentOwnershipStatus(eos, nodeId);
if (status.isPresent()) {
state = status.get();
} else {
return state != null && state.equals(EntityOwnershipState.IS_OWNER);
}
- private static java.util.Optional<EntityOwnershipState> getCurrentOwnershipStatus(final EntityOwnershipService eos,
+ private static Optional<EntityOwnershipState> getCurrentOwnershipStatus(final EntityOwnershipService eos,
final String nodeId) {
Entity entity = createNodeEntity(nodeId);
Optional<EntityOwnershipState> ownershipStatus = eos.getOwnershipState(entity);
if (ownershipStatus.isPresent()) {
LOG.debug("Fetched ownership status for node {} is {}", nodeId, ownershipStatus.get());
- return java.util.Optional.of(ownershipStatus.get());
}
- return java.util.Optional.empty();
+ return ownershipStatus;
}
private static Entity createNodeEntity(final String nodeId) {