use of org.wso2.carbon.identity.secret.mgt.core.model.SecretType 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.model.SecretType 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.model.SecretType in project carbon-identity-framework by wso2.
the class SecretManagerTest method testAddDuplicateSecret.
@Test(priority = 10, expectedExceptions = SecretManagementClientException.class)
public void testAddDuplicateSecret() throws Exception {
SecretType secretType = secretManager.addSecretType(getSampleSecretTypeAdd(SAMPLE_SECRET_TYPE_NAME1, SAMPLE_SECRET_TYPE_DESCRIPTION1));
Secret secretAdd = getSampleSecretAdd(SAMPLE_SECRET_NAME1, SAMPLE_SECRET_VALUE1);
encryptSecret(secretAdd.getSecretValue());
secretManager.addSecret(secretType.getName(), secretAdd);
secretManager.addSecret(secretType.getName(), secretAdd);
fail("Expected: " + SecretManagementClientException.class.getName());
}
use of org.wso2.carbon.identity.secret.mgt.core.model.SecretType in project carbon-identity-framework by wso2.
the class SecretManagerTest method testAddSecret.
@Test(priority = 9)
public void testAddSecret() throws Exception {
SecretType secretType = secretManager.addSecretType(getSampleSecretTypeAdd(SAMPLE_SECRET_TYPE_NAME1, SAMPLE_SECRET_TYPE_DESCRIPTION1));
Secret secretAdd = getSampleSecretAdd(SAMPLE_SECRET_NAME1, SAMPLE_SECRET_VALUE1);
encryptSecret(secretAdd.getSecretValue());
Secret secret = secretManager.addSecret(secretType.getName(), secretAdd);
assertNotNull(secret.getSecretId(), "Created secret type id cannot be null");
assertEquals(secretAdd.getSecretName(), secret.getSecretName());
}
use of org.wso2.carbon.identity.secret.mgt.core.model.SecretType in project carbon-identity-framework by wso2.
the class SecretManagerTest method testAddDuplicateResourceType.
@Test(priority = 2, expectedExceptions = SecretManagementClientException.class)
public void testAddDuplicateResourceType() throws Exception {
SecretType secretTypeAdd = getSampleSecretTypeAdd(SAMPLE_SECRET_TYPE_NAME1, SAMPLE_SECRET_TYPE_DESCRIPTION1);
secretManager.addSecretType(secretTypeAdd);
secretManager.addSecretType(secretTypeAdd);
fail("Expected: " + SecretManagementClientException.class.getName());
}
Aggregations