|
| 1 | +// Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | +// Licensed under the MIT License. |
| 3 | +// Code generated by Microsoft (R) TypeSpec Code Generator. |
| 4 | + |
| 5 | +package com.azure.security.keyvault.keys.implementation.models; |
| 6 | + |
| 7 | +import com.azure.core.annotation.Generated; |
| 8 | +import com.azure.core.annotation.Immutable; |
| 9 | +import com.azure.core.util.Base64Url; |
| 10 | +import com.azure.json.JsonReader; |
| 11 | +import com.azure.json.JsonSerializable; |
| 12 | +import com.azure.json.JsonToken; |
| 13 | +import com.azure.json.JsonWriter; |
| 14 | +import java.io.IOException; |
| 15 | +import java.util.Objects; |
| 16 | + |
| 17 | +/** |
| 18 | + * The key attestation information. |
| 19 | + */ |
| 20 | +@Immutable |
| 21 | +public final class KeyAttestation implements JsonSerializable<KeyAttestation> { |
| 22 | + /* |
| 23 | + * A base64url-encoded string containing certificates in PEM format, used for attestation validation. |
| 24 | + */ |
| 25 | + @Generated |
| 26 | + private Base64Url certificatePemFile; |
| 27 | + |
| 28 | + /* |
| 29 | + * The attestation blob bytes encoded as base64url string corresponding to a private key. |
| 30 | + */ |
| 31 | + @Generated |
| 32 | + private Base64Url privateKeyAttestation; |
| 33 | + |
| 34 | + /* |
| 35 | + * The attestation blob bytes encoded as base64url string corresponding to a public key in case of asymmetric key. |
| 36 | + */ |
| 37 | + @Generated |
| 38 | + private Base64Url publicKeyAttestation; |
| 39 | + |
| 40 | + /* |
| 41 | + * The version of the attestation. |
| 42 | + */ |
| 43 | + @Generated |
| 44 | + private String version; |
| 45 | + |
| 46 | + /** |
| 47 | + * Creates an instance of KeyAttestation class. |
| 48 | + */ |
| 49 | + @Generated |
| 50 | + private KeyAttestation() { |
| 51 | + } |
| 52 | + |
| 53 | + /** |
| 54 | + * Get the certificatePemFile property: A base64url-encoded string containing certificates in PEM format, used for |
| 55 | + * attestation validation. |
| 56 | + * |
| 57 | + * @return the certificatePemFile value. |
| 58 | + */ |
| 59 | + @Generated |
| 60 | + public byte[] getCertificatePemFile() { |
| 61 | + if (this.certificatePemFile == null) { |
| 62 | + return null; |
| 63 | + } |
| 64 | + return this.certificatePemFile.decodedBytes(); |
| 65 | + } |
| 66 | + |
| 67 | + /** |
| 68 | + * Get the privateKeyAttestation property: The attestation blob bytes encoded as base64url string corresponding to a |
| 69 | + * private key. |
| 70 | + * |
| 71 | + * @return the privateKeyAttestation value. |
| 72 | + */ |
| 73 | + @Generated |
| 74 | + public byte[] getPrivateKeyAttestation() { |
| 75 | + if (this.privateKeyAttestation == null) { |
| 76 | + return null; |
| 77 | + } |
| 78 | + return this.privateKeyAttestation.decodedBytes(); |
| 79 | + } |
| 80 | + |
| 81 | + /** |
| 82 | + * Get the publicKeyAttestation property: The attestation blob bytes encoded as base64url string corresponding to a |
| 83 | + * public key in case of asymmetric key. |
| 84 | + * |
| 85 | + * @return the publicKeyAttestation value. |
| 86 | + */ |
| 87 | + @Generated |
| 88 | + public byte[] getPublicKeyAttestation() { |
| 89 | + if (this.publicKeyAttestation == null) { |
| 90 | + return null; |
| 91 | + } |
| 92 | + return this.publicKeyAttestation.decodedBytes(); |
| 93 | + } |
| 94 | + |
| 95 | + /** |
| 96 | + * Get the version property: The version of the attestation. |
| 97 | + * |
| 98 | + * @return the version value. |
| 99 | + */ |
| 100 | + @Generated |
| 101 | + public String getVersion() { |
| 102 | + return this.version; |
| 103 | + } |
| 104 | + |
| 105 | + /** |
| 106 | + * {@inheritDoc} |
| 107 | + */ |
| 108 | + @Generated |
| 109 | + @Override |
| 110 | + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { |
| 111 | + jsonWriter.writeStartObject(); |
| 112 | + jsonWriter.writeStringField("certificatePemFile", Objects.toString(this.certificatePemFile, null)); |
| 113 | + jsonWriter.writeStringField("privateKeyAttestation", Objects.toString(this.privateKeyAttestation, null)); |
| 114 | + jsonWriter.writeStringField("publicKeyAttestation", Objects.toString(this.publicKeyAttestation, null)); |
| 115 | + jsonWriter.writeStringField("version", this.version); |
| 116 | + return jsonWriter.writeEndObject(); |
| 117 | + } |
| 118 | + |
| 119 | + /** |
| 120 | + * Reads an instance of KeyAttestation from the JsonReader. |
| 121 | + * |
| 122 | + * @param jsonReader The JsonReader being read. |
| 123 | + * @return An instance of KeyAttestation if the JsonReader was pointing to an instance of it, or null if it was |
| 124 | + * pointing to JSON null. |
| 125 | + * @throws IOException If an error occurs while reading the KeyAttestation. |
| 126 | + */ |
| 127 | + @Generated |
| 128 | + public static KeyAttestation fromJson(JsonReader jsonReader) throws IOException { |
| 129 | + return jsonReader.readObject(reader -> { |
| 130 | + KeyAttestation deserializedKeyAttestation = new KeyAttestation(); |
| 131 | + while (reader.nextToken() != JsonToken.END_OBJECT) { |
| 132 | + String fieldName = reader.getFieldName(); |
| 133 | + reader.nextToken(); |
| 134 | + |
| 135 | + if ("certificatePemFile".equals(fieldName)) { |
| 136 | + deserializedKeyAttestation.certificatePemFile |
| 137 | + = reader.getNullable(nonNullReader -> new Base64Url(nonNullReader.getString())); |
| 138 | + } else if ("privateKeyAttestation".equals(fieldName)) { |
| 139 | + deserializedKeyAttestation.privateKeyAttestation |
| 140 | + = reader.getNullable(nonNullReader -> new Base64Url(nonNullReader.getString())); |
| 141 | + } else if ("publicKeyAttestation".equals(fieldName)) { |
| 142 | + deserializedKeyAttestation.publicKeyAttestation |
| 143 | + = reader.getNullable(nonNullReader -> new Base64Url(nonNullReader.getString())); |
| 144 | + } else if ("version".equals(fieldName)) { |
| 145 | + deserializedKeyAttestation.version = reader.getString(); |
| 146 | + } else { |
| 147 | + reader.skipChildren(); |
| 148 | + } |
| 149 | + } |
| 150 | + |
| 151 | + return deserializedKeyAttestation; |
| 152 | + }); |
| 153 | + } |
| 154 | +} |
0 commit comments