Search in sources :

Example 21 with PreparedStatementSetter

use of org.springframework.jdbc.core.PreparedStatementSetter in project spring-security by spring-projects.

the class JdbcOAuth2AuthorizedClientService method removeAuthorizedClient.

@Override
public void removeAuthorizedClient(String clientRegistrationId, String principalName) {
    Assert.hasText(clientRegistrationId, "clientRegistrationId cannot be empty");
    Assert.hasText(principalName, "principalName cannot be empty");
    SqlParameterValue[] parameters = new SqlParameterValue[] { new SqlParameterValue(Types.VARCHAR, clientRegistrationId), new SqlParameterValue(Types.VARCHAR, principalName) };
    PreparedStatementSetter pss = new ArgumentPreparedStatementSetter(parameters);
    this.jdbcOperations.update(REMOVE_AUTHORIZED_CLIENT_SQL, pss);
}
Also used : SqlParameterValue(org.springframework.jdbc.core.SqlParameterValue) PreparedStatementSetter(org.springframework.jdbc.core.PreparedStatementSetter) ArgumentPreparedStatementSetter(org.springframework.jdbc.core.ArgumentPreparedStatementSetter) ArgumentPreparedStatementSetter(org.springframework.jdbc.core.ArgumentPreparedStatementSetter)

Example 22 with PreparedStatementSetter

use of org.springframework.jdbc.core.PreparedStatementSetter in project spring-security by spring-projects.

the class JdbcOAuth2AuthorizedClientService method loadAuthorizedClient.

@Override
@SuppressWarnings("unchecked")
public <T extends OAuth2AuthorizedClient> T loadAuthorizedClient(String clientRegistrationId, String principalName) {
    Assert.hasText(clientRegistrationId, "clientRegistrationId cannot be empty");
    Assert.hasText(principalName, "principalName cannot be empty");
    SqlParameterValue[] parameters = new SqlParameterValue[] { new SqlParameterValue(Types.VARCHAR, clientRegistrationId), new SqlParameterValue(Types.VARCHAR, principalName) };
    PreparedStatementSetter pss = new ArgumentPreparedStatementSetter(parameters);
    List<OAuth2AuthorizedClient> result = this.jdbcOperations.query(LOAD_AUTHORIZED_CLIENT_SQL, pss, this.authorizedClientRowMapper);
    return !result.isEmpty() ? (T) result.get(0) : null;
}
Also used : SqlParameterValue(org.springframework.jdbc.core.SqlParameterValue) PreparedStatementSetter(org.springframework.jdbc.core.PreparedStatementSetter) ArgumentPreparedStatementSetter(org.springframework.jdbc.core.ArgumentPreparedStatementSetter) ArgumentPreparedStatementSetter(org.springframework.jdbc.core.ArgumentPreparedStatementSetter)

Aggregations

PreparedStatementSetter (org.springframework.jdbc.core.PreparedStatementSetter)22 SQLException (java.sql.SQLException)13 PreparedStatement (java.sql.PreparedStatement)12 List (java.util.List)5 Timestamp (java.sql.Timestamp)4 Date (java.util.Date)4 ArgumentPreparedStatementSetter (org.springframework.jdbc.core.ArgumentPreparedStatementSetter)4 JdbcTemplate (org.springframework.jdbc.core.JdbcTemplate)4 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)3 Map (java.util.Map)3 SqlParameterValue (org.springframework.jdbc.core.SqlParameterValue)3 Lists (com.google.common.collect.Lists)2 ResultSet (java.sql.ResultSet)2 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 HashMap (java.util.HashMap)2 DataSource (javax.sql.DataSource)2 SessionFactory (org.hibernate.SessionFactory)2 SortOrder (org.hisp.dhis.analytics.SortOrder)2 DataStatisticsEvent (org.hisp.dhis.datastatistics.DataStatisticsEvent)2