<feature version="${restconf.version}">odl-restconf</feature>
<feature version="${mdsal.version}">odl-mdsal-broker</feature>
<feature version='${project.version}'>odl-lispflowmapping-models</feature>
+ <feature version="${project.version}">odl-lispflowmapping-inmemorydb</feature>
<bundle>mvn:org.opendaylight.lispflowmapping/mappingservice.mapcache/{{VERSION}}</bundle>
<bundle>mvn:org.opendaylight.lispflowmapping/mappingservice.southbound/{{VERSION}}</bundle>
<configfile finalname="${configfile.directory}/lfm-mappingservice-sb.xml">
mapRegisterWithMapNotifyAndMapRequest();
registerAndQuery__MAC();
mapRequestMapRegisterAndMapRequest();
- //TODO uncomment followign test once authentication check will be moved to LispSouthboundHandler
-// mapRegisterWithAuthenticationWithoutConfiguringAKey();
+ mapRegisterWithAuthenticationWithoutConfiguringAKey();
mapRegisterWithoutMapNotify();
}
*/
public interface IGenericMapServer {
- /**
- * @return Should the Map Server use authentication.
- */
- boolean shouldAuthenticate();
-
- /**
- * Configure Map server to use authentication
- *
- * @param shouldAuthenticate
- * Set authentication
- */
- void setShouldAuthenticate(boolean shouldAuthenticate);
-
/**
* Configure Map Server to notify mapping subscribers on mapping updates
*
*/
package org.opendaylight.lispflowmapping.interfaces.lisp;
+import java.nio.ByteBuffer;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister;
public interface ILispAuthentication {
- boolean validate(MapRegister mapRegister, String key);
+
+ boolean validate(ByteBuffer mapRegisterBuffer, byte[] expectedAuthData, String key);
byte[] getAuthenticationData(MapNotify mapNotify, String key);
IMapNotifyHandler, OdlLispProtoListener, AutoCloseable {
protected static final Logger LOG = LoggerFactory.getLogger(LispMappingService.class);
- private volatile boolean shouldAuthenticate = true;
-
private volatile boolean smr = ConfigIni.getInstance().smrIsSet();
private volatile String elpPolicy = ConfigIni.getInstance().getElpPolicy();
broker.registerProvider(this);
notificationService.registerNotificationListener(this);
mapResolver = new MapResolver(mapService, smr, elpPolicy, this);
- mapServer = new MapServer(mapService, shouldAuthenticate, smr, this, notificationService);
+ mapServer = new MapServer(mapService, smr, this, notificationService);
}
public void basicInit() {
mapResolver = new MapResolver(mapService, smr, elpPolicy, this);
- mapServer = new MapServer(mapService, shouldAuthenticate, smr, this, notificationService);
+ mapServer = new MapServer(mapService, smr, this, notificationService);
}
@Override
}
public void setShouldAuthenticate(boolean shouldAuthenticate) {
- this.shouldAuthenticate = shouldAuthenticate;
this.mapResolver.setShouldAuthenticate(shouldAuthenticate);
- this.mapServer.setShouldAuthenticate(shouldAuthenticate);
- }
-
- public boolean shouldAuthenticate() {
- return shouldAuthenticate;
}
private void sendMapNotify(MapNotify mapNotify, TransportAddress address) {
protected static final Logger LOG = LoggerFactory.getLogger(MapServer.class);
private IMappingService mapService;
- private boolean authenticate;
private boolean subscriptionService;
private IMapNotifyHandler notifyHandler;
private NotificationService notificationService;
- public MapServer(IMappingService mapService, boolean authenticate, boolean subscriptionService,
+ public MapServer(IMappingService mapService, boolean subscriptionService,
IMapNotifyHandler notifyHandler, NotificationService notificationService) {
Preconditions.checkNotNull(mapService);
this.mapService = mapService;
- this.authenticate = authenticate;
this.subscriptionService = subscriptionService;
this.notifyHandler = notifyHandler;
this.notificationService = notificationService;
this.subscriptionService = subscriptionService;
}
- @Override
- public boolean shouldAuthenticate() {
- return authenticate;
- }
-
- @Override
- public void setShouldAuthenticate(boolean shouldAuthenticate) {
- authenticate = shouldAuthenticate;
- }
-
@SuppressWarnings("unchecked")
public void handleMapRegister(MapRegister mapRegister) {
boolean authFailed = false;
lispMappingService.setShouldAuthenticate(value);
Mockito.verify(mapResolverMock).setShouldAuthenticate(value);
- Mockito.verify(mapServerMock).setShouldAuthenticate(value);
}
private static Pair<MapNotify, List<TransportAddress>> getDefaultMapNotifyPair() {
@Before
public void init() throws NoSuchFieldException, IllegalAccessException {
- mapServer = new MapServer(mapService, true, true, notifyHandler, notificationService);
+ mapServer = new MapServer(mapService, true, notifyHandler, notificationService);
subscriberSetMock_1.add(SUBSCRIBER_RLOC_1);
subscriberSetMock_1.add(SUBSCRIBER_RLOC_2);
subscriberSetMock_2.add(SUBSCRIBER_RLOC_3);
<groupId>${project.groupId}</groupId>
<artifactId>mappingservice.api</artifactId>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>mappingservice.inmemorydb</artifactId>
+ </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>mappingservice.lisp-proto</artifactId>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>mappingservice.mapcache</artifactId>
+ </dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&revision=2013-10-28</capability>
<capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl?module=opendaylight-sal-binding-broker-impl&revision=2013-10-28</capability>
<capability>urn:opendaylight:params:xml:ns:yang:controller:config:lisp-sb:impl?module=odl-lisp-sb-impl&revision=2015-05-17</capability>
+ <capability>urn:opendaylight:params:xml:ns:yang:controller:config:lfm:mappingservice-dao:inmemorydb?module=odl-mappingservice-dao-inmemorydb&revision=2015-10-07</capability>
</required-capabilities>
<configuration>
<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
</type>
<name>binding-notification-publish-adapter</name>
</notification-publish-service>
+
+ <data-broker>
+ <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-async-data-broker</type>
+ <name>pingpong-binding-data-broker</name>
+ </data-broker>
+
</module>
</modules>
sbPlugin = new LispSouthboundPlugin();
sbPlugin.setNotificationPublishService(getNotificationPublishServiceDependency());
sbPlugin.setRpcRegistryDependency(getRpcRegistryDependency());
+ sbPlugin.setDataBroker(getDataBrokerDependency());
sbPlugin.init();
return sbPlugin;
package org.opendaylight.lispflowmapping.southbound;
import static io.netty.buffer.Unpooled.wrappedBuffer;
+
+import com.google.common.base.Preconditions;
import io.netty.bootstrap.Bootstrap;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;
import io.netty.channel.socket.DatagramPacket;
import io.netty.channel.socket.nio.NioDatagramChannel;
import io.netty.util.concurrent.DefaultThreadFactory;
-
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.nio.ByteBuffer;
import java.util.concurrent.ThreadFactory;
-
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.base.Preconditions;
-
public class LispSouthboundPlugin implements IConfigLispSouthboundPlugin, AutoCloseable {
protected static final Logger LOG = LoggerFactory.getLogger(LispSouthboundPlugin.class);
private LispSouthboundStats statistics = new LispSouthboundStats();
private ThreadFactory threadFactory = new DefaultThreadFactory("lisp-sb");
private EventLoopGroup eventLoopGroup = new NioEventLoopGroup(0, threadFactory);
+ private DataBroker dataBroker;
public void init() {
synchronized (startLock) {
lispSouthboundHandler = new LispSouthboundHandler(this);
- lispXtrSouthboundHandler = new LispXtrSouthboundHandler();
+ lispSouthboundHandler.setDataBroker(dataBroker);
lispSouthboundHandler.setNotificationProvider(this.notificationPublishService);
+ lispSouthboundHandler.init();
+
+ lispXtrSouthboundHandler = new LispXtrSouthboundHandler();
lispXtrSouthboundHandler.setNotificationProvider(this.notificationPublishService);
start();
}
}
+ public void setDataBroker(final DataBroker dataBroker) {
+ this.dataBroker = dataBroker;
+ }
+
@Override
public void close() throws Exception {
unloadActions();
eventLoopGroup.shutdownGracefully();
sbRpcRegistration.close();
+ lispSouthboundHandler.close();
}
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.lispflowmapping.implementation.authentication;
+package org.opendaylight.lispflowmapping.southbound.authentication;
import java.util.HashMap;
import java.util.Map;
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.lispflowmapping.implementation.authentication;
+package org.opendaylight.lispflowmapping.southbound.authentication;
+import java.nio.ByteBuffer;
import org.opendaylight.lispflowmapping.interfaces.lisp.ILispAuthentication;
import org.opendaylight.lispflowmapping.lisp.util.LispAddressStringifier;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify;
private LispAuthenticationUtil() {
}
- public static boolean validate(MapRegister mapRegister, Eid eid, MappingAuthkey key) {
+ private static ILispAuthentication resolveAuthentication(final MapRegister mapRegister, final Eid eid, final
+ MappingAuthkey key) {
if (key == null) {
LOG.warn("Authentication failed: mapping authentication key is null");
- return false;
+ return null;
}
short keyId = 0;
if (mapRegister.getKeyId() != null) {
if (keyId != key.getKeyType().shortValue()) {
LOG.warn("Authentication failed: key-ID in Map-Register is different from the one on file for {}",
LispAddressStringifier.getString(eid));
- return false;
+ return null;
}
- ILispAuthentication authentication = LispAuthenticationFactory.getAuthentication(LispKeyIDEnum.valueOf(keyId));
- return authentication.validate(mapRegister, key.getKeyString());
+ return LispAuthenticationFactory.getAuthentication(LispKeyIDEnum.valueOf(keyId));
+ }
+
+
+ public static boolean validate(MapRegister mapRegister, ByteBuffer byteBuffer, Eid eid, MappingAuthkey key) {
+ final ILispAuthentication authentication = resolveAuthentication(mapRegister, eid, key);
+ return authentication == null ? false : authentication.validate(byteBuffer, mapRegister.getAuthenticationData(),
+ key.getKeyString());
}
public static byte[] createAuthenticationData(MapNotify mapNotify, String key) {
LispKeyIDEnum.valueOf(mapNotify.getKeyId()));
return authentication.getAuthenticationData(mapNotify, key);
}
-
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.lispflowmapping.implementation.authentication;
+package org.opendaylight.lispflowmapping.southbound.authentication;
public enum LispKeyIDEnum {
NONE(0, null), //
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.lispflowmapping.implementation.authentication;
+package org.opendaylight.lispflowmapping.southbound.authentication;
import java.nio.ByteBuffer;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
-
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
-
import org.opendaylight.lispflowmapping.interfaces.lisp.ILispAuthentication;
import org.opendaylight.lispflowmapping.lisp.serializer.MapNotifySerializer;
-import org.opendaylight.lispflowmapping.lisp.serializer.MapRegisterSerializer;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
}
}
- public boolean validate(MapRegister mapRegister, String key) {
+ @Override
+ public boolean validate(ByteBuffer mapRegisterBuffer, byte[] expectedAuthData, String key) {
if (key == null) {
LOG.warn("Authentication failed: mapping authentication password is null!");
return false;
}
- ByteBuffer mapRegisterBuffer = MapRegisterSerializer.getInstance().serialize(mapRegister);
if (mapRegisterBuffer == null) {
return true;
}
- mapRegisterBuffer.position(MAP_REGISTER_AND_NOTIFY_AUTHENTICATION_POSITION);
+ mapRegisterBuffer.position(ILispAuthentication.MAP_REGISTER_AND_NOTIFY_AUTHENTICATION_POSITION);
mapRegisterBuffer.put(tempAuthenticationData);
mapRegisterBuffer.position(0);
- return Arrays.equals(getAuthenticationData(mapRegisterBuffer.array(), key),
- mapRegister.getAuthenticationData());
+ return Arrays.equals(getAuthenticationData(mapRegisterBuffer.array(), key), expectedAuthData);
}
protected byte[] getAuthenticationData(byte[] data, String key) {
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.lispflowmapping.implementation.authentication;
+package org.opendaylight.lispflowmapping.southbound.authentication;
+import java.nio.ByteBuffer;
import org.opendaylight.lispflowmapping.interfaces.lisp.ILispAuthentication;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister;
public final class LispNoAuthentication implements ILispAuthentication {
return authenticationData;
}
- public boolean validate(MapRegister mapRegister, String key) {
+ @Override
+ public boolean validate(ByteBuffer mapRegisterBuffer, byte[] expectedAuthData, String key) {
return true;
}
--- /dev/null
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.lispflowmapping.southbound.lisp;
+
+import java.util.Collection;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
+import org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.lispflowmapping.mapcache.SimpleMapCache;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingDatabase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.mapping.database.VirtualNetworkIdentifier;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * DataListener for all AuthenticationKey modification events.
+ *
+ */
+public class AuthenticationKeyDataListener implements DataTreeChangeListener<AuthenticationKey> {
+ private static final Logger LOG = LoggerFactory.getLogger(AuthenticationKeyDataListener.class);
+
+ private final SimpleMapCache smc;
+ private final DataBroker broker;
+ private final InstanceIdentifier<AuthenticationKey> path;
+ private ListenerRegistration<DataTreeChangeListener<AuthenticationKey>> registration;
+
+
+ public AuthenticationKeyDataListener(final DataBroker broker, final SimpleMapCache smc) {
+ this.broker = broker;
+ this.smc = smc;
+ this.path = InstanceIdentifier.create(MappingDatabase.class).child(VirtualNetworkIdentifier.class)
+ .child(AuthenticationKey.class);
+ LOG.trace("Registering AuthenticationKey listener.");
+ final DataTreeIdentifier<AuthenticationKey> dataTreeIdentifier = new DataTreeIdentifier<>
+ (LogicalDatastoreType.CONFIGURATION, path);
+ registration = broker.registerDataTreeChangeListener(dataTreeIdentifier, this);
+ }
+
+ public void closeDataChangeListener() {
+ registration.close();
+ }
+
+ @Override
+ public void onDataTreeChanged(Collection<DataTreeModification<AuthenticationKey>> changes) {
+ for (DataTreeModification<AuthenticationKey> change : changes) {
+ final DataObjectModification<AuthenticationKey> mod = change.getRootNode();
+
+ if (ModificationType.DELETE == mod.getModificationType()) {
+ final AuthenticationKey authKey = mod.getDataBefore();
+
+ LOG.trace("Received deleted data");
+ LOG.trace("Key: {}", change.getRootPath().getRootIdentifier());
+ LOG.trace("Value: {}", authKey);
+
+ smc.removeAuthenticationKey(authKey.getEid());
+ } else if (ModificationType.WRITE == mod.getModificationType() || ModificationType.SUBTREE_MODIFIED == mod
+ .getModificationType()) {
+ if (ModificationType.WRITE == mod.getModificationType()) {
+ LOG.trace("Received created data");
+ } else {
+ LOG.trace("Received updated data");
+ }
+ // Process newly created or updated authentication keys
+ final AuthenticationKey authKey = mod.getDataAfter();
+
+ LOG.trace("Key: {}", change.getRootPath().getRootIdentifier());
+ LOG.trace("Value: {}", authKey);
+
+ smc.addAuthenticationKey(authKey.getEid(), authKey.getMappingAuthkey());
+ } else {
+ LOG.warn("Ignoring unhandled modification type {}", mod.getModificationType());
+ }
+ }
+ }
+
+}
package org.opendaylight.lispflowmapping.southbound.lisp;
+import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBufUtil;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
+import org.opendaylight.lispflowmapping.inmemorydb.HashMapDb;
+import org.opendaylight.lispflowmapping.southbound.authentication.LispAuthenticationUtil;
import org.opendaylight.lispflowmapping.lisp.serializer.MapNotifySerializer;
import org.opendaylight.lispflowmapping.lisp.serializer.MapRegisterSerializer;
import org.opendaylight.lispflowmapping.lisp.serializer.MapReplySerializer;
import org.opendaylight.lispflowmapping.lisp.util.ByteUtil;
import org.opendaylight.lispflowmapping.lisp.util.LispAddressStringifier;
import org.opendaylight.lispflowmapping.lisp.util.MapRequestUtil;
+import org.opendaylight.lispflowmapping.mapcache.SimpleMapCache;
import org.opendaylight.lispflowmapping.southbound.LispSouthboundPlugin;
import org.opendaylight.lispflowmapping.southbound.LispSouthboundStats;
import org.opendaylight.lispflowmapping.southbound.lisp.cache.MapRegisterCache;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.map.register.cache.metadata.container.map.register.cache.metadata.EidLispAddressBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.map.register.cache.value.grouping.MapRegisterCacheValue;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.map.register.cache.value.grouping.MapRegisterCacheValueBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddressBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.mapping.authkey.container.MappingAuthkey;
import org.opendaylight.yangtools.yang.binding.Notification;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ChannelHandler.Sharable
public class LispSouthboundHandler extends SimpleChannelInboundHandler<DatagramPacket>
- implements ILispSouthboundService {
- private final MapRegisterCache mapRegisterCache;
+ implements ILispSouthboundService, AutoCloseable {
+ private MapRegisterCache mapRegisterCache;
/**
* How long is record supposed to be relevant. After this time record isn't valid.
* If you modify this value, please update the LispSouthboundServiceTest class too.
*/
private static final long CACHE_RECORD_TIMEOUT = 90000;
+ private DataBroker dataBroker;
private NotificationPublishService notificationPublishService;
protected static final Logger LOG = LoggerFactory.getLogger(LispSouthboundHandler.class);
+ //TODO: think whether this field can be accessed through mappingservice or some other configuration parameter
+ private boolean authenticationEnabled = true;
+
private final LispSouthboundPlugin lispSbPlugin;
private LispSouthboundStats lispSbStats = null;
+ private SimpleMapCache smc;
+ private AuthenticationKeyDataListener authenticationKeyDataListener;
- public LispSouthboundHandler(LispSouthboundPlugin lispSbPlugin, final MapRegisterCache mapRegisterCache) {
+ public LispSouthboundHandler(LispSouthboundPlugin lispSbPlugin) {
this.lispSbPlugin = lispSbPlugin;
if (lispSbPlugin != null) {
this.lispSbStats = lispSbPlugin.getStats();
}
- this.mapRegisterCache = mapRegisterCache;
- }
-
- public LispSouthboundHandler(LispSouthboundPlugin lispSbPlugin) {
- this(lispSbPlugin, new MapRegisterCache());
- }
-
- public void setNotificationProvider(NotificationPublishService nps) {
- this.notificationPublishService = nps;
+ this.mapRegisterCache = new MapRegisterCache();
+ this.smc = new SimpleMapCache(new HashMapDb());
}
public void handlePacket(DatagramPacket msg) {
}
} else {
MapRegister mapRegister = MapRegisterSerializer.getInstance().deserialize(inBuffer, sourceAddress);
- AddMappingBuilder addMappingBuilder = new AddMappingBuilder();
- addMappingBuilder.setMapRegister(LispNotificationHelper.convertMapRegister(mapRegister));
- TransportAddressBuilder transportAddressBuilder = new TransportAddressBuilder();
- transportAddressBuilder.setIpAddress(LispNotificationHelper.getIpAddressBinaryFromInetAddress(
- sourceAddress));
- transportAddressBuilder.setPort(new PortNumber(port));
- addMappingBuilder.setTransportAddress(transportAddressBuilder.build());
- sendNotificationIfPossible(addMappingBuilder.build());
- if (artificialEntry != null) {
- final MapRegisterCacheMetadataBuilder cacheMetadataBldNew = new MapRegisterCacheMetadataBuilder();
- cacheMetadataBldNew.setEidLispAddress(provideEidPrefixesFromMessage(mapRegister));
- cacheMetadataBldNew.setXtrId(mapRegister.getXtrId());
- cacheMetadataBldNew.setSiteId(mapRegister.getSiteId());
- cacheMetadataBldNew.setWantMapNotify(mapRegister.isWantMapNotify());
- cacheMetadataBldNew.setMergeEnabled(mapRegister.isMergeEnabled());
- cacheMetadataBldNew.setTimestamp(System.currentTimeMillis());
-
- final MapRegisterCacheValueBuilder cacheValueBldNew = new MapRegisterCacheValueBuilder();
- cacheValueBldNew.setPacketData(artificialEntry.getValue());
- cacheValueBldNew.setMapRegisterCacheMetadata(cacheMetadataBldNew.build());
-
- mapRegisterCache.addEntry(cacheKey, cacheValueBldNew.build());
+ if (isAuthenticationSuccessful(mapRegister, inBuffer)) {
+ AddMappingBuilder addMappingBuilder = new AddMappingBuilder();
+ addMappingBuilder.setMapRegister(LispNotificationHelper.convertMapRegister(mapRegister));
+ TransportAddressBuilder transportAddressBuilder = new TransportAddressBuilder();
+ transportAddressBuilder.setIpAddress(LispNotificationHelper.getIpAddressBinaryFromInetAddress(
+ sourceAddress));
+ transportAddressBuilder.setPort(new PortNumber(port));
+ addMappingBuilder.setTransportAddress(transportAddressBuilder.build());
+ sendNotificationIfPossible(addMappingBuilder.build());
+ if (artificialEntry != null) {
+ final MapRegisterCacheMetadataBuilder cacheMetadataBldNew = new
+ MapRegisterCacheMetadataBuilder();
+ cacheMetadataBldNew.setEidLispAddress(provideEidPrefixesFromMessage(mapRegister));
+ cacheMetadataBldNew.setXtrId(mapRegister.getXtrId());
+ cacheMetadataBldNew.setSiteId(mapRegister.getSiteId());
+ cacheMetadataBldNew.setWantMapNotify(mapRegister.isWantMapNotify());
+ cacheMetadataBldNew.setMergeEnabled(mapRegister.isMergeEnabled());
+ cacheMetadataBldNew.setTimestamp(System.currentTimeMillis());
+
+ final MapRegisterCacheValueBuilder cacheValueBldNew = new MapRegisterCacheValueBuilder();
+ cacheValueBldNew.setPacketData(artificialEntry.getValue());
+ cacheValueBldNew.setMapRegisterCacheMetadata(cacheMetadataBldNew.build());
+
+ mapRegisterCache.addEntry(cacheKey, cacheValueBldNew.build());
+ }
}
}
} catch (RuntimeException re) {
return eidsResult;
}
+ /**
+ * Checks whether authentication data is valid.
+ *
+ * Methods pass through all records from map register message. For the EID of the first record it gets
+ * authentication key and does validation of authentication data again this authentication key. If it pass
+ * it just checks for remaining records (and its EID) whether they have the same authenticatin key stored in
+ * simple map cache (smc).
+ *
+ * @param mapRegister
+ * @param byteBuffer
+ * @return
+ */
+ private boolean isAuthenticationSuccessful(final MapRegister mapRegister, final ByteBuffer byteBuffer) {
+ if (!authenticationEnabled) {
+ return true;
+ }
+
+ if (smc == null) {
+ LOG.debug("Simple map cache wasn't instantieted and set.");
+ return false;
+ }
+
+ MappingAuthkey firstAuthKey = null;
+ final List<MappingRecordItem> mappingRecords = mapRegister.getMappingRecordItem();
+ for (int i = 0; i < mappingRecords.size(); i++) {
+ final MappingRecordItem recordItem = mappingRecords.get(i);
+ final MappingRecord mappingRecord = recordItem.getMappingRecord();
+ if (i == 0) {
+ firstAuthKey = smc.getAuthenticationKey(mappingRecord.getEid());
+ if (!LispAuthenticationUtil.validate(mapRegister, byteBuffer, mappingRecord.getEid(), firstAuthKey)) {
+ return false;
+ }
+ } else {
+ final Eid eid = mappingRecord.getEid();
+ final MappingAuthkey authKey = smc.getAuthenticationKey(eid);
+ if (!firstAuthKey.equals(authKey)) {
+ LOG.debug("Map register packet contained several eids. Authentication keys for first one and for " +
+ "{} are different.",LispAddressStringifier.getString(eid));
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
private void handleMapNotify(ByteBuffer inBuffer, InetAddress sourceAddress, int port) {
try {
MapNotify mapNotify = MapNotifySerializer.getInstance().deserialize(inBuffer);
}
}
+
private void handleMapReply(ByteBuffer inBuffer, InetAddress sourceAddress, int port) {
try {
MapReply mapReply = MapReplySerializer.getInstance().deserialize(inBuffer);
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
LOG.error("Error on channel: " + cause, cause);
}
+
+ @Override
+ public void close() throws Exception {
+ authenticationKeyDataListener.closeDataChangeListener();
+ }
+
+ public void setSimpleMapCache(final SimpleMapCache smc) {
+ this.smc = smc;
+ }
+
+ public void setDataBroker(final DataBroker dataBroker) {
+ this.dataBroker = dataBroker;
+ }
+
+ public void setNotificationProvider(NotificationPublishService nps) {
+ this.notificationPublishService = nps;
+ }
+
+ public void setMapRegisterCache(final MapRegisterCache mapRegisterCache) {
+ this.mapRegisterCache = mapRegisterCache;
+ }
+
+
+ public void init() {
+ Preconditions.checkNotNull(dataBroker);
+ Preconditions.checkNotNull(smc);
+ this.authenticationKeyDataListener = new AuthenticationKeyDataListener(dataBroker, smc);
+ }
}
import opendaylight-md-sal-binding { prefix mdsal; revision-date 2013-10-28; }
import opendaylight-sal-binding-broker-impl { prefix sal-broker; revision-date 2013-10-28; }
import odl-lisp-sb { prefix lisp-sb; revision-date 2015-09-04; }
+ import odl-mappingservice-dao { prefix ms-dao; revision-date 2015-10-07; }
description
"This module contains the base YANG definitions for
}
}
}
+
+ container data-broker {
+ uses config:service-ref {
+ refine type {
+ mandatory true;
+ config:required-identity mdsal:binding-async-data-broker;
+ }
+ }
+ }
+
}
}
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.lispflowmapping.implementation.authentication;
+package org.opendaylight.lispflowmapping.southbound.authentication;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;
+import java.nio.ByteBuffer;
import java.util.ArrayList;
import junitx.framework.ArrayAssert;
// No-Action
// Local RLOC: 192.168.136.10 (RLOC=0xC0A8880A), Reachable,
// Priority/Weight: 1/100, Multicast Priority/Weight: 255/0
- //
- MapRegister mapRegister = MapRegisterSerializer.getInstance().deserialize(hexToByteBuffer("38 00 01 01 FF BB "
- + "00 00 00 00 00 00 00 01 00 14 e8 f5 0b c5 c5 f2 "
- + "b0 21 27 a8 21 41 04 f3 46 5a 5a 5b 5c 5d 00 00 "
- + "00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 "
- + "ff 00 00 05 00 01 c0 a8 88 0a"), null);
-
- assertFalse(validate(mapRegister, EID, 1, PASSWORD));
+ final ByteBuffer byteBuffer = hexToByteBuffer("38 00 01 01 FF BB "
+ + "00 00 00 00 00 00 00 01 00 14 e8 f5 0b c5 c5 f2 "
+ + "b0 21 27 a8 21 41 04 f3 46 5a 5a 5b 5c 5d 00 00 "
+ + "00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 "
+ + "ff 00 00 05 00 01 c0 a8 88 0a");
+ MapRegister mapRegister = MapRegisterSerializer.getInstance().deserialize(byteBuffer, null);
+
+ assertFalse(validate(mapRegister, byteBuffer, EID, 1, PASSWORD));
}
@Test
// Local RLOC: 192.168.136.10 (RLOC=0xC0A8880A), Reachable,
// Priority/Weight: 1/100, Multicast Priority/Weight: 255/0
//
- MapRegister mapRegister = MapRegisterSerializer.getInstance().deserialize(hexToByteBuffer("38 00 01 01 FF BB "
+ final ByteBuffer byteBuffer = hexToByteBuffer("38 00 01 01 FF BB "
+ "00 00 00 00 00 00 00 01 00 14 2c 61 b9 c9 9a 20 ba d8 f5 40 d3 55 6f 5f 6e 5a b2 0a bf b5 00 00 "
+ "00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 "
- + "ff 00 00 05 00 01 c0 a8 88 0a"), null);
+ + "ff 00 00 05 00 01 c0 a8 88 0a");
+ MapRegister mapRegister = MapRegisterSerializer.getInstance().deserialize(byteBuffer, null);
- assertTrue(validate(mapRegister, EID, 1, PASSWORD));
- assertFalse(validate(mapRegister, EID, 1, WRONG_PASSWORD));
+ assertTrue(validate(mapRegister, byteBuffer, EID, 1, PASSWORD));
+ assertFalse(validate(mapRegister, byteBuffer, EID, 1, WRONG_PASSWORD));
}
@Test
// Local RLOC: 192.168.136.10 (RLOC=0xC0A8880A), Reachable,
// Priority/Weight: 1/100, Multicast Priority/Weight: 255/0
//
+ final ByteBuffer byteBuffer = hexToByteBuffer("38 00 01 01 FF BB "
+ + "00 00 00 00 00 00 00 02 00 20 "
+ + "70 30 d4 c6 10 44 0d 83 be 4d bf fd a9 8c 57 6d "
+ + "68 a5 bf 32 11 c9 7b 58 c4 b9 9f 06 11 23 b9 38 "
+ + "00 00 "
+ + "00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 "
+ + "ff 00 00 05 00 01 c0 a8 88 0a");
MapRegister mapRegister = MapRegisterSerializer
.getInstance()
- .deserialize(
- hexToByteBuffer("38 00 01 01 FF BB "
- + "00 00 00 00 00 00 00 02 00 20 "
- + "70 30 d4 c6 10 44 0d 83 be 4d bf fd a9 8c 57 6d "
- + "68 a5 bf 32 11 c9 7b 58 c4 b9 9f 06 11 23 b9 38 "
- + "00 00 "
- + "00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 "
- + "ff 00 00 05 00 01 c0 a8 88 0a"), null);
-
- assertTrue(validate(mapRegister, EID, 2, PASSWORD));
- assertFalse(validate(mapRegister, EID, 2, WRONG_PASSWORD));
+ .deserialize(byteBuffer, null);
+
+ assertTrue(validate(mapRegister, byteBuffer, EID, 2, PASSWORD));
+ assertFalse(validate(mapRegister, byteBuffer, EID, 2, WRONG_PASSWORD));
}
@Test
// Local RLOC: 192.168.136.10 (RLOC=0xC0A8880A), Reachable,
// Priority/Weight: 1/100, Multicast Priority/Weight: 255/0
//
- MapRegister mapRegister = MapRegisterSerializer.getInstance().deserialize(hexToByteBuffer("38 00 01 01 FF BB "
+ final ByteBuffer byteBuffer = hexToByteBuffer("38 00 01 01 FF BB "
+ "00 00 00 00 00 00 00 00 00 00 "
+ "00 00 "
+ "00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 "
- + "ff 00 00 05 00 01 c0 a8 88 0a"), null);
+ + "ff 00 00 05 00 01 c0 a8 88 0a");
+ MapRegister mapRegister = MapRegisterSerializer.getInstance().deserialize(byteBuffer, null);
- assertTrue(validate(mapRegister, EID, 0, PASSWORD));
- assertTrue(validate(mapRegister, EID, 0, WRONG_PASSWORD));
+ assertTrue(validate(mapRegister, byteBuffer, EID, 0, PASSWORD));
+ assertTrue(validate(mapRegister, byteBuffer, EID, 0, WRONG_PASSWORD));
}
// @Test
}
- private static boolean validate(MapRegister mapRegister, Eid eid, int keyId, String password) {
+ private static boolean validate(MapRegister mapRegister, ByteBuffer byteBuffer, Eid eid, int keyId, String
+ password) {
MappingAuthkey key = new MappingAuthkeyBuilder().setKeyType(keyId).setKeyString(password).build();
- return LispAuthenticationUtil.validate(mapRegister, eid, key);
+ return LispAuthenticationUtil.validate(mapRegister,byteBuffer, eid, key);
}
}
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
-import static org.opendaylight.lispflowmapping.southbound.lisp.MapRegisterCacheTestUtil.authenticationData;
import static org.opendaylight.lispflowmapping.southbound.lisp.MapRegisterCacheTestUtil.data1;
import static org.opendaylight.lispflowmapping.southbound.lisp.MapRegisterCacheTestUtil.data2;
import static org.opendaylight.lispflowmapping.southbound.lisp.MapRegisterCacheTestUtil.data3;
import org.apache.commons.lang3.ArrayUtils;
import org.jmock.api.Invocation;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.AdditionalMatchers;
import org.mockito.InOrder;
+import org.mockito.Matchers;
import org.mockito.Mockito;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
import org.opendaylight.lispflowmapping.lisp.serializer.MapNotifySerializer;
import org.opendaylight.lispflowmapping.lisp.serializer.MapReplySerializer;
import org.opendaylight.lispflowmapping.lisp.util.LispAddressUtil;
import org.opendaylight.lispflowmapping.lisp.util.MapNotifyBuilderHelper;
import org.opendaylight.lispflowmapping.lisp.util.MaskUtil;
+import org.opendaylight.lispflowmapping.mapcache.SimpleMapCache;
import org.opendaylight.lispflowmapping.southbound.LispSouthboundPlugin;
import org.opendaylight.lispflowmapping.southbound.lisp.cache.MapRegisterCache;
import org.opendaylight.lispflowmapping.southbound.lisp.exception.LispMalformedPacketException;
import org.opendaylight.lispflowmapping.tools.junit.BaseTestCase;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana.afn.safi.rev130704.AddressFamily;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.InstanceIdType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.Ipv4BinaryAfi;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.Ipv4PrefixBinaryAfi;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.Ipv6PrefixBinaryAfi;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapreplymessage.MapReplyBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.mapping.authkey.container.MappingAuthkeyBuilder;
import org.opendaylight.yangtools.yang.binding.Notification;
public class LispSouthboundServiceTest extends BaseTestCase {
private LispSouthboundPlugin mockLispSouthboundPlugin;
private static final long CACHE_RECORD_TIMEOUT = 90000;
+ private static SimpleMapCache smc;
private interface MapReplyIpv4SingleLocatorPos {
int RECORD_COUNT = 3;
int LOCATOR = MapReplyIpv4SingleLocatorPos.LOCATOR + FIRST_LOCATOR_IPV4_LENGTH;
}
+ @BeforeClass
+ public static void initTests() {
+ smc = Mockito.mock(SimpleMapCache.class);
+ Mockito.when(smc.getAuthenticationKey(Matchers.eq(LispAddressUtil.asIpv4PrefixBinaryEid("10.10.10.10/8"))))
+ .thenReturn(new MappingAuthkeyBuilder().setKeyType(1).setKeyString("password").build());
+ Mockito.when(smc.getAuthenticationKey(Matchers.eq(LispAddressUtil.asIpv6PrefixBinaryEid
+ ("2610:d0:ffff:192:0:0:0:1/128"))))
+ .thenReturn(new MappingAuthkeyBuilder().setKeyType(1).setKeyString("password").build());
+ Mockito.when(smc.getAuthenticationKey(Matchers.eq(LispAddressUtil.asIpv4PrefixBinaryEid("153.16.254.1/32"))))
+ .thenReturn(new MappingAuthkeyBuilder().setKeyType(1).setKeyString("password").build());
+ Mockito.when(smc.getAuthenticationKey(Matchers.eq(LispAddressUtil.asIpv4PrefixBinaryEid("125.124.123.122/8", new
+ InstanceIdType(21L)))))
+ .thenReturn(new MappingAuthkeyBuilder().setKeyType(1).setKeyString("password").build());
+ Mockito.when(smc.getAuthenticationKey(Matchers.eq(LispAddressUtil.asMacEid("0a:0b:0c:0d:0e:0f"))))
+ .thenReturn(new MappingAuthkeyBuilder().setKeyType(1).setKeyString("password").build());
+ Mockito.when(smc.getAuthenticationKey(Matchers.eq(LispAddressUtil.asIpv6PrefixBinaryEid
+ ("f0f:f0f:f0f:f0f:f0f:f0f:f0f:f0f/8"))))
+ .thenReturn(new MappingAuthkeyBuilder().setKeyType(1).setKeyString("password").build());
+ Mockito.when(smc.getAuthenticationKey(Matchers.eq(LispAddressUtil.asIpv4PrefixBinaryEid("172.1.1.2/32"))))
+ .thenReturn(new MappingAuthkeyBuilder().setKeyType(1).setKeyString("password").build());
+ }
+
@Override
@Before
public void before() throws Exception {
super.before();
// mapResolver = context.mock(IMapResolver.class);
// mapServer = context.mock(IMapServer.class);
- mapRegisterCache = new MapRegisterCache();
mockLispSouthboundPlugin = mock(LispSouthboundPlugin.class);
- testedLispService = new LispSouthboundHandler(mockLispSouthboundPlugin, mapRegisterCache);
+ testedLispService = new LispSouthboundHandler(mockLispSouthboundPlugin);
+ mapRegisterCache = new MapRegisterCache();
+ testedLispService.setMapRegisterCache(mapRegisterCache);
+ testedLispService.setDataBroker(Mockito.mock(DataBroker.class));
+ testedLispService.setSimpleMapCache(smc);
+ testedLispService.init();
nps = context.mock(NotificationPublishService.class);
testedLispService.setNotificationProvider(nps);
lispNotificationSaver = new ValueSaverAction<Notification>();
}
void mapRegisterInvocationForCacheTest(byte[] eidPrefixAfi, byte[] eidPrefix) {
+ mapRegisterInvocationForCacheTest(eidPrefixAfi, eidPrefix, MapRegisterCacheTestUtil.authenticationData);
+ }
+
+ void mapRegisterInvocationForCacheTest(byte[] eidPrefixAfi, byte[] eidPrefix, byte[] authenticationData) {
final byte[] mapRegisterMessage = MapRegisterCacheTestUtil.joinArrays(data1, nonce, keyId,
authenticationData, data2, eidPrefixAfi, eidPrefix, data3, xTRId, siteId);
handlePacket(mapRegisterMessage);
byte[] eidPrefix = new byte[] {
0x0a, 0x0a, 0x0a, 0x0a //ipv4 address
};
- cacheTest(eidPrefixAfi, eidPrefix);
+
+ cacheTest(eidPrefixAfi, eidPrefix, MapRegisterCacheTestUtil.authenticationData);
}
/**
,0x0f, 0x0f, 0x0f, 0x0f //ipv6 address
,0x0f, 0x0f, 0x0f, 0x0f //ipv6 address
};
- cacheTest(eidPrefixAfi, eidPrefix);
+
+ byte[] authenticationData = new byte[]{
+ 0x00, 0x14
+ ,0x41,(byte)0x83,0x13,0x7C
+ ,0x48,(byte)0xEE,0x75,(byte)0x9A
+ ,0x4,(byte)0x8C,0x46,(byte)0xA6
+ ,0x1B,0x13,(byte)0xC8,0x4D
+ ,(byte)0xA1,0x17,0x53,(byte)0xC3
+ };
+
+ cacheTest(eidPrefixAfi, eidPrefix, authenticationData);
}
/**
0x0a, 0x0b, 0x0c, 0x0d //mac address
,0x0e, 0x0f //mac address
};
- cacheTest(eidPrefixAfi, eidPrefix);
+ byte[] authenticationData = new byte[]{
+ 0x00, 0x14
+ ,(byte)0xB2,(byte)0x8E,0x6,(byte)0x9D
+ ,0x61,(byte)0xD8,0xC,0x24
+ ,(byte)0x80,0x61,0x5A,0x20
+ ,0xD,0x50,0x5E,(byte)0xAE
+ ,0x47,(byte)0xF7,(byte)0x86,0x36
+ };
+ cacheTest(eidPrefixAfi, eidPrefix, authenticationData);
}
/**
byte[] eidPrefix = joinArrays(lcafRsvd1, lcafFlags, lcafType, lcafIIDMaskLength, lcafLength, lcafInstanceId,
lcafAfi, lcafAddress);
- cacheTest(eidPrefixAfi, eidPrefix);
+
+ byte[] authenticationData = new byte[]{
+ 0x00, 0x14 //authentication data length
+ ,0x68, 0x1d, (byte) 0x9e, 0x6e //auth data
+ ,0x5e, 0x32, (byte) 0x88, 0x1a //auth data
+ ,(byte) 0xae, 0x6b, (byte) 0xe3, 0x40 //auth data
+ ,0x30, (byte) 0x0b, (byte) 0xb6, (byte) 0xa0 //auth data
+ ,0x71, (byte) 0xf4, (byte) 0x8c, 0x5f //auth data
+ };
+
+
+ cacheTest(eidPrefixAfi, eidPrefix, authenticationData);
}
/**
* @param eidPrefixAfi
* @param eidPrefix
*/
- public void cacheTest(byte[] eidPrefixAfi, byte[] eidPrefix) throws InterruptedException {
+ public void cacheTest(byte[] eidPrefixAfi, byte[] eidPrefix, byte[] authenticationData) throws
+ InterruptedException {
final MapRegisterCacheKey mapRegisterCacheKey = MapRegisterCacheTestUtil.createMapRegisterCacheKey(eidPrefix);
final NotificationPublishService mockedNotificationProvider = mock(NotificationPublishService.class);
testedLispService.setNotificationProvider(mockedNotificationProvider);
MapRegisterCacheTestUtil.beforeMapRegisterInvocationValidation(mapRegisterCacheKey, mapRegisterCache);
- mapRegisterInvocationForCacheTest(eidPrefixAfi, eidPrefix);
+ mapRegisterInvocationForCacheTest(eidPrefixAfi, eidPrefix, authenticationData);
MapRegisterCacheTestUtil.afterMapRegisterInvocationValidation(mockedNotificationProvider,
mapRegisterCacheKey, mapRegisterCache, eidPrefixAfi, eidPrefix);
}
cacheRecordExpirationTest(false);
}
- private void cacheRecordExpirationTest(boolean cacheRecordTimeouted) {
- mapRegisterCache = mock(MapRegisterCache.class);
- testedLispService = new LispSouthboundHandler(mockLispSouthboundPlugin, mapRegisterCache);
+ private void cacheRecordExpirationTest(boolean cacheRecordTimeouted) throws InterruptedException {
+ mapRegisterCache = Mockito.mock(MapRegisterCache.class);
+ testedLispService.setMapRegisterCache(mapRegisterCache);
+ testedLispService.setNotificationProvider(Mockito.mock(NotificationPublishService.class));
byte[] eidPrefixAfi = new byte[] {0x00, 0x01};
-
byte[] eidPrefix = new byte[] {0x0a, 0x0a, 0x0a, 0x0a};
-
MapRegisterCacheKeyBuilder cacheKeyBld = new MapRegisterCacheKeyBuilder();
MapRegisterCacheValueBuilder cacheValueBld = new MapRegisterCacheValueBuilder();
cacheKeyBld.setXtrId(xTRId);
};
final static byte[] keyId = new byte[] {
- 0x10, 0x10 //key ID
+ 0x00, 0x01 //key ID
};
final static byte[] authenticationData = new byte[]{
- 0x00, 0x0c //authentication data length
- ,0x7f, 0x7f, 0x7f, 0x7f //auth data
- ,0x7f, 0x7f, 0x7f, 0x7f //auth data
- ,0x7f, 0x7f, 0x7f, 0x7f //auth data
+ 0x00, 0x14 //authentication data length
+ ,(byte)0xfa, 0x50, 0x1d, (byte)0xd6 //auth data
+ ,0x63, 0x53, 0x67, 0x6c //auth data
+ ,0x00, 0x3c, 0x61, 0x67 //auth data
+ ,0x35, (byte) 0xb8, (byte) 0xcf, 0x16 //auth data
+ ,(byte) 0x91, (byte) 0xcd, 0x6b, (byte) 0x95 //auth data
};
final static byte[] data2 = new byte[]{