Search in sources :

Example 1 with ERROR_CODE_SECRETS_DOES_NOT_EXISTS

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

the class SecretManagerImpl method getSecrets.

@Override
public Secrets getSecrets(String secretTypeName) throws SecretManagementException {
    validateSecretManagerEnabled();
    validateSecretsRetrieveRequest(secretTypeName);
    SecretType secretType = getSecretType(secretTypeName);
    List secretList = this.getSecretDAO().getSecrets(secretType, getTenantId());
    if (secretList == null) {
        if (log.isDebugEnabled()) {
            log.debug("No secret found for the secretTypeName: " + secretTypeName + "for the tenant: " + getTenantDomain());
        }
        throw handleClientException(ERROR_CODE_SECRETS_DOES_NOT_EXISTS, null);
    }
    if (log.isDebugEnabled()) {
        log.debug("All secrets of tenant: " + getTenantDomain() + " are retrieved successfully.");
    }
    return new Secrets(secretList);
}
Also used : SecretType(org.wso2.carbon.identity.secret.mgt.core.model.SecretType) Secrets(org.wso2.carbon.identity.secret.mgt.core.model.Secrets) List(java.util.List)

Example 2 with ERROR_CODE_SECRETS_DOES_NOT_EXISTS

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

the class SecretDAOImpl method getSecrets.

@Override
public List getSecrets(SecretType secretType, int tenantId) throws SecretManagementException {
    NamedJdbcTemplate jdbcTemplate = getNewTemplate();
    try {
        return jdbcTemplate.executeQuery(GET_SECRETS, (LambdaExceptionUtils.rethrowRowMapper((resultSet, rowNumber) -> {
            String secretId = resultSet.getString(DB_SCHEMA_COLUMN_NAME_ID);
            String secretName = resultSet.getString(DB_SCHEMA_COLUMN_NAME_SECRET_NAME);
            String secretLastModified = resultSet.getString(DB_SCHEMA_COLUMN_NAME_LAST_MODIFIED);
            String secretCreatedTime = resultSet.getString(DB_SCHEMA_COLUMN_NAME_CREATED_TIME);
            String description = resultSet.getString(DB_SCHEMA_COLUMN_NAME_DESCRIPTION);
            Secret secret = new Secret();
            secret.setCreatedTime(secretCreatedTime);
            secret.setSecretId(secretId);
            secret.setSecretName(secretName);
            secret.setLastModified(secretLastModified);
            secret.setTenantDomain(IdentityTenantUtil.getTenantDomain(tenantId));
            secret.setSecretType(secretType.getName());
            secret.setDescription(description);
            return secret;
        })), preparedStatement -> {
            preparedStatement.setString(DB_SCHEMA_COLUMN_NAME_TYPE, secretType.getId());
            preparedStatement.setInt(DB_SCHEMA_COLUMN_NAME_TENANT_ID, tenantId);
        });
    } catch (DataAccessException e) {
        throw handleServerException(ERROR_CODE_SECRETS_DOES_NOT_EXISTS, e);
    }
}
Also used : Secret(org.wso2.carbon.identity.secret.mgt.core.model.Secret) NamedJdbcTemplate(org.wso2.carbon.database.utils.jdbc.NamedJdbcTemplate) DataAccessException(org.wso2.carbon.database.utils.jdbc.exceptions.DataAccessException)

Aggregations

List (java.util.List)1 NamedJdbcTemplate (org.wso2.carbon.database.utils.jdbc.NamedJdbcTemplate)1 DataAccessException (org.wso2.carbon.database.utils.jdbc.exceptions.DataAccessException)1 Secret (org.wso2.carbon.identity.secret.mgt.core.model.Secret)1 SecretType (org.wso2.carbon.identity.secret.mgt.core.model.SecretType)1 Secrets (org.wso2.carbon.identity.secret.mgt.core.model.Secrets)1