import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.opendaylight.controller.md.sal.binding.api.NotificationService;
-import org.opendaylight.lispflowmapping.implementation.authentication.LispAuthenticationUtil;
import org.opendaylight.lispflowmapping.implementation.config.ConfigIni;
import org.opendaylight.lispflowmapping.interfaces.dao.SubKeys;
import org.opendaylight.lispflowmapping.interfaces.dao.SubscriberRLOC;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingChanged;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingOrigin;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.OdlMappingserviceListener;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.mapping.authkey.container.MappingAuthkey;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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;
boolean mappingUpdated = false;
boolean merge = ConfigIni.getInstance().mappingMergeIsSet() && mapRegister.isMergeEnabled();
- MappingAuthkey authkey = null;
Set<SubscriberRLOC> subscribers = null;
MappingRecord oldMapping;
for (MappingRecordItem record : mapRegister.getMappingRecordItem()) {
MappingRecord mapping = record.getMappingRecord();
- if (authenticate) {
- authkey = mapService.getAuthenticationKey(mapping.getEid());
- if (!LispAuthenticationUtil.validate(mapRegister, mapping.getEid(), authkey)) {
- authFailed = true;
- break;
- }
- }
oldMapping = (MappingRecord) mapService.getMapping(MappingOrigin.Southbound, mapping.getEid());
mapService.addMapping(MappingOrigin.Southbound, mapping.getEid(), getSiteId(mapRegister), mapping, merge);
}
}
}
- if (!authFailed && BooleanUtils.isTrue(mapRegister.isWantMapNotify())) {
+ if (BooleanUtils.isTrue(mapRegister.isWantMapNotify())) {
LOG.trace("MapRegister wants MapNotify");
MapNotifyBuilder builder = new MapNotifyBuilder();
List<TransportAddress> rlocs = null;
} else {
MapNotifyBuilderHelper.setFromMapRegister(builder, mapRegister);
}
- if (authenticate) {
- builder.setAuthenticationData(LispAuthenticationUtil.createAuthenticationData(builder.build(),
- authkey.getKeyString()));
- }
notifyHandler.handleMapNotify(builder.build(), rlocs);
}
}
// For SrcDst LCAF also send SMRs to Dst prefix
if (eid.getAddress() instanceof SourceDestKey) {
- Eid dstAddr = SourceDestKeyHelper.getDst(eid);
+ Eid dstAddr = SourceDestKeyHelper.getDstBinary(eid);
Set<SubscriberRLOC> dstSubs = getSubscribers(dstAddr);
MappingRecord newRecord = new MappingRecordBuilder(record).setEid(dstAddr).build();
handleSmr(newRecord.getEid(), dstSubs, notifyHandler);