Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed checkstyle EnforceFinalFieldsCheck violations in KeyVault classes #13323

Merged
merged 3 commits into from
Jul 20, 2020
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@

<!-- Remove this after fixing: https://github.com/Azure/azure-sdk-for-java/issues/5030 -->
<suppress checks="com.azure.tools.checkstyle.checks.EnforceFinalFieldsCheck" files=".*CredentialBuilderBase.java"/>
<suppress checks="com.azure.tools.checkstyle.checks.EnforceFinalFieldsCheck" files=".*CreateKeyOptions.java"/>
<suppress checks="com.azure.tools.checkstyle.checks.EnforceFinalFieldsCheck"
files=".*LocalKeyCryptographyClient.java"/>
<suppress checks="com.azure.tools.checkstyle.checks.EnforceFinalFieldsCheck" files=".*SearchIndexClientBuilder.java"/>
<suppress checks="com.azure.tools.checkstyle.checks.EnforceFinalFieldsCheck"
files=".*SearchServiceClientBuilder.java"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import reactor.core.publisher.Mono;

abstract class LocalKeyCryptographyClient {
CryptographyServiceClient serviceClient;
final CryptographyServiceClient serviceClient;

LocalKeyCryptographyClient(CryptographyServiceClient serviceClient) {
this.serviceClient = serviceClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.azure.core.annotation.Fluent;

import java.time.OffsetDateTime;
import java.util.Arrays;
import java.util.Map;

/**
Expand All @@ -30,8 +29,7 @@ public class CreateEcKeyOptions extends CreateKeyOptions {
* @param name The name of the Ec key.
*/
public CreateEcKeyOptions(String name) {
super.name = name;
this.keyType = KeyType.EC;
super(name, KeyType.EC);
}

/**
Expand Down Expand Up @@ -62,7 +60,7 @@ public CreateEcKeyOptions setCurveName(KeyCurveName curveName) {
*/
@Override
public CreateEcKeyOptions setKeyOperations(KeyOperation... keyOperations) {
this.keyOperations = Arrays.asList(keyOperations);
super.setKeyOperations(keyOperations);
return this;
}

Expand Down Expand Up @@ -121,7 +119,8 @@ public CreateEcKeyOptions setEnabled(Boolean enabled) {
*/
public CreateEcKeyOptions setHardwareProtected(Boolean hardwareProtected) {
this.hardwareProtected = hardwareProtected;
this.keyType = hardwareProtected ? KeyType.EC_HSM : KeyType.EC;
KeyType keyType = hardwareProtected ? KeyType.EC_HSM : KeyType.EC;
setKeyType(keyType);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,20 @@
*/
@Fluent
public class CreateKeyOptions {
/**
* The key name.
*/
private final String name;

/**
* Determines whether the object is enabled.
* The type of the key.
*/
private Boolean enabled;
private KeyType keyType;

/**
* The key operations.
*/
private List<KeyOperation> keyOperations;

/**
* Not before date in UTC.
Expand All @@ -37,21 +46,9 @@ public class CreateKeyOptions {
private Map<String, String> tags;

/**
* The type of the key.
*/
KeyType keyType;

/**
* The key operations.
*/
List<KeyOperation> keyOperations;

/**
* The key name.
* Determines whether the object is enabled.
*/
String name;

CreateKeyOptions() { }
private Boolean enabled;

/**
* Creates instance of KeyCreateOptions with {@code name} as key name and {@code keyType} as type of the key.
Expand Down Expand Up @@ -92,6 +89,10 @@ public KeyType getKeyType() {
return this.keyType;
}

void setKeyType(KeyType keyType) {
this.keyType = keyType;
}

/**
* Set the {@link OffsetDateTime notBefore} UTC time.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.azure.core.annotation.Fluent;

import java.time.OffsetDateTime;
import java.util.Arrays;
import java.util.Map;

/**
Expand All @@ -30,8 +29,7 @@ public class CreateRsaKeyOptions extends CreateKeyOptions {
* @param name The name of the key.
*/
public CreateRsaKeyOptions(String name) {
super.name = name;
this.keyType = KeyType.RSA;
super(name, KeyType.RSA);
}

/**
Expand Down Expand Up @@ -62,7 +60,7 @@ public CreateRsaKeyOptions setKeySize(Integer keySize) {
*/
@Override
public CreateRsaKeyOptions setKeyOperations(KeyOperation... keyOperations) {
this.keyOperations = Arrays.asList(keyOperations);
super.setKeyOperations(keyOperations);
return this;
}

Expand Down Expand Up @@ -120,7 +118,8 @@ public CreateRsaKeyOptions setEnabled(Boolean enabled) {
*/
public CreateRsaKeyOptions setHardwareProtected(Boolean hardwareProtected) {
this.hardwareProtected = hardwareProtected;
this.keyType = hardwareProtected ? KeyType.RSA_HSM : KeyType.RSA;
KeyType keyType = hardwareProtected ? KeyType.RSA_HSM : KeyType.RSA;
setKeyType(keyType);
return this;
}

Expand Down