use of org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.DB_SCHEMA_COLUMN_NAME_DESCRIPTION in project carbon-identity-framework by wso2.
the class SecretDAOImpl method getSecretTypeByName.
@Override
public SecretType getSecretTypeByName(String secretTypeName) throws SecretManagementException {
NamedJdbcTemplate jdbcTemplate = getNewTemplate();
SecretType secretTypeResponse;
try {
secretTypeResponse = jdbcTemplate.fetchSingleRecord(GET_SECRET_TYPE_BY_NAME, (resultSet, rowNumber) -> {
SecretType secretType = new SecretType();
secretType.setId(resultSet.getString(DB_SCHEMA_COLUMN_NAME_ID));
secretType.setName(resultSet.getString(DB_SCHEMA_COLUMN_NAME_NAME));
secretType.setDescription(resultSet.getString(DB_SCHEMA_COLUMN_NAME_DESCRIPTION));
return secretType;
}, preparedStatement -> preparedStatement.setString(DB_SCHEMA_COLUMN_NAME_NAME, secretTypeName));
return secretTypeResponse;
} catch (DataAccessException e) {
throw handleServerException(ERROR_CODE_RETRIEVE_SECRET_TYPE, secretTypeName, e);
}
}
use of org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.DB_SCHEMA_COLUMN_NAME_DESCRIPTION in project carbon-identity-framework by wso2.
the class SecretDAOImpl method addSecretType.
@Override
public void addSecretType(SecretType secretType) throws SecretManagementException {
NamedJdbcTemplate jdbcTemplate = getNewTemplate();
try {
jdbcTemplate.executeInsert(SQLConstants.INSERT_SECRET_TYPE, preparedStatement -> {
preparedStatement.setString(DB_SCHEMA_COLUMN_NAME_ID, secretType.getId());
preparedStatement.setString(DB_SCHEMA_COLUMN_NAME_NAME, secretType.getName());
preparedStatement.setString(DB_SCHEMA_COLUMN_NAME_DESCRIPTION, secretType.getDescription());
}, secretType, false);
} catch (DataAccessException e) {
throw handleServerException(ERROR_CODE_ADD_SECRET_TYPE, secretType.getName(), e);
}
}
use of org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.DB_SCHEMA_COLUMN_NAME_DESCRIPTION in project carbon-identity-framework by wso2.
the class SecretDAOImpl method getSecretByName.
@Override
public Secret getSecretByName(String name, SecretType secretType, int tenantId) throws SecretManagementException {
NamedJdbcTemplate jdbcTemplate = getNewTemplate();
List<SecretRawDataCollector> secretRawDataCollectors;
try {
String query = GET_SECRET_BY_NAME;
secretRawDataCollectors = jdbcTemplate.executeQuery(query, (resultSet, rowNumber) -> {
SecretRawDataCollector.SecretRawDataCollectorBuilder secretRawDataCollectorBuilder = new SecretRawDataCollector.SecretRawDataCollectorBuilder().setSecretId(resultSet.getString(DB_SCHEMA_COLUMN_NAME_ID)).setTenantId(resultSet.getInt(DB_SCHEMA_COLUMN_NAME_TENANT_ID)).setSecretName(resultSet.getString(DB_SCHEMA_COLUMN_NAME_SECRET_NAME)).setSecretValue(resultSet.getString(DB_SCHEMA_COLUMN_NAME_SECRET_VALUE)).setLastModified(resultSet.getTimestamp(DB_SCHEMA_COLUMN_NAME_LAST_MODIFIED, calendar)).setCreatedTime(resultSet.getTimestamp(DB_SCHEMA_COLUMN_NAME_CREATED_TIME, calendar)).setDescription(resultSet.getString(DB_SCHEMA_COLUMN_NAME_DESCRIPTION)).setSecretType(secretType.getName());
return secretRawDataCollectorBuilder.build();
}, preparedStatement -> {
preparedStatement.setString(DB_SCHEMA_COLUMN_NAME_SECRET_NAME, name);
preparedStatement.setString(DB_SCHEMA_COLUMN_NAME_TYPE, secretType.getId());
preparedStatement.setInt(DB_SCHEMA_COLUMN_NAME_TENANT_ID, tenantId);
});
return secretRawDataCollectors == null || secretRawDataCollectors.size() == 0 ? null : buildSecretFromRawData(secretRawDataCollectors);
} catch (DataAccessException | CryptoException e) {
throw handleServerException(ERROR_CODE_GET_SECRET, name, e);
}
}
use of org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.DB_SCHEMA_COLUMN_NAME_DESCRIPTION in project carbon-identity-framework by wso2.
the class SecretDAOImpl method replaceSecretType.
@Override
public void replaceSecretType(SecretType secretType) throws SecretManagementException {
NamedJdbcTemplate jdbcTemplate = getNewTemplate();
try {
jdbcTemplate.executeInsert(UPDATE_SECRET_TYPE, preparedStatement -> {
preparedStatement.setString(DB_SCHEMA_COLUMN_NAME_NAME, secretType.getName());
preparedStatement.setString(DB_SCHEMA_COLUMN_NAME_DESCRIPTION, secretType.getDescription());
preparedStatement.setString(DB_SCHEMA_COLUMN_NAME_ID, secretType.getId());
}, secretType, false);
} catch (DataAccessException e) {
throw handleServerException(ERROR_CODE_UPDATE_SECRET_TYPE, secretType.getName(), e);
}
}
use of org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.DB_SCHEMA_COLUMN_NAME_DESCRIPTION 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);
}
}
Aggregations