Example usage for org.springframework.security.oauth2.provider ClientDetails getClass

List of usage examples for org.springframework.security.oauth2.provider ClientDetails getClass

Introduction

In this page you can find the example usage for org.springframework.security.oauth2.provider ClientDetails getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:nl.surfnet.coin.api.oauth.OpenConextOauth2JdbcTokenStore.java

@Override
public void storeAccessToken(OAuth2AccessToken token, OAuth2Authentication authentication) {
    AuthorizationRequest authorizationRequest = authentication.getAuthorizationRequest();
    String clientId = authorizationRequest.getClientId();
    ClientDetails clientDetails = clientDetailsService.loadClientByClientId(clientId);
    if (!(clientDetails instanceof OpenConextClientDetails)) {
        throw new RuntimeException("The clientDetails is of the type '"
                + (clientDetails != null ? clientDetails.getClass() : "null")
                + "'. Required is a (sub)class of ExtendedBaseClientDetails");
    }/*w ww. j a  v  a2 s  . c o m*/

    ClientMetaData clientMetaData = ((OpenConextClientDetails) clientDetails).getClientMetaData();

    String refreshToken = null;
    if (token.getRefreshToken() != null) {
        refreshToken = token.getRefreshToken().getValue();
    }

    String value = extractTokenKey(token.getValue());
    jdbcTemplate.update(ACCESS_TOKEN_INSERT_STATEMENT,
            new Object[] { value, new SqlLobValue(SerializationUtils.serialize(token)),
                    authenticationKeyGenerator.extractKey(authentication),
                    authentication.isClientOnly() ? null : authentication.getName(),
                    authentication.getAuthorizationRequest().getClientId(), clientMetaData.getAppEntityId(),
                    new SqlLobValue(SerializationUtils.serialize(authentication)), refreshToken },
            new int[] { Types.VARCHAR, Types.BLOB, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
                    Types.BLOB, Types.VARCHAR });

}