use of org.wso2.carbon.identity.secret.mgt.core.exception.SecretManagementException in project carbon-identity-framework by wso2.
the class CachedBackedSecretDAO method deleteCacheBySecretId.
private void deleteCacheBySecretId(String secretId, int tenantId) throws SecretManagementException {
Secret secret = getSecretFromCacheById(secretId, tenantId);
if (secret == null) {
return;
}
deleteSecretFromCache(secret);
}
use of org.wso2.carbon.identity.secret.mgt.core.exception.SecretManagementException in project carbon-identity-framework by wso2.
the class CachedBackedSecretDAO method updateSecretDescription.
@Override
public Secret updateSecretDescription(Secret secret, String description) throws SecretManagementException {
Secret updatedSecret = secretDAO.updateSecretDescription(secret, description);
deleteSecretFromCache(secret);
return updatedSecret;
}
use of org.wso2.carbon.identity.secret.mgt.core.exception.SecretManagementException in project carbon-identity-framework by wso2.
the class CachedBackedSecretDAO method updateSecretValue.
@Override
public Secret updateSecretValue(Secret secret, String value) throws SecretManagementException {
Secret updatedSecret = secretDAO.updateSecretValue(secret, value);
deleteSecretFromCache(secret);
return updatedSecret;
}
use of org.wso2.carbon.identity.secret.mgt.core.exception.SecretManagementException in project carbon-identity-framework by wso2.
the class CachedBackedSecretDAO method getSecretById.
@Override
public Secret getSecretById(String secretId, int tenantId) throws SecretManagementException {
Secret secret = getSecretFromCacheById(secretId, tenantId);
if (secret != null) {
if (log.isDebugEnabled()) {
String message = String.format("Cache hit for secret by it's id. Secret id: %s", secretId);
log.debug(message);
}
} else {
if (log.isDebugEnabled()) {
String message = String.format("Cache miss for secret by it's id. Secret id: %s", secretId);
log.debug(message);
}
secret = secretDAO.getSecretById(secretId, tenantId);
addSecretToCache(secret);
}
return secret;
}
use of org.wso2.carbon.identity.secret.mgt.core.exception.SecretManagementException in project carbon-identity-framework by wso2.
the class SecretDAOImpl method isExistingSecret.
@Override
public boolean isExistingSecret(String secretId, int tenantId) throws SecretManagementException {
NamedJdbcTemplate jdbcTemplate = getNewTemplate();
String secretName;
try {
secretName = jdbcTemplate.fetchSingleRecord(GET_SECRET_NAME_BY_ID, (resultSet, rowNumber) -> resultSet.getString(DB_SCHEMA_COLUMN_NAME_SECRET_NAME), preparedStatement -> {
preparedStatement.setString(DB_SCHEMA_COLUMN_NAME_ID, secretId);
preparedStatement.setInt(DB_SCHEMA_COLUMN_NAME_TENANT_ID, tenantId);
});
return StringUtils.isNotEmpty(secretName);
} catch (DataAccessException e) {
throw handleServerException(ERROR_CODE_GET_SECRET, "id = " + secretId, e);
}
}
Aggregations