Authentication to southbound
[lispflowmapping.git] / mappingservice / southbound / src / main / java / org / opendaylight / lispflowmapping / southbound / lisp / LispSouthboundHandler.java
1 /*
2  * Copyright (c) 2014 Contextream, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.lispflowmapping.southbound.lisp;
10
11 import com.google.common.base.Preconditions;
12 import io.netty.buffer.ByteBufUtil;
13 import io.netty.channel.ChannelHandler;
14 import io.netty.channel.ChannelHandlerContext;
15 import io.netty.channel.SimpleChannelInboundHandler;
16 import io.netty.channel.socket.DatagramPacket;
17 import java.net.InetAddress;
18 import java.nio.ByteBuffer;
19 import java.util.ArrayList;
20 import java.util.Arrays;
21 import java.util.List;
22 import java.util.Map;
23 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
24 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
25 import org.opendaylight.lispflowmapping.inmemorydb.HashMapDb;
26 import org.opendaylight.lispflowmapping.southbound.authentication.LispAuthenticationUtil;
27 import org.opendaylight.lispflowmapping.lisp.serializer.MapNotifySerializer;
28 import org.opendaylight.lispflowmapping.lisp.serializer.MapRegisterSerializer;
29 import org.opendaylight.lispflowmapping.lisp.serializer.MapReplySerializer;
30 import org.opendaylight.lispflowmapping.lisp.serializer.MapRequestSerializer;
31 import org.opendaylight.lispflowmapping.lisp.type.LispMessage;
32 import org.opendaylight.lispflowmapping.lisp.util.ByteUtil;
33 import org.opendaylight.lispflowmapping.lisp.util.LispAddressStringifier;
34 import org.opendaylight.lispflowmapping.lisp.util.MapRequestUtil;
35 import org.opendaylight.lispflowmapping.mapcache.SimpleMapCache;
36 import org.opendaylight.lispflowmapping.southbound.LispSouthboundPlugin;
37 import org.opendaylight.lispflowmapping.southbound.LispSouthboundStats;
38 import org.opendaylight.lispflowmapping.southbound.lisp.cache.MapRegisterCache;
39 import org.opendaylight.lispflowmapping.southbound.lisp.cache.MapRegisterPartialDeserializer;
40 import org.opendaylight.lispflowmapping.southbound.lisp.exception.LispMalformedPacketException;
41 import org.opendaylight.lispflowmapping.southbound.lisp.network.PacketHeader;
42 import org.opendaylight.lispflowmapping.southbound.util.LispNotificationHelper;
43 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMappingBuilder;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapNotifyBuilder;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapReplyBuilder;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MappingKeepAlive;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MappingKeepAliveBuilder;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MessageType;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.RequestMappingBuilder;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.map.register.cache.key.container.MapRegisterCacheKey;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.map.register.cache.metadata.container.MapRegisterCacheMetadata;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.map.register.cache.metadata.container.MapRegisterCacheMetadataBuilder;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.map.register.cache.metadata.container.map.register.cache.metadata.EidLispAddress;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.map.register.cache.metadata.container.map.register.cache.metadata.EidLispAddressBuilder;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.map.register.cache.value.grouping.MapRegisterCacheValue;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.map.register.cache.value.grouping.MapRegisterCacheValueBuilder;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddressBuilder;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.mapping.authkey.container.MappingAuthkey;
67 import org.opendaylight.yangtools.yang.binding.Notification;
68 import org.slf4j.Logger;
69 import org.slf4j.LoggerFactory;
70
71 @ChannelHandler.Sharable
72 public class LispSouthboundHandler extends SimpleChannelInboundHandler<DatagramPacket>
73         implements ILispSouthboundService, AutoCloseable {
74     private MapRegisterCache mapRegisterCache;
75
76     /**
77      * How long is record supposed to be relevant. After this time record isn't valid.
78      *
79      * If you modify this value, please update the LispSouthboundServiceTest class too.
80      */
81     private static final long CACHE_RECORD_TIMEOUT = 90000;
82     private DataBroker dataBroker;
83
84     private NotificationPublishService notificationPublishService;
85     protected static final Logger LOG = LoggerFactory.getLogger(LispSouthboundHandler.class);
86
87     //TODO: think whether this field can be accessed through mappingservice or some other configuration parameter
88     private boolean authenticationEnabled = true;
89
90     private final LispSouthboundPlugin lispSbPlugin;
91     private LispSouthboundStats lispSbStats = null;
92     private SimpleMapCache smc;
93     private AuthenticationKeyDataListener authenticationKeyDataListener;
94
95     public LispSouthboundHandler(LispSouthboundPlugin lispSbPlugin) {
96         this.lispSbPlugin = lispSbPlugin;
97         if (lispSbPlugin != null) {
98             this.lispSbStats = lispSbPlugin.getStats();
99         }
100         this.mapRegisterCache = new MapRegisterCache();
101         this.smc = new SimpleMapCache(new HashMapDb());
102     }
103
104     public void handlePacket(DatagramPacket msg) {
105         ByteBuffer inBuffer = msg.content().nioBuffer();
106         int type = ByteUtil.getUnsignedByte(inBuffer, LispMessage.Pos.TYPE) >> 4;
107         handleStats(type);
108         Object lispType = MessageType.forValue(type);
109         if (lispType == MessageType.EncapsulatedControlMessage) {
110             LOG.trace("Received packet of type Encapsulated Control Message");
111             handleEncapsulatedControlMessage(inBuffer, msg.sender().getAddress());
112         } else if (lispType == MessageType.MapRequest) {
113             LOG.trace("Received packet of type Map-Request");
114             handleMapRequest(inBuffer, msg.sender().getPort());
115         } else if (lispType == MessageType.MapRegister) {
116             LOG.trace("Received packet of type Map-Register");
117             handleMapRegister(inBuffer, msg.sender().getAddress(), msg.sender().getPort());
118         } else if (lispType == MessageType.MapNotify) {
119             LOG.trace("Received packet of type Map-Notify");
120             handleMapNotify(inBuffer, msg.sender().getAddress(), msg.sender().getPort());
121         } else if (lispType == MessageType.MapReply) {
122             LOG.trace("Received packet of type Map-Reply");
123             handleMapReply(inBuffer, msg.sender().getAddress(), msg.sender().getPort());
124         } else {
125             LOG.warn("Received unknown LISP control packet (type " + ((lispType != null) ? lispType : type) + ")");
126         }
127     }
128
129     private void handleEncapsulatedControlMessage(ByteBuffer inBuffer, InetAddress sourceAddress) {
130         try {
131             handleMapRequest(inBuffer, extractEncapsulatedSourcePort(inBuffer));
132         } catch (RuntimeException re) {
133             throw new LispMalformedPacketException("Couldn't deserialize Map-Request (len="
134                     + inBuffer.capacity() + ")", re);
135         }
136     }
137
138     private void handleMapRequest(ByteBuffer inBuffer, int port) {
139         try {
140             MapRequest request = MapRequestSerializer.getInstance().deserialize(inBuffer);
141             InetAddress finalSourceAddress = MapRequestUtil.selectItrRloc(request);
142             if (finalSourceAddress == null) {
143                 throw new LispMalformedPacketException("Couldn't deserialize Map-Request, no ITR Rloc found!");
144             }
145
146             RequestMappingBuilder requestMappingBuilder = new RequestMappingBuilder();
147             requestMappingBuilder.setMapRequest(LispNotificationHelper.convertMapRequest(request));
148             TransportAddressBuilder transportAddressBuilder = new TransportAddressBuilder();
149             transportAddressBuilder.setIpAddress(
150                     LispNotificationHelper.getIpAddressBinaryFromInetAddress(finalSourceAddress));
151             transportAddressBuilder.setPort(new PortNumber(port));
152             requestMappingBuilder.setTransportAddress(transportAddressBuilder.build());
153             if (notificationPublishService != null) {
154                 notificationPublishService.putNotification(requestMappingBuilder.build());
155                 LOG.trace("MapRequest was published!");
156             } else {
157                 LOG.warn("Notification Provider is null!");
158             }
159         } catch (RuntimeException re) {
160             throw new LispMalformedPacketException("Couldn't deserialize Map-Request (len="
161                     + inBuffer.capacity() + ")", re);
162         } catch (InterruptedException e) {
163             LOG.warn("Notification publication interrupted!");
164         }
165     }
166
167     private int extractEncapsulatedSourcePort(ByteBuffer inBuffer) {
168         try {
169             inBuffer.position(PacketHeader.Length.LISP_ENCAPSULATION);
170             int ipType = (inBuffer.get() >> 4);
171             if (ipType == 4) {
172                 inBuffer.position(inBuffer.position() + PacketHeader.Length.IPV4 - 1);
173             } else if (ipType == 6) {
174                 inBuffer.position(inBuffer.position() + PacketHeader.Length.IPV6_NO_EXT - 1);
175             } else {
176                 throw new LispMalformedPacketException(
177                         "Couldn't deserialize Map-Request: inner packet has unknown IP version: " + ipType);
178             }
179
180             int encapsulatedSourcePort = inBuffer.getShort() & 0xFFFF;
181             inBuffer.position(inBuffer.position() + PacketHeader.Length.UDP - 2);
182             return encapsulatedSourcePort;
183         } catch (RuntimeException re) {
184             throw new LispMalformedPacketException("Couldn't deserialize Map-Request (len="
185                     + inBuffer.capacity() + ")", re);
186         }
187     }
188
189     private void handleMapRegister(ByteBuffer inBuffer, InetAddress sourceAddress, int port) {
190         try {
191             final Map.Entry<MapRegisterCacheKey, byte[]> artificialEntry = MapRegisterPartialDeserializer
192                     .deserializePartially(inBuffer, sourceAddress);
193             final MapRegisterCacheKey cacheKey = artificialEntry == null ? null : artificialEntry.getKey();
194
195             final MapRegisterCacheValue cacheValue = resolveCacheValue(artificialEntry);
196             if (cacheValue != null) {
197                 final MapRegisterCacheMetadata mapRegisterValue = cacheValue.getMapRegisterCacheMetadata();
198                 LOG.debug("Map register message site-ID: {} xTR-ID: {} from cache.", mapRegisterValue.getSiteId(),
199                         mapRegisterValue.getXtrId());
200                 mapRegisterCache.refreshEntry(cacheKey);
201                 sendNotificationIfPossible(createMappingKeepAlive(cacheValue));
202                 if (mapRegisterValue.isWantMapNotify()) {
203                     sendMapNotifyMsg(inBuffer, sourceAddress, port);
204                 }
205             } else {
206                 MapRegister mapRegister = MapRegisterSerializer.getInstance().deserialize(inBuffer, sourceAddress);
207                 if (isAuthenticationSuccessful(mapRegister, inBuffer)) {
208                     AddMappingBuilder addMappingBuilder = new AddMappingBuilder();
209                     addMappingBuilder.setMapRegister(LispNotificationHelper.convertMapRegister(mapRegister));
210                     TransportAddressBuilder transportAddressBuilder = new TransportAddressBuilder();
211                     transportAddressBuilder.setIpAddress(LispNotificationHelper.getIpAddressBinaryFromInetAddress(
212                             sourceAddress));
213                     transportAddressBuilder.setPort(new PortNumber(port));
214                     addMappingBuilder.setTransportAddress(transportAddressBuilder.build());
215                     sendNotificationIfPossible(addMappingBuilder.build());
216                     if (artificialEntry != null) {
217                         final MapRegisterCacheMetadataBuilder cacheMetadataBldNew = new
218                                 MapRegisterCacheMetadataBuilder();
219                         cacheMetadataBldNew.setEidLispAddress(provideEidPrefixesFromMessage(mapRegister));
220                         cacheMetadataBldNew.setXtrId(mapRegister.getXtrId());
221                         cacheMetadataBldNew.setSiteId(mapRegister.getSiteId());
222                         cacheMetadataBldNew.setWantMapNotify(mapRegister.isWantMapNotify());
223                         cacheMetadataBldNew.setMergeEnabled(mapRegister.isMergeEnabled());
224                         cacheMetadataBldNew.setTimestamp(System.currentTimeMillis());
225
226                         final MapRegisterCacheValueBuilder cacheValueBldNew = new MapRegisterCacheValueBuilder();
227                         cacheValueBldNew.setPacketData(artificialEntry.getValue());
228                         cacheValueBldNew.setMapRegisterCacheMetadata(cacheMetadataBldNew.build());
229
230                         mapRegisterCache.addEntry(cacheKey, cacheValueBldNew.build());
231                     }
232                 }
233             }
234         } catch (RuntimeException re) {
235             throw new LispMalformedPacketException("Couldn't deserialize Map-Register (len="
236                     + inBuffer.capacity() + ")", re);
237         } catch (InterruptedException e) {
238             LOG.warn("Notification publication interrupted!");
239         }
240     }
241
242     private MapRegisterCacheValue resolveCacheValue(Map.Entry<MapRegisterCacheKey, byte[]> entry) {
243         if (entry != null) {
244             final MapRegisterCacheValue mapRegisterCacheValue = mapRegisterCache.getEntry(entry.getKey());
245             if (mapRegisterCacheValue != null) {
246                 final long creationTime = mapRegisterCacheValue.getMapRegisterCacheMetadata().getTimestamp();
247                 final long currentTime = System.currentTimeMillis();
248                 if (currentTime - creationTime > CACHE_RECORD_TIMEOUT) {
249                     mapRegisterCache.removeEntry(entry.getKey());
250                     return null;
251                 } else if (Arrays.equals(mapRegisterCacheValue.getPacketData(), entry.getValue())) {
252                     return mapRegisterCacheValue;
253                 }
254             }
255         }
256         return null;
257     }
258
259     private void sendNotificationIfPossible(final Notification notification) throws InterruptedException {
260         if (notificationPublishService != null) {
261             notificationPublishService.putNotification(notification);
262             LOG.trace("{} was published.", notification.getClass());
263         } else {
264             LOG.warn("Notification Provider is null!");
265         }
266     }
267
268     private MappingKeepAlive createMappingKeepAlive(final MapRegisterCacheValue value) {
269         MappingKeepAliveBuilder mappingKeepAliveBuilder = new MappingKeepAliveBuilder();
270         mappingKeepAliveBuilder.setMapRegisterCacheMetadata(value.getMapRegisterCacheMetadata());
271         return mappingKeepAliveBuilder.build();
272     }
273
274     private void sendMapNotifyMsg(final ByteBuffer inBuffer, final InetAddress inetAddress, int portNumber) {
275         ByteBuffer outBuffer = transformMapRegisterToMapNotify(inBuffer);
276         outBuffer.position(0);
277         lispSbPlugin.handleSerializedLispBuffer(inetAddress, outBuffer, MessageType.MapNotify, portNumber);
278     }
279
280     private ByteBuffer transformMapRegisterToMapNotify(final ByteBuffer buffer) {
281         buffer.position(0);
282         //TODO: also reset of authentication data is required. other trello card is opened for this task.
283         byte[] byteReplacement = new byte[] {0x04, 0x00, 0x00};
284         buffer.put(byteReplacement);
285         return buffer;
286     }
287
288     private List<EidLispAddress> provideEidPrefixesFromMessage(final MapRegister mapRegister) {
289         List<EidLispAddress> eidsResult = new ArrayList<>();
290         for (MappingRecordItem mappingRecordItem : mapRegister.getMappingRecordItem()) {
291             final EidLispAddressBuilder eidLispAddressBuilder = new EidLispAddressBuilder();
292             final Eid eid = mappingRecordItem.getMappingRecord().getEid();
293             eidLispAddressBuilder.setEidLispAddressId(LispAddressStringifier.getString(eid));
294             eidLispAddressBuilder.setEid(eid);
295             eidsResult.add(eidLispAddressBuilder.build());
296         }
297         return eidsResult;
298     }
299
300     /**
301      * Checks whether authentication data is valid.
302      *
303      * Methods pass through all records from map register message. For the EID of the first record it gets
304      * authentication key and does validation of authentication data again this authentication key. If it pass
305      * it just checks for remaining records (and its EID) whether they have the same authenticatin key stored in
306      * simple map cache (smc).
307      *
308      * @param mapRegister
309      * @param byteBuffer
310      * @return
311      */
312     private boolean isAuthenticationSuccessful(final MapRegister mapRegister, final ByteBuffer byteBuffer) {
313         if (!authenticationEnabled) {
314             return true;
315         }
316
317         if (smc == null) {
318             LOG.debug("Simple map cache wasn't instantieted and set.");
319             return false;
320         }
321
322         MappingAuthkey firstAuthKey = null;
323         final List<MappingRecordItem> mappingRecords = mapRegister.getMappingRecordItem();
324         for (int i = 0; i < mappingRecords.size(); i++) {
325             final MappingRecordItem recordItem = mappingRecords.get(i);
326             final MappingRecord mappingRecord = recordItem.getMappingRecord();
327             if (i == 0) {
328                 firstAuthKey = smc.getAuthenticationKey(mappingRecord.getEid());
329                 if (!LispAuthenticationUtil.validate(mapRegister, byteBuffer, mappingRecord.getEid(), firstAuthKey)) {
330                     return false;
331                 }
332             } else {
333                 final Eid eid = mappingRecord.getEid();
334                 final MappingAuthkey authKey = smc.getAuthenticationKey(eid);
335                 if (!firstAuthKey.equals(authKey)) {
336                     LOG.debug("Map register packet contained several eids. Authentication keys for first one and for " +
337                             "{} are different.",LispAddressStringifier.getString(eid));
338                     return false;
339                 }
340             }
341         }
342         return true;
343     }
344
345     private void handleMapNotify(ByteBuffer inBuffer, InetAddress sourceAddress, int port) {
346         try {
347             MapNotify mapNotify = MapNotifySerializer.getInstance().deserialize(inBuffer);
348             GotMapNotifyBuilder gotMapNotifyBuilder = new GotMapNotifyBuilder();
349             gotMapNotifyBuilder.setMapNotify(LispNotificationHelper.convertMapNotify(mapNotify));
350             TransportAddressBuilder transportAddressBuilder = new TransportAddressBuilder();
351             transportAddressBuilder.setIpAddress(LispNotificationHelper
352                     .getIpAddressBinaryFromInetAddress(sourceAddress));
353             transportAddressBuilder.setPort(new PortNumber(port));
354             gotMapNotifyBuilder.setTransportAddress(transportAddressBuilder.build());
355             if (notificationPublishService != null) {
356                 notificationPublishService.putNotification(gotMapNotifyBuilder.build());
357                 LOG.trace("MapNotify was published!");
358             } else {
359                 LOG.warn("Notification Provider is null!");
360             }
361         } catch (RuntimeException re) {
362             throw new LispMalformedPacketException("Couldn't deserialize Map-Notify (len="
363                     + inBuffer.capacity() + ")", re);
364         } catch (InterruptedException e) {
365             LOG.warn("Notification publication interrupted!");
366         }
367     }
368
369
370     private void handleMapReply(ByteBuffer inBuffer, InetAddress sourceAddress, int port) {
371         try {
372             MapReply mapReply = MapReplySerializer.getInstance().deserialize(inBuffer);
373             GotMapReplyBuilder gotMapReplyBuilder = new GotMapReplyBuilder();
374             gotMapReplyBuilder.setMapReply(LispNotificationHelper.convertMapReply(mapReply));
375             TransportAddressBuilder transportAddressBuilder = new TransportAddressBuilder();
376             transportAddressBuilder.setIpAddress(LispNotificationHelper
377                     .getIpAddressBinaryFromInetAddress(sourceAddress));
378             transportAddressBuilder.setPort(new PortNumber(port));
379             gotMapReplyBuilder.setTransportAddress(transportAddressBuilder.build());
380             if (notificationPublishService != null) {
381                 notificationPublishService.putNotification(gotMapReplyBuilder.build());
382                 LOG.trace("MapReply was published!");
383             } else {
384                 LOG.warn("Notification Provider is null!");
385             }
386         } catch (RuntimeException re) {
387             throw new LispMalformedPacketException("Couldn't deserialize Map-Reply (len="
388                     + inBuffer.capacity() + ")", re);
389         } catch (InterruptedException e) {
390             LOG.warn("Notification publication interrupted!");
391         }
392     }
393
394     private void handleStats(int type) {
395         if (lispSbStats != null) {
396             if (type <= LispSouthboundStats.MAX_LISP_TYPES) {
397                 lispSbStats.incrementRx(type);
398             } else {
399                 lispSbStats.incrementRxUnknown();
400             }
401         }
402     }
403
404     @Override
405     protected void channelRead0(ChannelHandlerContext ctx, DatagramPacket msg) throws Exception {
406         if (LOG.isTraceEnabled()) {
407             LOG.trace("Received UDP packet from {}:{} with content:\n{}", msg.sender().getHostString(),
408                     msg.sender().getPort(), ByteBufUtil.prettyHexDump(msg.content()));
409         }
410         handlePacket(msg);
411     }
412
413     @Override
414     public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
415         ctx.flush();
416     }
417
418     @Override
419     public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
420         LOG.error("Error on channel: " + cause, cause);
421     }
422
423     @Override
424     public void close() throws Exception {
425         authenticationKeyDataListener.closeDataChangeListener();
426     }
427
428     public void setSimpleMapCache(final SimpleMapCache smc) {
429         this.smc = smc;
430     }
431
432     public void setDataBroker(final DataBroker dataBroker) {
433         this.dataBroker = dataBroker;
434     }
435
436     public void setNotificationProvider(NotificationPublishService nps) {
437         this.notificationPublishService = nps;
438     }
439
440     public void setMapRegisterCache(final MapRegisterCache mapRegisterCache) {
441         this.mapRegisterCache = mapRegisterCache;
442     }
443
444
445     public void init() {
446         Preconditions.checkNotNull(dataBroker);
447         Preconditions.checkNotNull(smc);
448         this.authenticationKeyDataListener = new AuthenticationKeyDataListener(dataBroker, smc);
449     }
450 }