Example usage for org.springframework.jdbc.core.namedparam EmptySqlParameterSource INSTANCE

List of usage examples for org.springframework.jdbc.core.namedparam EmptySqlParameterSource INSTANCE

Introduction

In this page you can find the example usage for org.springframework.jdbc.core.namedparam EmptySqlParameterSource INSTANCE.

Prototype

EmptySqlParameterSource INSTANCE

To view the source code for org.springframework.jdbc.core.namedparam EmptySqlParameterSource INSTANCE.

Click Source Link

Document

A shared instance of EmptySqlParameterSource .

Usage

From source file:net.turnbig.jdbcx.JdbcxDaoSupport.java

public <T> T queryForBean(String sql, Class<T> mapResultToClass) {
    return getNamedParameterJdbcTemplate().queryForObject(sql, EmptySqlParameterSource.INSTANCE,
            getBeanPropsRowMapper(mapResultToClass));
}

From source file:net.turnbig.jdbcx.JdbcxDaoSupport.java

public Map<String, Object> queryForMap(String sql) {
    return getNamedParameterJdbcTemplate().queryForMap(sql, EmptySqlParameterSource.INSTANCE);
}

From source file:net.turnbig.jdbcx.JdbcxDaoSupport.java

public List<Map<String, Object>> queryForListMap(String sql) {
    return getNamedParameterJdbcTemplate().queryForList(sql, EmptySqlParameterSource.INSTANCE);
}

From source file:net.turnbig.jdbcx.JdbcxDaoSupport.java

public <T> T queryForObject(String sql, Class<T> requiredType) {
    return getNamedParameterJdbcTemplate().queryForObject(sql, EmptySqlParameterSource.INSTANCE, requiredType);
}

From source file:net.turnbig.jdbcx.JdbcxDaoSupport.java

public <T> List<T> queryForList(String sql, Class<T> elementType) {
    return getNamedParameterJdbcTemplate().queryForList(sql, EmptySqlParameterSource.INSTANCE, elementType);
}

From source file:org.jasig.portlet.notice.service.jdbc.AbstractJdbcNotificationService.java

/**
 * General-purpose implementation of this method that wraps the OIDC Id token in an
 * {@link SqlParameterSource}.  Subclasses <em>may</em> override this method to provide a custom
 * {@link SqlParameterSource} when needed.
 *//*from w  w  w. j av a  2s . c  om*/
protected SqlParameterSource getSqlParameterSource(HttpServletRequest request) {

    final String authHeader = request.getHeader(HttpHeaders.AUTHORIZATION);
    if (StringUtils.isBlank(authHeader) || !authHeader.startsWith(Headers.BEARER_TOKEN_PREFIX)) {
        // No attribute without JWT...
        return EmptySqlParameterSource.INSTANCE;
    }

    final String bearerToken = authHeader.substring(Headers.BEARER_TOKEN_PREFIX.length());

    try {
        // Validate & parse the JWT
        final Jws<Claims> claims = Jwts.parser().setSigningKey(signatureKey).parseClaimsJws(bearerToken);
        // Convert to MapSqlParameterSource
        Map<String, Object> map = new HashMap<>();
        claims.getBody().entrySet().forEach(entry -> {
            final Object value = entry.getValue();
            if (List.class.isInstance(value) && ((List<Object>) value).size() != 0) {
                map.put(entry.getKey(), ((List<Object>) value).get(0));
            } else {
                map.put(entry.getKey(), value);
            }
        });
        return new MapSqlParameterSource(map);
    } catch (Exception e) {
        logger.warn("The specified Bearer token is unusable:  '{}'", bearerToken);
        logger.debug("Failed to validate and/or parse the specified Bearer token", e);
    }

    return EmptySqlParameterSource.INSTANCE;

}