Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Implement manual layer on top of CMEK protos
Change-Id: Ia0979264f3c3f5f7e997011f0a9944f993719908 fix: cmek verify fixes - ignore method additions to protobufs, external users dont implement them - add missing copyright header Change-Id: I2330400c144ce80e05ff1af3e5dc031f8a21aa37 Verify and update integration test Change-Id: I605ae5d202e90a68f0db58506b36bcae3adf1072
- Loading branch information
Showing
21 changed files
with
953 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
...loud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/EncryptionInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
/* | ||
* Copyright 2020 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.google.cloud.bigtable.admin.v2.models; | ||
|
||
import com.google.api.core.BetaApi; | ||
import com.google.bigtable.admin.v2.EncryptionInfo.EncryptionType; | ||
import com.google.cloud.bigtable.common.Status; | ||
import com.google.common.base.Objects; | ||
|
||
/** | ||
* Encryption information for a given resource. | ||
* | ||
* <p>If this resource is protected with customer managed encryption, the in-use Google Cloud Key | ||
* Management Service (KMS) key versions will be specified along with their status. | ||
* | ||
* <p>CMEK is not currently available to end users. This feature might be changed in | ||
* backward-incompatible ways and is not currently subject to any SLA or deprecation policy. | ||
*/ | ||
@BetaApi("CMEK is not yet stable and might change in the future") | ||
public final class EncryptionInfo { | ||
public enum Type { | ||
/** Encryption type was not specified, though data at rest remains encrypted. */ | ||
ENCRYPTION_TYPE_UNSPECIFIED( | ||
com.google.bigtable.admin.v2.EncryptionInfo.EncryptionType.ENCRYPTION_TYPE_UNSPECIFIED), | ||
/** | ||
* The data backing this resource is encrypted at rest with a key that is fully managed by | ||
* Google. No key version or status will be populated. | ||
*/ | ||
GOOGLE_DEFAULT_ENCRYPTION( | ||
com.google.bigtable.admin.v2.EncryptionInfo.EncryptionType.GOOGLE_DEFAULT_ENCRYPTION), | ||
/** | ||
* The data backing this resource is encrypted at rest with a key that is fully managed by | ||
* Google. No key version or status will be populated. This is the default state. | ||
*/ | ||
CUSTOMER_MANAGED_ENCRYPTION( | ||
com.google.bigtable.admin.v2.EncryptionInfo.EncryptionType.CUSTOMER_MANAGED_ENCRYPTION), | ||
/** Type not known by the client, please upgrade your client */ | ||
UNRECOGNIZED(com.google.bigtable.admin.v2.EncryptionInfo.EncryptionType.UNRECOGNIZED); | ||
|
||
private final com.google.bigtable.admin.v2.EncryptionInfo.EncryptionType proto; | ||
|
||
Type(EncryptionType proto) { | ||
this.proto = proto; | ||
} | ||
|
||
/** Wraps the EncryptionInfo protobuf. */ | ||
public static Type fromProto(com.google.bigtable.admin.v2.EncryptionInfo.EncryptionType proto) { | ||
for (Type type : values()) { | ||
if (Objects.equal(type.proto, proto)) { | ||
return type; | ||
} | ||
} | ||
return UNRECOGNIZED; | ||
} | ||
} | ||
|
||
private com.google.bigtable.admin.v2.EncryptionInfo proto; | ||
|
||
public static EncryptionInfo fromProto(com.google.bigtable.admin.v2.EncryptionInfo proto) { | ||
return new EncryptionInfo(proto); | ||
} | ||
|
||
private EncryptionInfo(com.google.bigtable.admin.v2.EncryptionInfo proto) { | ||
this.proto = proto; | ||
} | ||
|
||
public Type getType() { | ||
return EncryptionInfo.Type.fromProto(proto.getEncryptionType()); | ||
} | ||
|
||
public String getKmsKeyVersion() { | ||
return proto.getKmsKeyVersion(); | ||
} | ||
|
||
public Status getStatus() { | ||
return Status.fromProto(proto.getEncryptionStatus()); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
EncryptionInfo that = (EncryptionInfo) o; | ||
return Objects.equal(proto, that.proto); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hashCode(proto); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return proto.toString(); | ||
} | ||
} |
Oops, something went wrong.