use of org.springframework.jdbc.core.support.SqlLobValue in project spring-security-oauth by spring-projects.
the class JdbcTokenStore method storeAccessToken.
public void storeAccessToken(OAuth2AccessToken token, OAuth2Authentication authentication) {
String refreshToken = null;
if (token.getRefreshToken() != null) {
refreshToken = token.getRefreshToken().getValue();
}
if (readAccessToken(token.getValue()) != null) {
removeAccessToken(token.getValue());
}
jdbcTemplate.update(insertAccessTokenSql, new Object[] { extractTokenKey(token.getValue()), new SqlLobValue(serializeAccessToken(token)), authenticationKeyGenerator.extractKey(authentication), authentication.isClientOnly() ? null : authentication.getName(), authentication.getOAuth2Request().getClientId(), new SqlLobValue(serializeAuthentication(authentication)), extractTokenKey(refreshToken) }, new int[] { Types.VARCHAR, Types.BLOB, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.BLOB, Types.VARCHAR });
}
use of org.springframework.jdbc.core.support.SqlLobValue in project sakuli by ConSol.
the class DaoTestCaseImplTest method testGetScreenshotAsSqlLobValueTestCase.
@Test
public void testGetScreenshotAsSqlLobValueTestCase() throws Exception {
Path screenshotPath = Paths.get(this.getClass().getResource("computer.png").toURI());
TestCase testCase = new TestCaseExampleBuilder().withException(null).withTestCaseSteps(Collections.singletonList(new TestCaseStepExampleBuilder().withException(new SakuliExceptionWithScreenshot("test-exception", screenshotPath)).buildExample())).buildExample();
SqlLobValue result = testling.getScreenshotAsSqlLobValue(testCase);
assertNotNull(result);
}
use of org.springframework.jdbc.core.support.SqlLobValue in project sakuli by ConSol.
the class DaoTestCaseImpl method getScreenshotAsSqlLobValue.
/**
* Determine the first available screenshot inside of the testcase and respectively in the assigned steps.
* For Details of the transformation, see {@link org.springframework.jdbc.support.lob.LobHandler}.
*
* @return a {@link SqlLobValue}
*/
protected SqlLobValue getScreenshotAsSqlLobValue(TestCase testCase) {
try {
Path screenShotPath = testCase.getScreenShotPath();
if (screenShotPath == null) {
//get first step exception
for (TestCaseStep step : testCase.getStepsAsSortedSet()) {
if (step.getScreenShotPath() != null) {
screenShotPath = step.getScreenShotPath();
break;
}
}
}
if (screenShotPath != null) {
final InputStream blobIs = Files.newInputStream(screenShotPath);
final int length = (int) screenShotPath.toFile().length();
return new SqlLobValue(blobIs, length, lobHandler);
}
return null;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
use of org.springframework.jdbc.core.support.SqlLobValue in project sakuli by ConSol.
the class DaoTestSuiteImpl method getCompleteParameters.
private MapSqlParameterSource getCompleteParameters() {
MapSqlParameterSource tcParameters = getInitialDataParameters();
tcParameters.addValues(getGuidParameter().getValues());
tcParameters.addValue("stop", testSuite.getStopDateAsUnixTimestamp());
int warningTime = testSuite.getWarningTime();
tcParameters.addValue("warning", (warningTime != 0) ? warningTime : null);
int criticalTime = testSuite.getCriticalTime();
tcParameters.addValue("critical", (criticalTime != 0) ? criticalTime : null);
tcParameters.addValue("duration", testSuite.getDuration());
//try to save the screenshot
try {
if (testSuite.getScreenShotPath() != null) {
final InputStream blobIs = Files.newInputStream(testSuite.getScreenShotPath());
final int length = (int) testSuite.getScreenShotPath().toFile().length();
tcParameters.addValue("screenshot", new SqlLobValue(blobIs, length, lobHandler), Types.BLOB);
}
} catch (IOException e) {
throw new RuntimeException(e);
}
tcParameters.addValue("msg", testSuite.getExceptionMessages(false));
return tcParameters;
}
use of org.springframework.jdbc.core.support.SqlLobValue in project spring-security-oauth by spring-projects.
the class JdbcClientTokenServices method saveAccessToken.
public void saveAccessToken(OAuth2ProtectedResourceDetails resource, Authentication authentication, OAuth2AccessToken accessToken) {
removeAccessToken(resource, authentication);
String name = authentication == null ? null : authentication.getName();
jdbcTemplate.update(insertAccessTokenSql, new Object[] { accessToken.getValue(), new SqlLobValue(SerializationUtils.serialize(accessToken)), keyGenerator.extractKey(resource, authentication), name, resource.getClientId() }, new int[] { Types.VARCHAR, Types.BLOB, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR });
}
Aggregations