public final class PrincipalSerializer extends Object
| Modifier and Type | Method and Description |
|---|---|
static Principal |
deserialize(org.eclipse.californium.elements.util.DatagramReader reader)
Deserializes a principal from its byte array representation.
|
static void |
serialize(Principal principal,
org.eclipse.californium.elements.util.DatagramWriter writer)
Serializes a principal to a byte array based on the plain text encoding defined in
RFC 5077, Section 4.
|
public static void serialize(Principal principal, org.eclipse.californium.elements.util.DatagramWriter writer)
RFC 5077 does not explicitly define support for RawPublicKey based client authentication. However, it supports the addition of arbitrary authentication mechanisms by extending the ClientAuthenticationType which we do as follows:
enum {
anonymous(0),
certificate_based(1),
psk(2),
raw_public_key(255)
} ClientAuthenticationType
struct {
ClientAuthenticationType client_authentication_type;
select (ClientAuthenticationType) {
case anonymous:
struct {};
case psk:
opaque psk_identity<0..2^16-1>;
case certificate_based:
DER ASN.1Cert certificate_list<0..2^24-1>;
case raw_public_key:
DER ASN.1_subjectPublicKeyInfo<1..2^24-1>; // as defined in RFC 7250
};
}
psk_identity may be scoped by server name indication. To distinguish
scoped and plain psk_identity, the first byte in the opaque psk_identity
indicates a scoped identity with 1, or a plain identity with 0.principal - The principal to serialize.writer - The writer to serialize to.NullPointerException - if the writer is null.public static Principal deserialize(org.eclipse.californium.elements.util.DatagramReader reader) throws GeneralSecurityException
reader - The reader containing the byte array.null if the reader does not contain a supported principal type.GeneralSecurityException - if the reader contains a raw public key principal that could not be recreated.IllegalArgumentException - if the reader contains an unsupported ClientAuthenticationType.Copyright © 2023 Eclipse Foundation. All rights reserved.