Move authData calculation logic to each LISP message builder classs
Change-Id: I61f13cbb77c58f06efce7e9450f11d328749b247
diff --git a/protocols/lisp/ctl/src/main/java/org/onosproject/lisp/ctl/LispMapServer.java b/protocols/lisp/ctl/src/main/java/org/onosproject/lisp/ctl/LispMapServer.java
index aca2c76..bcc726a 100644
--- a/protocols/lisp/ctl/src/main/java/org/onosproject/lisp/ctl/LispMapServer.java
+++ b/protocols/lisp/ctl/src/main/java/org/onosproject/lisp/ctl/LispMapServer.java
@@ -15,10 +15,6 @@
*/
package org.onosproject.lisp.ctl;
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
-import org.onosproject.lisp.msg.authentication.LispAuthenticationFactory;
-import org.onosproject.lisp.msg.exceptions.LispWriterException;
import org.onosproject.lisp.msg.protocols.DefaultLispMapNotify.DefaultNotifyBuilder;
import org.onosproject.lisp.msg.protocols.DefaultLispMapRegister.DefaultRegisterBuilder;
import org.onosproject.lisp.msg.protocols.LispEidRecord;
@@ -41,7 +37,7 @@
*/
public class LispMapServer {
- private static final int NOTIFY_PORT = 4342;
+ private static final int MAP_NOTIFY_PORT = 4342;
// TODO: need to be configurable
private static final String AUTH_KEY = "onos";
@@ -51,11 +47,9 @@
private static final Logger log = LoggerFactory.getLogger(LispMapServer.class);
- private LispAuthenticationFactory factory;
private LispEidRlocMap mapInfo;
public LispMapServer() {
- factory = LispAuthenticationFactory.getInstance();
mapInfo = LispEidRlocMap.getInstance();
}
@@ -69,46 +63,22 @@
LispMapRegister register = (LispMapRegister) message;
- if (!checkAuthData(register)) {
+ if (!checkMapRegisterAuthData(register)) {
log.warn("Unmatched authentication data of Map-Register");
return null;
}
- // build temp notify message
- NotifyBuilder authNotifyBuilder = new DefaultNotifyBuilder();
- authNotifyBuilder.withKeyId(AUTH_METHOD);
- authNotifyBuilder.withAuthDataLength(valueOf(AUTH_METHOD).getHashLength());
- authNotifyBuilder.withNonce(register.getNonce());
- authNotifyBuilder.withMapRecords(register.getMapRecords());
-
- byte[] authData = new byte[valueOf(AUTH_METHOD).getHashLength()];
- Arrays.fill(authData, (byte) 0);
- authNotifyBuilder.withAuthenticationData(authData);
-
- ByteBuf byteBuf = Unpooled.buffer();
- try {
- authNotifyBuilder.build().writeTo(byteBuf);
- } catch (LispWriterException e) {
- e.printStackTrace();
- }
-
- byte[] bytes = new byte[byteBuf.readableBytes()];
- byteBuf.readBytes(bytes);
-
- byte[] calcAuthData = factory.createAuthenticationData(
- valueOf(register.getKeyId()), AUTH_KEY, bytes);
-
NotifyBuilder notifyBuilder = new DefaultNotifyBuilder();
notifyBuilder.withKeyId(AUTH_METHOD);
- notifyBuilder.withAuthDataLength((short) calcAuthData.length);
- notifyBuilder.withAuthenticationData(calcAuthData);
+ notifyBuilder.withAuthDataLength(valueOf(AUTH_METHOD).getHashLength());
+ notifyBuilder.withAuthKey(AUTH_KEY);
notifyBuilder.withNonce(register.getNonce());
notifyBuilder.withMapRecords(register.getMapRecords());
LispMapNotify notify = notifyBuilder.build();
InetSocketAddress address =
- new InetSocketAddress(register.getSender().getAddress(), NOTIFY_PORT);
+ new InetSocketAddress(register.getSender().getAddress(), MAP_NOTIFY_PORT);
notify.configSender(address);
register.getMapRecords().forEach(record -> {
@@ -127,33 +97,16 @@
* @param register map-register message
* @return evaluation result
*/
- private boolean checkAuthData(LispMapRegister register) {
- ByteBuf byteBuf = Unpooled.buffer();
+ private boolean checkMapRegisterAuthData(LispMapRegister register) {
RegisterBuilder registerBuilder = new DefaultRegisterBuilder();
registerBuilder.withKeyId(register.getKeyId());
- registerBuilder.withAuthDataLength(register.getAuthDataLength());
+ registerBuilder.withAuthKey(AUTH_KEY);
registerBuilder.withNonce(register.getNonce());
registerBuilder.withIsProxyMapReply(register.isProxyMapReply());
registerBuilder.withIsWantMapNotify(register.isWantMapNotify());
registerBuilder.withMapRecords(register.getMapRecords());
+ LispMapRegister authRegister = registerBuilder.build();
- byte[] authData = register.getAuthenticationData();
- if (authData != null) {
- authData = authData.clone();
- Arrays.fill(authData, (byte) 0);
- }
- registerBuilder.withAuthenticationData(authData);
- try {
- registerBuilder.build().writeTo(byteBuf);
- } catch (LispWriterException e) {
- e.printStackTrace();
- }
-
- byte[] bytes = new byte[byteBuf.readableBytes()];
- byteBuf.readBytes(bytes);
-
- byte[] calculatedAuthData = factory.createAuthenticationData(
- valueOf(register.getKeyId()), AUTH_KEY, bytes);
- return Arrays.equals(calculatedAuthData, register.getAuthenticationData());
+ return Arrays.equals(authRegister.getAuthData(), register.getAuthData());
}
}
diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispInfo.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispInfo.java
index 1f8f771..3ad3bd1 100644
--- a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispInfo.java
+++ b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispInfo.java
@@ -35,7 +35,7 @@
protected final long nonce;
protected final short keyId;
protected final short authDataLength;
- protected final byte[] authenticationData;
+ protected final byte[] authData;
protected final int ttl;
protected final byte maskLength;
protected final LispAfiAddress eidPrefix;
@@ -54,23 +54,23 @@
/**
* A private constructor that protects object instantiation from external.
*
- * @param infoReply info reply flag
- * @param nonce nonce
- * @param keyId key identifier
- * @param authDataLength authentication data length
- * @param authenticationData authentication data
- * @param ttl Time-To-Live value
- * @param maskLength EID prefix mask length
- * @param eidPrefix EID prefix
+ * @param infoReply info reply flag
+ * @param nonce nonce
+ * @param keyId key identifier
+ * @param authDataLength authentication data length
+ * @param authData authentication data
+ * @param ttl Time-To-Live value
+ * @param maskLength EID prefix mask length
+ * @param eidPrefix EID prefix
*/
protected DefaultLispInfo(boolean infoReply, long nonce, short keyId, short authDataLength,
- byte[] authenticationData, int ttl, byte maskLength,
+ byte[] authData, int ttl, byte maskLength,
LispAfiAddress eidPrefix) {
this.infoReply = infoReply;
this.nonce = nonce;
this.keyId = keyId;
this.authDataLength = authDataLength;
- this.authenticationData = authenticationData;
+ this.authData = authData;
this.ttl = ttl;
this.maskLength = maskLength;
this.eidPrefix = eidPrefix;
@@ -92,7 +92,7 @@
}
@Override
- public boolean hasInfoReply() {
+ public boolean isInfoReply() {
return infoReply;
}
@@ -112,9 +112,9 @@
}
@Override
- public byte[] getAuthenticationData() {
- if (authenticationData != null && authenticationData.length != 0) {
- return ImmutableByteSequence.copyFrom(authenticationData).asArray();
+ public byte[] getAuthData() {
+ if (authData != null && authData.length != 0) {
+ return ImmutableByteSequence.copyFrom(authData).asArray();
} else {
return new byte[0];
}
@@ -156,7 +156,7 @@
// authenticationDataLength -> 16 bits
short authLength = byteBuf.readShort();
- // authenticationData -> depends on the authenticationDataLength
+ // authData -> depends on the authenticationDataLength
byte[] authData = new byte[authLength];
byteBuf.readBytes(authData);
@@ -182,7 +182,7 @@
// info reply flag
byte infoReply = DISABLE_BIT;
- if (message.hasInfoReply()) {
+ if (message.isInfoReply()) {
infoReply = (byte) (ENABLE_BIT << INFO_REPLY_INDEX);
}
@@ -203,7 +203,7 @@
byteBuf.writeShort(message.getAuthDataLength());
// authentication data
- byte[] data = message.getAuthenticationData();
+ byte[] data = message.getAuthData();
byte[] clone;
if (data != null) {
clone = data.clone();
@@ -212,8 +212,6 @@
byteBuf.writeBytes(data);
- // TODO: need to implement MAC authentication mechanism
-
/// TTL
byteBuf.writeInt(message.getTtl());
diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispInfoReply.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispInfoReply.java
index 9576dee..29cd39e 100644
--- a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispInfoReply.java
+++ b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispInfoReply.java
@@ -17,41 +17,49 @@
import com.google.common.base.Objects;
import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import org.onosproject.lisp.msg.authentication.LispAuthenticationFactory;
+import org.onosproject.lisp.msg.authentication.LispAuthenticationKeyEnum;
import org.onosproject.lisp.msg.exceptions.LispParseError;
import org.onosproject.lisp.msg.exceptions.LispReaderException;
import org.onosproject.lisp.msg.exceptions.LispWriterException;
import org.onosproject.lisp.msg.types.LispAfiAddress;
import org.onosproject.lisp.msg.types.LispNatLcafAddress;
import org.onosproject.lisp.msg.types.LispNatLcafAddress.NatLcafAddressWriter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.util.Arrays;
import static com.google.common.base.MoreObjects.toStringHelper;
+import static org.onosproject.lisp.msg.authentication.LispAuthenticationKeyEnum.valueOf;
/**
* Default LISP info reply message class.
*/
public final class DefaultLispInfoReply extends DefaultLispInfo implements LispInfoReply {
+ private static final Logger log = LoggerFactory.getLogger(DefaultLispInfoReply.class);
+
private final LispNatLcafAddress natLcafAddress;
/**
* A private constructor that protects object instantiation from external.
*
- * @param infoReply info reply flag
- * @param nonce nonce
- * @param keyId key identifier
- * @param authDataLength authentication data length
- * @param authenticationData authentication data
- * @param ttl Time-To-Live value
- * @param maskLength EID prefix mask length
- * @param eidPrefix EID prefix
- * @param natLcafAddress NAT LCAF address
+ * @param infoReply info reply flag
+ * @param nonce nonce
+ * @param keyId key identifier
+ * @param authDataLength authentication data length
+ * @param authData authentication data
+ * @param ttl Time-To-Live value
+ * @param maskLength EID prefix mask length
+ * @param eidPrefix EID prefix
+ * @param natLcafAddress NAT LCAF address
*/
protected DefaultLispInfoReply(boolean infoReply, long nonce, short keyId, short authDataLength,
- byte[] authenticationData, int ttl, byte maskLength,
- LispAfiAddress eidPrefix, LispNatLcafAddress natLcafAddress) {
- super(infoReply, nonce, keyId, authDataLength, authenticationData, ttl, maskLength, eidPrefix);
+ byte[] authData, int ttl, byte maskLength,
+ LispAfiAddress eidPrefix, LispNatLcafAddress natLcafAddress) {
+ super(infoReply, nonce, keyId, authDataLength, authData, ttl, maskLength, eidPrefix);
this.natLcafAddress = natLcafAddress;
}
@@ -67,7 +75,7 @@
.add("nonce", nonce)
.add("keyId", keyId)
.add("authentication data length", authDataLength)
- .add("authentication data", authenticationData)
+ .add("authentication data", authData)
.add("TTL", ttl)
.add("EID mask length", maskLength)
.add("EID prefix", eidPrefix)
@@ -87,7 +95,7 @@
return Objects.equal(nonce, that.nonce) &&
Objects.equal(keyId, that.keyId) &&
Objects.equal(authDataLength, that.authDataLength) &&
- Arrays.equals(authenticationData, that.authenticationData) &&
+ Arrays.equals(authData, that.authData) &&
Objects.equal(ttl, that.ttl) &&
Objects.equal(maskLength, that.maskLength) &&
Objects.equal(eidPrefix, that.eidPrefix) &&
@@ -97,7 +105,7 @@
@Override
public int hashCode() {
return Objects.hashCode(nonce, keyId, authDataLength, ttl, maskLength,
- eidPrefix, natLcafAddress) + Arrays.hashCode(authenticationData);
+ eidPrefix, natLcafAddress) + Arrays.hashCode(authData);
}
public static final class DefaultInfoReplyBuilder implements InfoReplyBuilder {
@@ -106,7 +114,8 @@
private long nonce;
private short keyId;
private short authDataLength;
- private byte[] authenticationData = new byte[0];
+ private byte[] authData;
+ private String authKey;
private int ttl;
private byte maskLength;
private LispAfiAddress eidPrefix;
@@ -143,14 +152,20 @@
}
@Override
- public InfoReplyBuilder withAuthenticationData(byte[] authenticationData) {
+ public InfoReplyBuilder withAuthData(byte[] authenticationData) {
if (authenticationData != null) {
- this.authenticationData = authenticationData;
+ this.authData = authenticationData;
}
return this;
}
@Override
+ public InfoReplyBuilder withAuthKey(String key) {
+ this.authKey = key;
+ return this;
+ }
+
+ @Override
public InfoReplyBuilder withTtl(int ttl) {
this.ttl = ttl;
return this;
@@ -177,8 +192,36 @@
@Override
public LispInfoReply build() {
+
+ // if authentication data is not specified, we will calculate it
+ if (authData == null) {
+ LispAuthenticationFactory factory = LispAuthenticationFactory.getInstance();
+
+ authDataLength = LispAuthenticationKeyEnum.valueOf(keyId).getHashLength();
+ byte[] tmpAuthData = new byte[authDataLength];
+ Arrays.fill(tmpAuthData, (byte) 0);
+ authData = tmpAuthData;
+
+ ByteBuf byteBuf = Unpooled.buffer();
+ try {
+ new DefaultLispInfoReply(infoReply, nonce, keyId, authDataLength,
+ authData, ttl, maskLength, eidPrefix, natLcafAddress).writeTo(byteBuf);
+ } catch (LispWriterException e) {
+ log.warn("Failed to serialize info reply", e);
+ }
+
+ byte[] bytes = new byte[byteBuf.readableBytes()];
+ byteBuf.readBytes(bytes);
+
+ if (authKey == null) {
+ log.warn("Must specify authentication key");
+ }
+
+ authData = factory.createAuthenticationData(valueOf(keyId), authKey, bytes);
+ }
+
return new DefaultLispInfoReply(infoReply, nonce, keyId, authDataLength,
- authenticationData, ttl, maskLength, eidPrefix, natLcafAddress);
+ authData, ttl, maskLength, eidPrefix, natLcafAddress);
}
}
@@ -193,11 +236,11 @@
LispNatLcafAddress natLcafAddress = new LispNatLcafAddress.NatLcafAddressReader().readFrom(byteBuf);
return new DefaultInfoReplyBuilder()
- .withInfoReply(lispInfo.hasInfoReply())
+ .withInfoReply(lispInfo.isInfoReply())
.withNonce(lispInfo.getNonce())
.withKeyId(lispInfo.getKeyId())
.withAuthDataLength(lispInfo.getAuthDataLength())
- .withAuthenticationData(lispInfo.getAuthenticationData())
+ .withAuthData(lispInfo.getAuthData())
.withTtl(lispInfo.getTtl())
.withMaskLength(lispInfo.getMaskLength())
.withEidPrefix(lispInfo.getPrefix())
diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispInfoRequest.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispInfoRequest.java
index afe473f..a24fd1a 100644
--- a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispInfoRequest.java
+++ b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispInfoRequest.java
@@ -17,36 +17,44 @@
import com.google.common.base.Objects;
import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import org.onosproject.lisp.msg.authentication.LispAuthenticationFactory;
+import org.onosproject.lisp.msg.authentication.LispAuthenticationKeyEnum;
import org.onosproject.lisp.msg.exceptions.LispParseError;
import org.onosproject.lisp.msg.exceptions.LispReaderException;
import org.onosproject.lisp.msg.exceptions.LispWriterException;
import org.onosproject.lisp.msg.types.LispAfiAddress;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.util.Arrays;
import static com.google.common.base.MoreObjects.toStringHelper;
+import static org.onosproject.lisp.msg.authentication.LispAuthenticationKeyEnum.valueOf;
/**
* Default LISP info request message class.
*/
public class DefaultLispInfoRequest extends DefaultLispInfo implements LispInfoRequest {
+ private static final Logger log = LoggerFactory.getLogger(DefaultLispInfoRequest.class);
+
/**
* A private constructor that protects object instantiation from external.
*
- * @param infoReply info reply flag
- * @param nonce nonce
- * @param keyId key identifier
- * @param authDataLength authentication data length
- * @param authenticationData authentication data
- * @param ttl Time-To-Live value
- * @param maskLength EID prefix mask length
- * @param eidPrefix EID prefix
+ * @param infoReply info reply flag
+ * @param nonce nonce
+ * @param keyId key identifier
+ * @param authDataLength authentication data length
+ * @param authData authentication data
+ * @param ttl Time-To-Live value
+ * @param maskLength EID prefix mask length
+ * @param eidPrefix EID prefix
*/
protected DefaultLispInfoRequest(boolean infoReply, long nonce, short keyId, short authDataLength,
- byte[] authenticationData, int ttl, byte maskLength,
+ byte[] authData, int ttl, byte maskLength,
LispAfiAddress eidPrefix) {
- super(infoReply, nonce, keyId, authDataLength, authenticationData, ttl, maskLength, eidPrefix);
+ super(infoReply, nonce, keyId, authDataLength, authData, ttl, maskLength, eidPrefix);
}
@Override
@@ -56,7 +64,7 @@
.add("nonce", nonce)
.add("keyId", keyId)
.add("authentication data length", authDataLength)
- .add("authentication data", authenticationData)
+ .add("authentication data", authData)
.add("TTL", ttl)
.add("EID mask length", maskLength)
.add("EID prefix", eidPrefix).toString();
@@ -75,7 +83,7 @@
return Objects.equal(nonce, that.nonce) &&
Objects.equal(keyId, that.keyId) &&
Objects.equal(authDataLength, that.authDataLength) &&
- Arrays.equals(authenticationData, that.authenticationData) &&
+ Arrays.equals(authData, that.authData) &&
Objects.equal(ttl, that.ttl) &&
Objects.equal(maskLength, that.maskLength) &&
Objects.equal(eidPrefix, that.eidPrefix);
@@ -84,7 +92,7 @@
@Override
public int hashCode() {
return Objects.hashCode(nonce, keyId, authDataLength, ttl, maskLength,
- eidPrefix) + Arrays.hashCode(authenticationData);
+ eidPrefix) + Arrays.hashCode(authData);
}
public static final class DefaultInfoRequestBuilder implements InfoRequestBuilder {
@@ -93,7 +101,8 @@
private long nonce;
private short keyId;
private short authDataLength;
- private byte[] authenticationData = new byte[0];
+ private byte[] authData;
+ private String authKey;
private int ttl;
private byte maskLength;
private LispAfiAddress eidPrefix;
@@ -129,14 +138,20 @@
}
@Override
- public InfoRequestBuilder withAuthenticationData(byte[] authenticationData) {
+ public InfoRequestBuilder withAuthData(byte[] authenticationData) {
if (authenticationData != null) {
- this.authenticationData = authenticationData;
+ this.authData = authenticationData;
}
return this;
}
@Override
+ public InfoRequestBuilder withAuthKey(String key) {
+ this.authKey = key;
+ return this;
+ }
+
+ @Override
public InfoRequestBuilder withTtl(int ttl) {
this.ttl = ttl;
return this;
@@ -156,8 +171,36 @@
@Override
public LispInfoRequest build() {
+
+ // if authentication data is not specified, we will calculate it
+ if (authData == null) {
+ LispAuthenticationFactory factory = LispAuthenticationFactory.getInstance();
+
+ authDataLength = LispAuthenticationKeyEnum.valueOf(keyId).getHashLength();
+ byte[] tmpAuthData = new byte[authDataLength];
+ Arrays.fill(tmpAuthData, (byte) 0);
+ authData = tmpAuthData;
+
+ ByteBuf byteBuf = Unpooled.buffer();
+ try {
+ new DefaultLispInfoRequest(infoReply, nonce, keyId, authDataLength,
+ authData, ttl, maskLength, eidPrefix).writeTo(byteBuf);
+ } catch (LispWriterException e) {
+ log.warn("Failed to serialize info request", e);
+ }
+
+ byte[] bytes = new byte[byteBuf.readableBytes()];
+ byteBuf.readBytes(bytes);
+
+ if (authKey == null) {
+ log.warn("Must specify authentication key");
+ }
+
+ authData = factory.createAuthenticationData(valueOf(keyId), authKey, bytes);
+ }
+
return new DefaultLispInfoRequest(infoReply, nonce, keyId,
- authDataLength, authenticationData, ttl, maskLength, eidPrefix);
+ authDataLength, authData, ttl, maskLength, eidPrefix);
}
}
@@ -172,11 +215,11 @@
LispInfo lispInfo = DefaultLispInfo.deserialize(byteBuf);
return new DefaultInfoRequestBuilder()
- .withInfoReply(lispInfo.hasInfoReply())
+ .withInfoReply(lispInfo.isInfoReply())
.withNonce(lispInfo.getNonce())
.withKeyId(lispInfo.getKeyId())
.withAuthDataLength(lispInfo.getAuthDataLength())
- .withAuthenticationData(lispInfo.getAuthenticationData())
+ .withAuthData(lispInfo.getAuthData())
.withTtl(lispInfo.getTtl())
.withMaskLength(lispInfo.getMaskLength())
.withEidPrefix(lispInfo.getPrefix()).build();
diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispMapNotify.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispMapNotify.java
index 248d118..d6a27fb 100644
--- a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispMapNotify.java
+++ b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispMapNotify.java
@@ -19,15 +19,21 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
import org.onlab.util.ImmutableByteSequence;
+import org.onosproject.lisp.msg.authentication.LispAuthenticationFactory;
+import org.onosproject.lisp.msg.authentication.LispAuthenticationKeyEnum;
import org.onosproject.lisp.msg.exceptions.LispParseError;
import org.onosproject.lisp.msg.exceptions.LispReaderException;
import org.onosproject.lisp.msg.exceptions.LispWriterException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.List;
import static com.google.common.base.MoreObjects.toStringHelper;
+import static org.onosproject.lisp.msg.authentication.LispAuthenticationKeyEnum.valueOf;
import static org.onosproject.lisp.msg.protocols.DefaultLispMapRecord.MapRecordWriter;
/**
@@ -36,13 +42,16 @@
public final class DefaultLispMapNotify extends AbstractLispMessage
implements LispMapNotify {
+ private static final Logger log = LoggerFactory.getLogger(DefaultLispMapNotify.class);
+
private final long nonce;
private final short keyId;
private final short authDataLength;
- private final byte[] authenticationData;
+ private final byte[] authData;
private final List<LispMapRecord> mapRecords;
static final NotifyWriter WRITER;
+
static {
WRITER = new NotifyWriter();
}
@@ -50,17 +59,17 @@
/**
* A private constructor that protects object instantiation from external.
*
- * @param nonce nonce
- * @param keyId key identifier
- * @param authenticationData authentication data
- * @param mapRecords a collection of map records
+ * @param nonce nonce
+ * @param keyId key identifier
+ * @param authData authentication data
+ * @param mapRecords a collection of map records
*/
private DefaultLispMapNotify(long nonce, short keyId, short authDataLength,
- byte[] authenticationData, List<LispMapRecord> mapRecords) {
+ byte[] authData, List<LispMapRecord> mapRecords) {
this.nonce = nonce;
this.keyId = keyId;
this.authDataLength = authDataLength;
- this.authenticationData = authenticationData;
+ this.authData = authData;
this.mapRecords = mapRecords;
}
@@ -100,9 +109,9 @@
}
@Override
- public byte[] getAuthenticationData() {
- if (authenticationData != null && authenticationData.length != 0) {
- return ImmutableByteSequence.copyFrom(authenticationData).asArray();
+ public byte[] getAuthData() {
+ if (authData != null && authData.length != 0) {
+ return ImmutableByteSequence.copyFrom(authData).asArray();
} else {
return new byte[0];
}
@@ -120,7 +129,7 @@
.add("nonce", nonce)
.add("keyId", keyId)
.add("authentication data length", authDataLength)
- .add("authentication data", authenticationData)
+ .add("authentication data", authData)
.add("mapRecords", mapRecords).toString();
}
@@ -136,13 +145,13 @@
return Objects.equal(nonce, that.nonce) &&
Objects.equal(keyId, that.keyId) &&
Objects.equal(authDataLength, that.authDataLength) &&
- Arrays.equals(authenticationData, that.authenticationData);
+ Arrays.equals(authData, that.authData);
}
@Override
public int hashCode() {
return Objects.hashCode(nonce, keyId, authDataLength) +
- Arrays.hashCode(authenticationData);
+ Arrays.hashCode(authData);
}
public static final class DefaultNotifyBuilder implements NotifyBuilder {
@@ -150,7 +159,8 @@
private long nonce;
private short keyId;
private short authDataLength;
- private byte[] authenticationData;
+ private byte[] authData;
+ private String authKey;
private List<LispMapRecord> mapRecords = Lists.newArrayList();
@Override
@@ -171,17 +181,23 @@
}
@Override
+ public NotifyBuilder withAuthKey(String key) {
+ this.authKey = key;
+ return this;
+ }
+
+ @Override
public NotifyBuilder withAuthDataLength(short authDataLength) {
this.authDataLength = authDataLength;
return this;
}
@Override
- public NotifyBuilder withAuthenticationData(byte[] authenticationData) {
- if (authenticationData != null) {
- this.authenticationData = authenticationData;
+ public NotifyBuilder withAuthData(byte[] authData) {
+ if (authData != null) {
+ this.authData = authData;
} else {
- this.authenticationData = new byte[0];
+ this.authData = new byte[0];
}
return this;
}
@@ -197,12 +213,34 @@
@Override
public LispMapNotify build() {
- if (authenticationData == null) {
- authenticationData = new byte[0];
+ // if authentication data is not specified, we will calculate it
+ if (authData == null) {
+ LispAuthenticationFactory factory = LispAuthenticationFactory.getInstance();
+
+ authDataLength = LispAuthenticationKeyEnum.valueOf(keyId).getHashLength();
+ byte[] tmpAuthData = new byte[authDataLength];
+ Arrays.fill(tmpAuthData, (byte) 0);
+ authData = tmpAuthData;
+
+ ByteBuf byteBuf = Unpooled.buffer();
+ try {
+ new DefaultLispMapNotify(nonce, keyId, authDataLength,
+ authData, mapRecords).writeTo(byteBuf);
+ } catch (LispWriterException e) {
+ log.warn("Failed to serialize map notify message", e);
+ }
+
+ byte[] bytes = new byte[byteBuf.readableBytes()];
+ byteBuf.readBytes(bytes);
+
+ if (authKey == null) {
+ log.warn("Must specify authentication key");
+ }
+
+ authData = factory.createAuthenticationData(valueOf(keyId), authKey, bytes);
}
- return new DefaultLispMapNotify(nonce, keyId, authDataLength,
- authenticationData, mapRecords);
+ return new DefaultLispMapNotify(nonce, keyId, authDataLength, authData, mapRecords);
}
}
@@ -235,7 +273,7 @@
// authenticationDataLength -> 16 bits
short authLength = byteBuf.readShort();
- // authenticationData -> depends on the authenticationDataLength
+ // authData -> depends on the authenticationDataLength
byte[] authData = new byte[authLength];
byteBuf.readBytes(authData);
@@ -245,12 +283,12 @@
}
return new DefaultNotifyBuilder()
- .withNonce(nonce)
- .withKeyId(keyId)
- .withAuthDataLength(authLength)
- .withAuthenticationData(authData)
- .withMapRecords(mapRecords)
- .build();
+ .withNonce(nonce)
+ .withKeyId(keyId)
+ .withAuthDataLength(authLength)
+ .withAuthData(authData)
+ .withMapRecords(mapRecords)
+ .build();
}
}
@@ -283,11 +321,11 @@
byteBuf.writeShort(message.getKeyId());
// authentication data and its length
- if (message.getAuthenticationData() == null) {
+ if (message.getAuthData() == null) {
byteBuf.writeShort((short) 0);
} else {
- byteBuf.writeShort(message.getAuthenticationData().length);
- byteBuf.writeBytes(message.getAuthenticationData());
+ byteBuf.writeShort(message.getAuthData().length);
+ byteBuf.writeBytes(message.getAuthData());
}
// serialize map records
diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispMapRegister.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispMapRegister.java
index a3166c1..3171d2e 100644
--- a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispMapRegister.java
+++ b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispMapRegister.java
@@ -19,16 +19,22 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
import org.onlab.util.ByteOperator;
import org.onlab.util.ImmutableByteSequence;
+import org.onosproject.lisp.msg.authentication.LispAuthenticationFactory;
+import org.onosproject.lisp.msg.authentication.LispAuthenticationKeyEnum;
import org.onosproject.lisp.msg.exceptions.LispParseError;
import org.onosproject.lisp.msg.exceptions.LispReaderException;
import org.onosproject.lisp.msg.exceptions.LispWriterException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.List;
import static com.google.common.base.MoreObjects.toStringHelper;
+import static org.onosproject.lisp.msg.authentication.LispAuthenticationKeyEnum.valueOf;
import static org.onosproject.lisp.msg.protocols.DefaultLispMapRecord.MapRecordReader;
import static org.onosproject.lisp.msg.protocols.DefaultLispMapRecord.MapRecordWriter;
@@ -39,15 +45,18 @@
public final class DefaultLispMapRegister extends AbstractLispMessage
implements LispMapRegister {
+ private static final Logger log = LoggerFactory.getLogger(DefaultLispMapRegister.class);
+
private final long nonce;
private final short keyId;
private final short authDataLength;
- private final byte[] authenticationData;
+ private final byte[] authData;
private final List<LispMapRecord> mapRecords;
private final boolean proxyMapReply;
private final boolean wantMapNotify;
static final RegisterWriter WRITER;
+
static {
WRITER = new RegisterWriter();
}
@@ -55,21 +64,21 @@
/**
* A private constructor that protects object instantiation from external.
*
- * @param nonce nonce
- * @param keyId key identifier
- * @param authDataLength authentication data length
- * @param authenticationData authentication data
- * @param mapRecords a collection of map records
- * @param proxyMapReply proxy map reply flag
- * @param wantMapNotify want map notify flag
+ * @param nonce nonce
+ * @param keyId key identifier
+ * @param authDataLength authentication data length
+ * @param authData authentication data
+ * @param mapRecords a collection of map records
+ * @param proxyMapReply proxy map reply flag
+ * @param wantMapNotify want map notify flag
*/
private DefaultLispMapRegister(long nonce, short keyId, short authDataLength,
- byte[] authenticationData, List<LispMapRecord> mapRecords,
+ byte[] authData, List<LispMapRecord> mapRecords,
boolean proxyMapReply, boolean wantMapNotify) {
this.nonce = nonce;
this.keyId = keyId;
this.authDataLength = authDataLength;
- this.authenticationData = authenticationData;
+ this.authData = authData;
this.mapRecords = mapRecords;
this.proxyMapReply = proxyMapReply;
this.wantMapNotify = wantMapNotify;
@@ -121,9 +130,9 @@
}
@Override
- public byte[] getAuthenticationData() {
- if (authenticationData != null && authenticationData.length != 0) {
- return ImmutableByteSequence.copyFrom(authenticationData).asArray();
+ public byte[] getAuthData() {
+ if (authData != null && authData.length != 0) {
+ return ImmutableByteSequence.copyFrom(authData).asArray();
} else {
return new byte[0];
}
@@ -141,7 +150,7 @@
.add("nonce", nonce)
.add("keyId", keyId)
.add("authentication data length", authDataLength)
- .add("authentication data", authenticationData)
+ .add("authentication data", authData)
.add("mapRecords", mapRecords)
.add("proxyMapReply", proxyMapReply)
.add("wantMapNotify", wantMapNotify).toString();
@@ -160,7 +169,7 @@
return Objects.equal(nonce, that.nonce) &&
Objects.equal(keyId, that.keyId) &&
Objects.equal(authDataLength, that.authDataLength) &&
- Arrays.equals(authenticationData, that.authenticationData) &&
+ Arrays.equals(authData, that.authData) &&
Objects.equal(proxyMapReply, that.proxyMapReply) &&
Objects.equal(wantMapNotify, that.wantMapNotify);
}
@@ -168,7 +177,7 @@
@Override
public int hashCode() {
return Objects.hashCode(nonce, keyId, authDataLength,
- proxyMapReply, wantMapNotify) + Arrays.hashCode(authenticationData);
+ proxyMapReply, wantMapNotify) + Arrays.hashCode(authData);
}
public static final class DefaultRegisterBuilder implements RegisterBuilder {
@@ -176,7 +185,8 @@
private long nonce;
private short keyId;
private short authDataLength;
- private byte[] authenticationData = new byte[0];
+ private byte[] authData;
+ private String authKey;
private List<LispMapRecord> mapRecords = Lists.newArrayList();
private boolean proxyMapReply;
private boolean wantMapNotify;
@@ -205,6 +215,12 @@
}
@Override
+ public RegisterBuilder withAuthKey(String key) {
+ this.authKey = key;
+ return this;
+ }
+
+ @Override
public RegisterBuilder withAuthDataLength(short authDataLength) {
this.authDataLength = authDataLength;
return this;
@@ -217,9 +233,9 @@
}
@Override
- public RegisterBuilder withAuthenticationData(byte[] authenticationData) {
+ public RegisterBuilder withAuthData(byte[] authenticationData) {
if (authenticationData != null) {
- this.authenticationData = authenticationData;
+ this.authData = authenticationData;
}
return this;
}
@@ -234,8 +250,36 @@
@Override
public LispMapRegister build() {
+
+ // if authentication data is not specified, we will calculate it
+ if (authData == null) {
+ LispAuthenticationFactory factory = LispAuthenticationFactory.getInstance();
+
+ authDataLength = LispAuthenticationKeyEnum.valueOf(keyId).getHashLength();
+ byte[] tmpAuthData = new byte[authDataLength];
+ Arrays.fill(tmpAuthData, (byte) 0);
+ authData = tmpAuthData;
+
+ ByteBuf byteBuf = Unpooled.buffer();
+ try {
+ new DefaultLispMapRegister(nonce, keyId, authDataLength, authData,
+ mapRecords, proxyMapReply, wantMapNotify).writeTo(byteBuf);
+ } catch (LispWriterException e) {
+ log.warn("Failed to serialize map register message", e);
+ }
+
+ byte[] bytes = new byte[byteBuf.readableBytes()];
+ byteBuf.readBytes(bytes);
+
+ if (authKey == null) {
+ log.warn("Must specify authentication key");
+ }
+
+ authData = factory.createAuthenticationData(valueOf(keyId), authKey, bytes);
+ }
+
return new DefaultLispMapRegister(nonce, keyId, authDataLength,
- authenticationData, mapRecords, proxyMapReply, wantMapNotify);
+ authData, mapRecords, proxyMapReply, wantMapNotify);
}
}
@@ -278,7 +322,7 @@
// authenticationDataLength -> 16 bits
short authLength = byteBuf.readShort();
- // authenticationData -> depends on the authenticationDataLength
+ // authData -> depends on the authenticationDataLength
byte[] authData = new byte[authLength];
byteBuf.readBytes(authData);
@@ -292,7 +336,7 @@
.withIsWantMapNotify(wantMapNotifyFlag)
.withNonce(nonce)
.withKeyId(keyId)
- .withAuthenticationData(authData)
+ .withAuthData(authData)
.withAuthDataLength(authLength)
.withMapRecords(mapRecords)
.build();
@@ -321,7 +365,7 @@
// proxy map reply flag
byte proxyMapReply = DISABLE_BIT;
- if (message.isProxyMapReply()) {
+ if (message.isProxyMapReply()) {
proxyMapReply = (byte) (ENABLE_BIT << PROXY_MAP_REPLY_SHIFT_BIT);
}
@@ -348,11 +392,11 @@
byteBuf.writeShort(message.getKeyId());
// authentication data and its length
- if (message.getAuthenticationData() == null) {
+ if (message.getAuthData() == null) {
byteBuf.writeShort((short) 0);
} else {
- byteBuf.writeShort(message.getAuthenticationData().length);
- byteBuf.writeBytes(message.getAuthenticationData());
+ byteBuf.writeShort(message.getAuthData().length);
+ byteBuf.writeBytes(message.getAuthData());
}
// serialize map records
diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/InfoBuilder.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/InfoBuilder.java
index 0b6f381..655eb49 100644
--- a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/InfoBuilder.java
+++ b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/InfoBuilder.java
@@ -58,10 +58,18 @@
/**
* Sets authentication data.
*
- * @param authenticationData authentication data
+ * @param authData authentication data
* @return T object
*/
- T withAuthenticationData(byte[] authenticationData);
+ T withAuthData(byte[] authData);
+
+ /**
+ * Sets authentication key.
+ *
+ * @param key authentication key
+ * @return RegisterBuilder object
+ */
+ T withAuthKey(String key);
/**
* Sets Time-To-Live value.
diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/LispInfo.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/LispInfo.java
index 1fd9b46..19fb9d0 100644
--- a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/LispInfo.java
+++ b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/LispInfo.java
@@ -27,7 +27,7 @@
*
* @return has info reply flag value
*/
- boolean hasInfoReply();
+ boolean isInfoReply();
/**
* Obtains nonce value.
@@ -55,7 +55,7 @@
*
* @return authentication data
*/
- byte[] getAuthenticationData();
+ byte[] getAuthData();
/**
* Obtains TTL value.
diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/LispMapNotify.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/LispMapNotify.java
index 4b8abca..84d16f2 100644
--- a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/LispMapNotify.java
+++ b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/LispMapNotify.java
@@ -89,7 +89,7 @@
*
* @return authentication data
*/
- byte[] getAuthenticationData();
+ byte[] getAuthData();
/**
* Obtains a collection of records.
@@ -112,7 +112,7 @@
NotifyBuilder withNonce(long nonce);
/**
- * Sets key identitifer.
+ * Sets key identifier.
*
* @param keyId key identifier
* @return NotifyBuilder object
@@ -120,6 +120,14 @@
NotifyBuilder withKeyId(short keyId);
/**
+ * Sets authentication key.
+ *
+ * @param key authentication key
+ * @return NotifyBuilder object
+ */
+ NotifyBuilder withAuthKey(String key);
+
+ /**
* Sets authentication data length.
*
* @param authDataLength authentication data length
@@ -130,10 +138,10 @@
/**
* Sets authentication data.
*
- * @param authenticationData authentication data
+ * @param authData authentication data
* @return NotifyBuilder object
*/
- NotifyBuilder withAuthenticationData(byte[] authenticationData);
+ NotifyBuilder withAuthData(byte[] authData);
/**
* Sets a collection of map records.
diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/LispMapRegister.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/LispMapRegister.java
index f5341c2..797ebd7 100644
--- a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/LispMapRegister.java
+++ b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/LispMapRegister.java
@@ -103,7 +103,7 @@
*
* @return authentication data
*/
- byte[] getAuthenticationData();
+ byte[] getAuthData();
/**
* Obtains a collection of records.
@@ -142,6 +142,14 @@
RegisterBuilder withNonce(long nonce);
/**
+ * Sets authentication key.
+ *
+ * @param key authentication key
+ * @return RegisterBuilder object
+ */
+ RegisterBuilder withAuthKey(String key);
+
+ /**
* Sets authentication data length.
*
* @param authDataLength authentication data length
@@ -160,10 +168,10 @@
/**
* Sets authentication data.
*
- * @param authenticationData authentication data
+ * @param authData authentication data
* @return RegisterBuilder object
*/
- RegisterBuilder withAuthenticationData(byte[] authenticationData);
+ RegisterBuilder withAuthData(byte[] authData);
/**
* Sets a collection of map records.
diff --git a/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/protocols/DefaultLispEncapsulatedControlTest.java b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/protocols/DefaultLispEncapsulatedControlTest.java
index fa64950..06cf2a1 100644
--- a/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/protocols/DefaultLispEncapsulatedControlTest.java
+++ b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/protocols/DefaultLispEncapsulatedControlTest.java
@@ -48,6 +48,8 @@
private static final String ECM2_DST_IP = "192.168.2.2";
private static final String RECORD_EID = "1.1.1.1";
+ private static final String AUTH_KEY = "onos";
+
private LispEncapsulatedControl ecm1;
private LispEncapsulatedControl sameAsEcm1;
private LispEncapsulatedControl ecm2;
@@ -74,6 +76,7 @@
LispMapRegister innerMsg1 = msgBuilder.withIsProxyMapReply(true)
.withIsWantMapNotify(false)
.withKeyId((short) 1)
+ .withAuthKey(AUTH_KEY)
.withNonce(1L)
.withMapRecords(records1)
.build();
@@ -103,6 +106,7 @@
LispMapRegister innerMsg2 = msgBuilder2.withIsProxyMapReply(true)
.withIsWantMapNotify(false)
.withKeyId((short) 1)
+ .withAuthKey(AUTH_KEY)
.withNonce(1L)
.withMapRecords(records2)
.build();
@@ -132,6 +136,7 @@
LispMapRegister innerMsg3 = msgBuilder3.withIsProxyMapReply(true)
.withIsWantMapNotify(false)
.withKeyId((short) 2)
+ .withAuthKey(AUTH_KEY)
.withNonce(1L)
.withMapRecords(records3)
.build();
diff --git a/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/protocols/DefaultLispInfoReplyTest.java b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/protocols/DefaultLispInfoReplyTest.java
index 1952a03..2ab8002 100644
--- a/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/protocols/DefaultLispInfoReplyTest.java
+++ b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/protocols/DefaultLispInfoReplyTest.java
@@ -43,6 +43,8 @@
private LispInfoReply sameAsReply1;
private LispInfoReply reply2;
+ private static final String AUTH_KEY = "onos";
+
@Before
public void setup() {
@@ -68,6 +70,7 @@
reply1 = builder1
.withNonce(1L)
.withKeyId((short) 1)
+ .withAuthKey(AUTH_KEY)
.withInfoReply(false)
.withMaskLength((byte) 1)
.withEidPrefix(address1)
@@ -78,6 +81,7 @@
sameAsReply1 = builder2
.withNonce(1L)
.withKeyId((short) 1)
+ .withAuthKey(AUTH_KEY)
.withInfoReply(false)
.withMaskLength((byte) 1)
.withEidPrefix(address1)
@@ -105,6 +109,7 @@
reply2 = builder3
.withNonce(2L)
.withKeyId((short) 2)
+ .withAuthKey(AUTH_KEY)
.withInfoReply(true)
.withMaskLength((byte) 1)
.withEidPrefix(address2)
@@ -139,7 +144,7 @@
.withPrivateEtrRlocAddress(privateEtrRlocAddress1)
.build();
- assertThat(reply.hasInfoReply(), is(false));
+ assertThat(reply.isInfoReply(), is(false));
assertThat(reply.getNonce(), is(1L));
assertThat(reply.getKeyId(), is((short) 1));
assertThat(reply.getMaskLength(), is((byte) 1));
diff --git a/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/protocols/DefaultLispInfoRequestTest.java b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/protocols/DefaultLispInfoRequestTest.java
index 501b82f..83b6f89 100644
--- a/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/protocols/DefaultLispInfoRequestTest.java
+++ b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/protocols/DefaultLispInfoRequestTest.java
@@ -42,6 +42,8 @@
private LispInfoRequest sameAsRequest1;
private LispInfoRequest request2;
+ private static final String AUTH_KEY = "onos";
+
@Before
public void setup() {
@@ -52,6 +54,7 @@
request1 = builder1
.withNonce(1L)
.withKeyId((short) 1)
+ .withAuthKey(AUTH_KEY)
.withInfoReply(false)
.withMaskLength((byte) 1)
.withEidPrefix(address1).build();
@@ -61,6 +64,7 @@
sameAsRequest1 = builder2
.withNonce(1L)
.withKeyId((short) 1)
+ .withAuthKey(AUTH_KEY)
.withInfoReply(false)
.withMaskLength((byte) 1)
.withEidPrefix(address1).build();
@@ -72,6 +76,7 @@
request2 = builder3
.withNonce(2L)
.withKeyId((short) 2)
+ .withAuthKey(AUTH_KEY)
.withInfoReply(true)
.withMaskLength((byte) 1)
.withEidPrefix(address2).build();
@@ -90,7 +95,7 @@
LispIpv4Address address = new LispIpv4Address(IpAddress.valueOf("192.168.1.1"));
- assertThat(request.hasInfoReply(), is(false));
+ assertThat(request.isInfoReply(), is(false));
assertThat(request.getNonce(), is(1L));
assertThat(request.getKeyId(), is((short) 1));
assertThat(request.getMaskLength(), is((byte) 1));
diff --git a/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/protocols/DefaultLispMapNotifyTest.java b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/protocols/DefaultLispMapNotifyTest.java
index aa10703..f9dd47f 100644
--- a/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/protocols/DefaultLispMapNotifyTest.java
+++ b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/protocols/DefaultLispMapNotifyTest.java
@@ -43,6 +43,7 @@
private LispMapNotify notify1;
private LispMapNotify sameAsNotify1;
private LispMapNotify notify2;
+ private static final String AUTH_KEY = "onos";
@Before
public void setup() {
@@ -53,6 +54,7 @@
notify1 = builder1
.withKeyId((short) 1)
+ .withAuthKey(AUTH_KEY)
.withNonce(1L)
.withMapRecords(records1)
.build();
@@ -63,6 +65,7 @@
sameAsNotify1 = builder2
.withKeyId((short) 1)
+ .withAuthKey(AUTH_KEY)
.withNonce(1L)
.withMapRecords(records2)
.build();
@@ -71,6 +74,7 @@
notify2 = builder3
.withKeyId((short) 2)
+ .withAuthKey(AUTH_KEY)
.withNonce(2L)
.build();
}
diff --git a/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/protocols/DefaultLispMapRegisterTest.java b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/protocols/DefaultLispMapRegisterTest.java
index ff2c104..4dd081a 100644
--- a/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/protocols/DefaultLispMapRegisterTest.java
+++ b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/protocols/DefaultLispMapRegisterTest.java
@@ -46,6 +46,7 @@
private LispMapRegister register1;
private LispMapRegister sameAsRegister1;
private LispMapRegister register2;
+ private static final String AUTH_KEY = "onos";
@Before
public void setup() {
@@ -58,6 +59,7 @@
.withIsProxyMapReply(true)
.withIsWantMapNotify(false)
.withKeyId((short) 1)
+ .withAuthKey(AUTH_KEY)
.withNonce(1L)
.withMapRecords(records1)
.build();
@@ -70,6 +72,7 @@
.withIsProxyMapReply(true)
.withIsWantMapNotify(false)
.withKeyId((short) 1)
+ .withAuthKey(AUTH_KEY)
.withNonce(1L)
.withMapRecords(records2)
.build();
@@ -80,6 +83,7 @@
.withIsProxyMapReply(true)
.withIsWantMapNotify(false)
.withKeyId((short) 2)
+ .withAuthKey(AUTH_KEY)
.withNonce(2L)
.build();
}