Skip to content

Commit 43bbbef

Browse files
committed
fixup
1 parent 3a2ee8a commit 43bbbef

11 files changed

Lines changed: 201 additions & 120 deletions

File tree

api/src/main/java/org/apache/cloudstack/api/command/user/kms/UpdateKMSKeyCmd.java

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,14 @@
1919

2020
package org.apache.cloudstack.api.command.user.kms;
2121

22-
import com.cloud.event.EventTypes;
2322
import org.apache.cloudstack.acl.RoleType;
2423
import org.apache.cloudstack.api.APICommand;
2524
import org.apache.cloudstack.api.ApiCommandResourceType;
2625
import org.apache.cloudstack.api.ApiConstants;
2726
import org.apache.cloudstack.api.ApiErrorCode;
28-
import org.apache.cloudstack.api.BaseAsyncCmd;
27+
import org.apache.cloudstack.api.BaseCmd;
2928
import org.apache.cloudstack.api.Parameter;
3029
import org.apache.cloudstack.api.ServerApiException;
31-
import org.apache.cloudstack.api.command.user.UserCmd;
3230
import org.apache.cloudstack.api.response.KMSKeyResponse;
3331
import org.apache.cloudstack.context.CallContext;
3432
import org.apache.cloudstack.framework.kms.KMSException;
@@ -43,7 +41,7 @@
4341
authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User},
4442
requestHasSensitiveInfo = false,
4543
responseHasSensitiveInfo = false)
46-
public class UpdateKMSKeyCmd extends BaseAsyncCmd implements UserCmd {
44+
public class UpdateKMSKeyCmd extends BaseCmd {
4745

4846
@Inject
4947
private KMSManager kmsManager;
@@ -109,16 +107,6 @@ public Long getApiResourceId() {
109107
return getId();
110108
}
111109

112-
@Override
113-
public String getEventType() {
114-
return EventTypes.EVENT_KMS_KEY_UPDATE;
115-
}
116-
117-
@Override
118-
public String getEventDescription() {
119-
return "updating KMS key: " + getId();
120-
}
121-
122110
public Long getId() {
123111
return id;
124112
}

api/src/main/java/org/apache/cloudstack/api/command/user/kms/hsm/ListHSMProfilesCmd.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ public class ListHSMProfilesCmd extends BaseListProjectAndAccountResourcesCmd {
5151
@Parameter(name = ApiConstants.ENABLED, type = CommandType.BOOLEAN, description = "list only enabled profiles")
5252
private Boolean enabled;
5353

54-
@Parameter(name = ApiConstants.IS_SYSTEM,
54+
@Parameter(name = ApiConstants.IS_PUBLIC,
5555
type = CommandType.BOOLEAN,
5656
description = "when true, non-admin users see only system (global) profiles")
57-
private Boolean isSystem;
57+
private Boolean isPublic;
5858

5959
public Long getId() {
6060
return id;
@@ -72,8 +72,8 @@ public Boolean getEnabled() {
7272
return enabled;
7373
}
7474

75-
public Boolean getIsSystem() {
76-
return isSystem;
75+
public Boolean getIsPublic() {
76+
return isPublic;
7777
}
7878

7979
@Override

api/src/main/java/org/apache/cloudstack/api/response/VolumeResponse.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,10 @@ public void setVolumeRepairResult(Map<String, String> volumeRepairResult) {
880880
this.volumeRepairResult = volumeRepairResult;
881881
}
882882

883+
public String getEncryptionFormat() {
884+
return encryptionFormat;
885+
}
886+
883887
public void setEncryptionFormat(String encryptionFormat) {
884888
this.encryptionFormat = encryptionFormat;
885889
}

plugins/kms/pkcs11/src/main/java/org/apache/cloudstack/kms/provider/pkcs11/PKCS11HSMProvider.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -691,29 +691,30 @@ private String buildSunPKCS11Config(Map<String, String> config, String nameSuffi
691691
*/
692692
private void handlePKCS11Exception(Exception e, String context) throws KMSException {
693693
String errorMsg = e.getMessage();
694+
String causeErrorMessage = e.getCause() != null ? e.getCause().getMessage() : "";
694695
if (errorMsg == null) {
695696
errorMsg = e.getClass().getSimpleName();
696697
}
697698
logger.warn("PKCS#11 error: {} - {}", errorMsg, context, e);
698699

699-
if (errorMsg.contains("CKR_CRYPTOKI_NOT_INITIALIZED") || errorMsg.contains("CRYPTOKI_NOT_INITIALIZED")) {
700+
if (causeErrorMessage.contains("CRYPTOKI_NOT_INITIALIZED") || errorMsg.contains("CRYPTOKI_NOT_INITIALIZED")) {
700701
hsmRestartCount.incrementAndGet();
701702
throw new KMSException(KMSException.ErrorType.CONNECTION_FAILED,
702703
context + ": HSM requires re-initialization (CRYPTOKI_NOT_INITIALIZED)", e);
703-
} else if (errorMsg.contains("CKR_PIN_INCORRECT") || errorMsg.contains("PIN_INCORRECT")) {
704+
} else if (causeErrorMessage.contains("PIN_INCORRECT") || errorMsg.contains("PIN_INCORRECT")) {
704705
throw new KMSException(KMSException.ErrorType.AUTHENTICATION_FAILED,
705706
context + ": Incorrect PIN", e);
706-
} else if (errorMsg.contains("CKR_SLOT_ID_INVALID") || errorMsg.contains("SLOT_ID_INVALID")) {
707+
} else if (causeErrorMessage.contains("SLOT_ID_INVALID") || errorMsg.contains("SLOT_ID_INVALID")) {
707708
throw KMSException.invalidParameter(context + ": Invalid slot ID");
708-
} else if (errorMsg.contains("CKR_KEY_NOT_FOUND") || errorMsg.contains("KEY_NOT_FOUND")) {
709+
} else if (causeErrorMessage.contains("KEY_NOT_FOUND") || errorMsg.contains("KEY_NOT_FOUND")) {
709710
throw KMSException.kekNotFound(context + ": Key not found");
710-
} else if (errorMsg.contains("CKR_DEVICE_ERROR") || errorMsg.contains("DEVICE_ERROR")) {
711+
} else if (causeErrorMessage.contains("DEVICE_ERROR") || errorMsg.contains("DEVICE_ERROR")) {
711712
throw new KMSException(KMSException.ErrorType.CONNECTION_FAILED,
712713
context + ": HSM device error", e);
713-
} else if (errorMsg.contains("CKR_SESSION_HANDLE_INVALID") || errorMsg.contains("SESSION_HANDLE_INVALID")) {
714+
} else if (causeErrorMessage.contains("SESSION_HANDLE_INVALID") || errorMsg.contains("SESSION_HANDLE_INVALID")) {
714715
throw new KMSException(KMSException.ErrorType.CONNECTION_FAILED,
715716
context + ": Invalid session handle", e);
716-
} else if (errorMsg.contains("CKR_KEY_ALREADY_EXISTS") || errorMsg.contains("KEY_ALREADY_EXISTS")) {
717+
} else if (causeErrorMessage.contains("KEY_ALREADY_EXISTS") || errorMsg.contains("KEY_ALREADY_EXISTS")) {
717718
throw KMSException.keyAlreadyExists(context);
718719
} else if (e instanceof KeyStoreException) {
719720
throw new KMSException(KMSException.ErrorType.WRAP_UNWRAP_FAILED,

0 commit comments

Comments
 (0)