Class Crypto_SignedObject
- All Implemented Interfaces:
Serializable
The class can hold either a raw SignedObject (JavaSer mode) or the
plain fields content, signature, algorithm (ProtoBuf
/ byte-oriented modes). The generated protocol code always uses this class
regardless of the serialiser, and the library methods that consume/produce
Crypto_SignedObject select the correct internal representation
automatically.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCrypto_SignedObject(byte[] content, byte[] signature, String algorithm) Creates an instance from raw fields (ProtoBufNew / byte-oriented mode).Creates an instance from the Protobuf message wrapper.Creates an instance from an existingSignedObject(JavaSer mode). -
Method Summary
Modifier and TypeMethodDescriptionbooleanstatic Crypto_SignedObjectReconstructs aCrypto_SignedObjectfrom a ProtobufAnBx_WireFormats.SignedMessage.Returns the signature algorithm name.byte[]Returns a copy of the signed content bytes.byte[]Returns a copy of the raw signature bytes.Returns the originalSignedObjectif this instance was created from one (JavaSer mode), otherwisenull.inthashCode()byte[]Produces a deterministic byte array representation of this signed object.Converts aCrypto_SignedObjectto its ProtobufAnBx_WireFormats.SignedMessagerepresentation.Converts this container to a Protobuf-compatibleAnBx_WireFormats.SignedMessage.Reconstructs aSignedObjectfrom this container.toString()
-
Constructor Details
-
Crypto_SignedObject
Creates an instance from raw fields (ProtoBufNew / byte-oriented mode).The internal
SignedObjectis set tonull. All three fields are cloned to ensure immutability.- Parameters:
content- the serialised content that was signed (must not benull)signature- the raw signature bytes (must not benull)algorithm- the signature algorithm name, e.g."SHA256withRSA"(must not benull)- Throws:
NullPointerException- if any argument isnull
-
Crypto_SignedObject
Creates an instance from an existingSignedObject(JavaSer mode).The raw fields are extracted immediately via
Crypto_SerializationUtils.serialize(Object)andSignedObject.getSignature()/SignedObject.getAlgorithm(). The originalSignedObjectis retained for possible later conversion back to a realSignedObjectif needed by the JavaSer verification path.- Parameters:
so- the signed object to wrap (must not benull)- Throws:
AnBx_LibraryException- if extraction of the inner object, signature, or algorithm failsNullPointerException- ifsoisnull
-
Crypto_SignedObject
Creates an instance from the Protobuf message wrapper.This constructor is used by the typed-Protobuf serializer to reconstruct a
Crypto_SignedObjectfrom the fields of aAnBx_WireFormats.SignedMessage.- Parameters:
sm- the protobuf message wrapper (must not benull)- Throws:
NullPointerException- ifsmisnull
-
-
Method Details
-
getContent
public byte[] getContent()Returns a copy of the signed content bytes.The returned array is a fresh clone - modifications to it will not affect the internal state of this object.
- Returns:
- the serialised content that was signed (never
null)
-
getSignature
public byte[] getSignature()Returns a copy of the raw signature bytes.The returned array is a fresh clone - modifications to it will not affect the internal state of this object.
- Returns:
- the signature bytes (never
null)
-
getAlgorithm
Returns the signature algorithm name.Example values are
"SHA256withRSA","SHA256withECDSA", etc.- Returns:
- the algorithm name (never
null)
-
getSignedObject
Returns the originalSignedObjectif this instance was created from one (JavaSer mode), otherwisenull.This allows the verification path to use the legacy
SignedObjectdirectly when available, avoiding an expensive reconstruction.- Returns:
- the original
SignedObject, ornullif the instance was created from raw fields (ProtoBuf / byte-oriented modes)
-
toSignedMessage
Converts this container to a Protobuf-compatibleAnBx_WireFormats.SignedMessage.The returned message holds the same
content,signatureandalgorithmas this object, and can be used directly by the typed Protobuf serialiser.- Returns:
- a new
SignedMessage(nevernull)
-
toSignedObject
Reconstructs aSignedObjectfrom this container.This is only possible if the instance was originally created from a real
SignedObject(JavaSer mode). In that case the original object is returned directly. If the instance was built from raw signature bytes (ProtoBuf / byte-oriented mode), the conversion cannot be performed and anUnsupportedOperationExceptionis thrown.- Returns:
- the original
SignedObject - Throws:
UnsupportedOperationException- if the instance was not built from a realSignedObject(i.e.getSignedObject()returnsnull)
-
toByteArray
public byte[] toByteArray()Produces a deterministic byte array representation of this signed object.The binary layout is identical to that produced by
AnBx_WireFormats.SignedMessage.toByteArray(). This method is intended for use in Protobuf / byte-oriented serialisation modes where a canonical, language-agnostic format is required.- Returns:
- the serialised bytes (never
null) - See Also:
-
toProtobufSigned
Converts aCrypto_SignedObjectto its ProtobufAnBx_WireFormats.SignedMessagerepresentation.- Parameters:
obj- the signed object to convert- Returns:
- the corresponding
SignedMessage
-
fromProtobufSigned
Reconstructs aCrypto_SignedObjectfrom a ProtobufAnBx_WireFormats.SignedMessage.- Parameters:
msg- the Protobuf message- Returns:
- the reconstructed container
-
equals
-
hashCode
public int hashCode() -
toString
-