@Test public void saveOauthCode() throws Exception { final OAuthIssuerImpl oAuthIssuer = new OAuthIssuerImpl(new MD5Generator()); OauthCode oauthCode = new OauthCode() .username("test") .code(oAuthIssuer.authorizationCode()) .clientId("client+id"); oauthJdbcRepository.saveOauthCode(oauthCode); final OauthCode oauthCode1 = oauthJdbcRepository.findOauthCode(oauthCode.code(), oauthCode.clientId()); assertNotNull(oauthCode1); assertNotNull(oauthCode1.code()); assertNotNull(oauthCode1.username()); System.out.println(oauthCode1.code()); final OauthCode oauthCode2 = oauthJdbcRepository.findOauthCodeByUsernameClientId(oauthCode.username(), oauthCode.clientId()); assertNotNull(oauthCode2); final int i = oauthJdbcRepository.deleteOauthCode(oauthCode); assertEquals(i, 1); final OauthCode oauthCode3 = oauthJdbcRepository.findOauthCodeByUsernameClientId("add", "ddood"); assertNull(oauthCode3); }
@Override public int saveOauthCode(final OauthCode oauthCode) { final String sql = " insert into oauth_code(code,username,client_id) values (?,?,?)"; return jdbcTemplate.update(sql, new PreparedStatementSetter() { @Override public void setValues(PreparedStatement ps) throws SQLException { ps.setString(1, oauthCode.code()); ps.setString(2, oauthCode.username()); ps.setString(3, oauthCode.clientId()); } }); }
OauthJdbcRepository extends AbstractJdbcRepository implements OauthRepository { @Override public int saveOauthCode(final OauthCode oauthCode) { final String sql = " insert into oauth_code(code,username,client_id) values (?,?,?)"; return jdbcTemplate.update(sql, new PreparedStatementSetter() { @Override public void setValues(PreparedStatement ps) throws SQLException { ps.setString(1, oauthCode.code()); ps.setString(2, oauthCode.username()); ps.setString(3, oauthCode.clientId()); } }); } }
OauthJdbcRepository extends AbstractJdbcRepository implements OauthRepository { @Override public int saveOauthCode(final OauthCode oauthCode) { final String sql = " insert into oauth_code(code,username,client_id) values (?,?,?)"; return jdbcTemplate.update(sql, new PreparedStatementSetter() { @Override public void setValues(PreparedStatement ps) throws SQLException { ps.setString(1, oauthCode.code()); ps.setString(2, oauthCode.username()); ps.setString(3, oauthCode.clientId()); } }); }  }
OauthJdbcRepository extends AbstractJdbcRepository implements OauthRepository { @Override public int saveOauthCode(final OauthCode oauthCode) { final String sql = " insert into oauth_code(code,username,client_id) values (?,?,?)"; return jdbcTemplate.update(sql, new PreparedStatementSetter() { @Override public void setValues(PreparedStatement ps) throws SQLException { ps.setString(1, oauthCode.code()); ps.setString(2, oauthCode.username()); ps.setString(3, oauthCode.clientId()); } }); }  @Override ClientDetails findClientDetails(String clientId); @Override int saveClientDetails(final ClientDetails clientDetails); @Override int saveOauthCode(final OauthCode oauthCode); @Override OauthCode findOauthCode(String code, String clientId); @Override OauthCode findOauthCodeByUsernameClientId(String username, String clientId); @Override int deleteOauthCode(final OauthCode oauthCode); @Override AccessToken findAccessToken(String clientId, String username, String authenticationId); @Override int deleteAccessToken(final AccessToken accessToken); @Override int saveAccessToken(final AccessToken accessToken); @Override AccessToken findAccessTokenByRefreshToken(String refreshToken, String clientId); }
OauthJdbcRepository extends AbstractJdbcRepository implements OauthRepository { @Override public int saveOauthCode(final OauthCode oauthCode) { final String sql = " insert into oauth_code(code,username,client_id) values (?,?,?)"; return jdbcTemplate.update(sql, new PreparedStatementSetter() { @Override public void setValues(PreparedStatement ps) throws SQLException { ps.setString(1, oauthCode.code()); ps.setString(2, oauthCode.username()); ps.setString(3, oauthCode.clientId()); } }); }  @Override ClientDetails findClientDetails(String clientId); @Override int saveClientDetails(final ClientDetails clientDetails); @Override int saveOauthCode(final OauthCode oauthCode); @Override OauthCode findOauthCode(String code, String clientId); @Override OauthCode findOauthCodeByUsernameClientId(String username, String clientId); @Override int deleteOauthCode(final OauthCode oauthCode); @Override AccessToken findAccessToken(String clientId, String username, String authenticationId); @Override int deleteAccessToken(final AccessToken accessToken); @Override int saveAccessToken(final AccessToken accessToken); @Override AccessToken findAccessTokenByRefreshToken(String refreshToken, String clientId);  }