Search in sources :

Example 1 with ERROR_CODE_SECRET_DOES_NOT_EXISTS

use of org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.ErrorMessages.ERROR_CODE_SECRET_DOES_NOT_EXISTS in project carbon-identity-framework by wso2.

the class SecretManagerImpl method getSecret.

@Override
public Secret getSecret(String secretTypeName, String secretName) throws SecretManagementException {
    validateSecretManagerEnabled();
    validateSecretRetrieveRequest(secretTypeName, secretName);
    SecretType secretType = getSecretType(secretTypeName);
    Secret secret = this.getSecretDAO().getSecretByName(secretName, secretType, getTenantId());
    if (secret == null) {
        if (log.isDebugEnabled()) {
            log.debug("No secret found for the secretName: " + secretName);
        }
        throw handleClientException(ERROR_CODE_SECRET_DOES_NOT_EXISTS, secretName, null);
    }
    if (log.isDebugEnabled()) {
        log.debug("Secret: " + secretName + " is retrieved successfully.");
    }
    return secret;
}
Also used : Secret(org.wso2.carbon.identity.secret.mgt.core.model.Secret) SecretType(org.wso2.carbon.identity.secret.mgt.core.model.SecretType)

Example 2 with ERROR_CODE_SECRET_DOES_NOT_EXISTS

use of org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.ErrorMessages.ERROR_CODE_SECRET_DOES_NOT_EXISTS in project carbon-identity-framework by wso2.

the class SecretManagerImpl method deleteSecret.

@Override
public void deleteSecret(String secretTypeName, String secretName) throws SecretManagementException {
    validateSecretManagerEnabled();
    validateSecretDeleteRequest(secretTypeName, secretName);
    SecretType secretType = getSecretType(secretTypeName);
    if (isSecretExist(secretTypeName, secretName)) {
        this.getSecretDAO().deleteSecretByName(secretName, secretType.getId(), getTenantId());
        if (log.isDebugEnabled()) {
            log.debug("Secret: " + secretName + " is deleted successfully.");
        }
    } else {
        throw handleClientException(ERROR_CODE_SECRET_DOES_NOT_EXISTS, secretName);
    }
}
Also used : SecretType(org.wso2.carbon.identity.secret.mgt.core.model.SecretType)

Aggregations

SecretType (org.wso2.carbon.identity.secret.mgt.core.model.SecretType)2 Secret (org.wso2.carbon.identity.secret.mgt.core.model.Secret)1