Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
469 changes: 465 additions & 4 deletions sdk/keyvault/azure-security-keyvault-keys/CHANGELOG.md

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,22 @@ public static JsonWebKeySignatureAlgorithm fromString(String name) {
public static Collection<JsonWebKeySignatureAlgorithm> values() {
return values(JsonWebKeySignatureAlgorithm.class);
}

/**
* HMAC using SHA-256, as described in https://tools.ietf.org/html/rfc7518.
*/
@Generated
public static final JsonWebKeySignatureAlgorithm HS256 = fromString("HS256");

/**
* HMAC using SHA-384, as described in https://tools.ietf.org/html/rfc7518.
*/
@Generated
public static final JsonWebKeySignatureAlgorithm HS384 = fromString("HS384");

/**
* HMAC using SHA-512, as described in https://tools.ietf.org/html/rfc7518.
*/
@Generated
public static final JsonWebKeySignatureAlgorithm HS512 = fromString("HS512");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) TypeSpec Code Generator.

package com.azure.security.keyvault.keys.implementation.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.annotation.Generated;
import com.azure.core.util.Base64Url;
import com.azure.core.util.CoreUtils;
import com.azure.json.JsonReader;
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;
import java.util.Objects;

/**
* The key attestation information.
*/
@Fluent
public final class KeyAttestation implements JsonSerializable<KeyAttestation> {
/*
* A base64url-encoded string containing certificates in PEM format, used for attestation validation.
*/
@Generated
private Base64Url certificatePemFile;

/*
* The attestation blob bytes encoded as base64url string corresponding to a private key.
*/
@Generated
private Base64Url privateKeyAttestation;

/*
* The attestation blob bytes encoded as base64url string corresponding to a public key in case of asymmetric key.
*/
@Generated
private Base64Url publicKeyAttestation;

/*
* The version of the attestation.
*/
@Generated
private String version;

/**
* Creates an instance of KeyAttestation class.
*/
@Generated
public KeyAttestation() {
}

/**
* Get the certificatePemFile property: A base64url-encoded string containing certificates in PEM format, used for
* attestation validation.
*
* @return the certificatePemFile value.
*/
@Generated
public byte[] getCertificatePemFile() {
if (this.certificatePemFile == null) {
return null;
}
return this.certificatePemFile.decodedBytes();
}

/**
* Set the certificatePemFile property: A base64url-encoded string containing certificates in PEM format, used for
* attestation validation.
*
* @param certificatePemFile the certificatePemFile value to set.
* @return the KeyAttestation object itself.
*/
@Generated
public KeyAttestation setCertificatePemFile(byte[] certificatePemFile) {
if (certificatePemFile == null) {
this.certificatePemFile = null;
} else {
this.certificatePemFile = Base64Url.encode(CoreUtils.clone(certificatePemFile));
}
return this;
}

/**
* Get the privateKeyAttestation property: The attestation blob bytes encoded as base64url string corresponding to a
* private key.
*
* @return the privateKeyAttestation value.
*/
@Generated
public byte[] getPrivateKeyAttestation() {
if (this.privateKeyAttestation == null) {
return null;
}
return this.privateKeyAttestation.decodedBytes();
}

/**
* Set the privateKeyAttestation property: The attestation blob bytes encoded as base64url string corresponding to a
* private key.
*
* @param privateKeyAttestation the privateKeyAttestation value to set.
* @return the KeyAttestation object itself.
*/
@Generated
public KeyAttestation setPrivateKeyAttestation(byte[] privateKeyAttestation) {
if (privateKeyAttestation == null) {
this.privateKeyAttestation = null;
} else {
this.privateKeyAttestation = Base64Url.encode(CoreUtils.clone(privateKeyAttestation));
}
return this;
}

/**
* Get the publicKeyAttestation property: The attestation blob bytes encoded as base64url string corresponding to a
* public key in case of asymmetric key.
*
* @return the publicKeyAttestation value.
*/
@Generated
public byte[] getPublicKeyAttestation() {
if (this.publicKeyAttestation == null) {
return null;
}
return this.publicKeyAttestation.decodedBytes();
}

/**
* Set the publicKeyAttestation property: The attestation blob bytes encoded as base64url string corresponding to a
* public key in case of asymmetric key.
*
* @param publicKeyAttestation the publicKeyAttestation value to set.
* @return the KeyAttestation object itself.
*/
@Generated
public KeyAttestation setPublicKeyAttestation(byte[] publicKeyAttestation) {
if (publicKeyAttestation == null) {
this.publicKeyAttestation = null;
} else {
this.publicKeyAttestation = Base64Url.encode(CoreUtils.clone(publicKeyAttestation));
}
return this;
}

/**
* Get the version property: The version of the attestation.
*
* @return the version value.
*/
@Generated
public String getVersion() {
return this.version;
}

/**
* Set the version property: The version of the attestation.
*
* @param version the version value to set.
* @return the KeyAttestation object itself.
*/
@Generated
public KeyAttestation setVersion(String version) {
this.version = version;
return this;
}

/**
* {@inheritDoc}
*/
@Generated
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("certificatePemFile", Objects.toString(this.certificatePemFile, null));
jsonWriter.writeStringField("privateKeyAttestation", Objects.toString(this.privateKeyAttestation, null));
jsonWriter.writeStringField("publicKeyAttestation", Objects.toString(this.publicKeyAttestation, null));
jsonWriter.writeStringField("version", this.version);
return jsonWriter.writeEndObject();
}

/**
* Reads an instance of KeyAttestation from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of KeyAttestation if the JsonReader was pointing to an instance of it, or null if it was
* pointing to JSON null.
* @throws IOException If an error occurs while reading the KeyAttestation.
*/
@Generated
public static KeyAttestation fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
KeyAttestation deserializedKeyAttestation = new KeyAttestation();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();

if ("certificatePemFile".equals(fieldName)) {
deserializedKeyAttestation.certificatePemFile
= reader.getNullable(nonNullReader -> new Base64Url(nonNullReader.getString()));
} else if ("privateKeyAttestation".equals(fieldName)) {
deserializedKeyAttestation.privateKeyAttestation
= reader.getNullable(nonNullReader -> new Base64Url(nonNullReader.getString()));
} else if ("publicKeyAttestation".equals(fieldName)) {
deserializedKeyAttestation.publicKeyAttestation
= reader.getNullable(nonNullReader -> new Base64Url(nonNullReader.getString()));
} else if ("version".equals(fieldName)) {
deserializedKeyAttestation.version = reader.getString();
} else {
reader.skipChildren();
}
}

return deserializedKeyAttestation;
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeNumberField("nbf", this.notBefore);
jsonWriter.writeNumberField("exp", this.expires);
jsonWriter.writeBooleanField("exportable", this.exportable);
jsonWriter.writeJsonField("attestation", this.attestation);
return jsonWriter.writeEndObject();
}

Expand Down Expand Up @@ -294,11 +295,41 @@ public static KeyAttributes fromJson(JsonReader jsonReader) throws IOException {
deserializedKeyAttributes.exportable = reader.getNullable(JsonReader::getBoolean);
} else if ("hsmPlatform".equals(fieldName)) {
deserializedKeyAttributes.hsmPlatform = reader.getString();
} else if ("attestation".equals(fieldName)) {
deserializedKeyAttributes.attestation = KeyAttestation.fromJson(reader);
} else {
reader.skipChildren();
}
}
return deserializedKeyAttributes;
});
}

/*
* The key or key version attestation information.
*/
@Generated
private KeyAttestation attestation;

/**
* Get the attestation property: The key or key version attestation information.
*
* @return the attestation value.
*/
@Generated
public KeyAttestation getAttestation() {
return this.attestation;
}

/**
* Set the attestation property: The key or key version attestation information.
*
* @param attestation the attestation value to set.
* @return the KeyAttributes object itself.
*/
@Generated
public KeyAttributes setAttestation(KeyAttestation attestation) {
this.attestation = attestation;
return this;
}
}
7 changes: 3 additions & 4 deletions sdk/keyvault/azure-security-keyvault-keys/tsp-location.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
directory: specification/keyvault/Security.KeyVault.Keys
commit: a0eb4f02951e8b7dd80e72e108b9cf7618718bc9
commit: e5eca2279ea7f0cf8c93e7c543ffc033a18e5f7f
repo: Azure/azure-rest-api-specs
cleanup: true
additionalDirectories:
- specification/keyvault/Security.KeyVault.Common/
additionalDirectories:
- specification/keyvault/Security.KeyVault.Common