mirror of
https://github.com/nsacyber/HIRS.git
synced 2024-12-30 09:49:00 +00:00
[#401] Changed instanceof check and error message.
This commit is contained in:
parent
e5470eded5
commit
e8085aae0f
@ -5,6 +5,8 @@ import org.bouncycastle.asn1.DERBitString;
|
|||||||
import org.bouncycastle.asn1.DERIA5String;
|
import org.bouncycastle.asn1.DERIA5String;
|
||||||
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
|
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Basic class that handle a URIReference object.
|
* Basic class that handle a URIReference object.
|
||||||
@ -19,6 +21,7 @@ import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
|
|||||||
public class URIReference {
|
public class URIReference {
|
||||||
private DERIA5String uniformResourceIdentifier;
|
private DERIA5String uniformResourceIdentifier;
|
||||||
private AlgorithmIdentifier hashAlgorithm;
|
private AlgorithmIdentifier hashAlgorithm;
|
||||||
|
@JsonIgnore
|
||||||
private DERBitString hashValue;
|
private DERBitString hashValue;
|
||||||
|
|
||||||
private static final int PLATFORM_PROPERTIES_URI_MAX = 3;
|
private static final int PLATFORM_PROPERTIES_URI_MAX = 3;
|
||||||
@ -66,13 +69,15 @@ public class URIReference {
|
|||||||
for (int j = 0; j < sequence.size(); j++) {
|
for (int j = 0; j < sequence.size(); j++) {
|
||||||
if (sequence.getObjectAt(j) instanceof DERIA5String) {
|
if (sequence.getObjectAt(j) instanceof DERIA5String) {
|
||||||
this.uniformResourceIdentifier = DERIA5String.getInstance(sequence.getObjectAt(j));
|
this.uniformResourceIdentifier = DERIA5String.getInstance(sequence.getObjectAt(j));
|
||||||
} else if (sequence.getObjectAt(j) instanceof AlgorithmIdentifier) {
|
} else if ((sequence.getObjectAt(j) instanceof AlgorithmIdentifier)
|
||||||
|
|| (sequence.getObjectAt(j) instanceof ASN1Sequence)) {
|
||||||
this.hashAlgorithm =
|
this.hashAlgorithm =
|
||||||
AlgorithmIdentifier.getInstance(sequence.getObjectAt(j));
|
AlgorithmIdentifier.getInstance(sequence.getObjectAt(j));
|
||||||
} else if (sequence.getObjectAt(j) instanceof DERBitString) {
|
} else if (sequence.getObjectAt(j) instanceof DERBitString) {
|
||||||
this.hashValue = DERBitString.getInstance(sequence.getObjectAt(j));
|
this.hashValue = DERBitString.getInstance(sequence.getObjectAt(j));
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("PlatformPropertiesURI contains invalid type.");
|
throw new IllegalArgumentException("Unexpected DER type found. "
|
||||||
|
+ sequence.getObjectAt(j).getClass().getName() + " found at index " + j + ".");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user