Skip to content

Commit

Permalink
Fixed checkstyle EnforceFinalFieldsCheck violations in KeyVault class…
Browse files Browse the repository at this point in the history
…es (#13323)

* Addressed checkstyle violations.

* Removed checkstyle `EnforceFinalFieldsCheck` suppressions for KeyVault classes.

* Removed unused import on CreateEcKeyOptions.
  • Loading branch information
vcolin7 authored Jul 20, 2020
1 parent 8355cc5 commit 046a27f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 30 deletions.
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

0 comments on commit 046a27f

Please sign in to comment.