Defend against null privateKey object when delegating accessors
package com.quorum.tessera.config;
import com.quorum.tessera.config.adapters.PrivateKeyTypeAdapter;
+import java.util.Optional;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlAccessType;
@@ -41,27 +42,39 @@ public class KeyDataConfig {
}
public String getValue() {
- return privateKeyData.getValue();
+ return Optional.ofNullable(privateKeyData)
+ .map(PrivateKeyData::getValue)
+ .orElse(null);
}
public String getSnonce() {
- return privateKeyData.getSnonce();
+ return Optional.ofNullable(privateKeyData)
+ .map(PrivateKeyData::getSnonce)
+ .orElse(null);
}
public String getAsalt() {
- return privateKeyData.getAsalt();
+ return Optional.ofNullable(privateKeyData)
+ .map(PrivateKeyData::getAsalt)
+ .orElse(null);
}
public String getSbox() {
- return privateKeyData.getSbox();
+ return Optional.ofNullable(privateKeyData)
+ .map(PrivateKeyData::getSbox)
+ .orElse(null);
}
public ArgonOptions getArgonOptions() {
- return privateKeyData.getArgonOptions();
+ return Optional.ofNullable(privateKeyData)
+ .map(PrivateKeyData::getArgonOptions)
+ .orElse(null);
}
public String getPassword() {
- return privateKeyData.getPassword();
+ return Optional.ofNullable(privateKeyData)
+ .map(PrivateKeyData::getPassword)
+ .orElse(null);
}
}
