简体   繁体   中英

Spring Oauth2 JdbcTokenStore Oracle Database

i'm trying convert the jdbctoken store schema here https://github.com/spring-projects/spring-security-oauth/blob/master/spring-security-oauth2/src/test/resources/schema.sql

to

CREATE TABLE EISBIT.OAUTH_ACCESS_TOKEN
(
  TOKEN_ID           VARCHAR2(256 BYTE),
  TOKEN              CLOB,
  AUTHENTICATION_ID  VARCHAR2(256 BYTE),
  USER_NAME          VARCHAR2(256 BYTE),
  CLIENT_ID          VARCHAR2(256 BYTE),
  AUTHENTICATION     CLOB,
  REFRESH_TOKEN      VARCHAR2(256 BYTE)
)

ths

@Override
public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
    endpoints
            .tokenStore(tokenStore())
            .authenticationManager(this.authenticationManager);
}

but i get this exception when try a

 2015-07-03 14:34:01.300 WARN 10952 --- [pr-8080-exec-13] ossoptoken.store.JdbcTokenStore : Failed to deserialize access token for b14fa3b1-5a5a-4d0c-9112-416997c2dc83 java.lang.IllegalArgumentException: java.io.StreamCorruptedException: invalid stream header: 00540001 at org.springframework.security.oauth2.common.util.SerializationUtils.deserialize(SerializationUtils.java:40) at org.springframework.security.oauth2.provider.token.store.JdbcTokenStore.deserializeAccessToken(JdbcTokenStore.java:397) at org.springframework.security.oauth2.provider.token.store.JdbcTokenStore$2.mapRow(JdbcTokenStore.java:162) at org.springframework.security.oauth2.provider.token.store.JdbcTokenStore$2.mapRow(JdbcTokenStore.java:1) at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:93) at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:60) at org.springframework.jdbc.core.JdbcTemplate$1.doInPreparedStatement(JdbcTemplate.java:708) at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:644) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:695) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:727) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:737) at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:811) at org.springframework.security.oauth2.provider.token.store.JdbcTokenStore.readAccessToken(JdbcTokenStore.java:160) 

error when try to read the tokenstore :(..

modify CLOB to BLOB

CREATE TABLE EISBIT.OAUTH_ACCESS_TOKEN
(
  TOKEN_ID           VARCHAR2(256 BYTE),
  TOKEN              BLOB,
  AUTHENTICATION_ID  VARCHAR2(256 BYTE),
  USER_NAME          VARCHAR2(256 BYTE),
  CLIENT_ID          VARCHAR2(256 BYTE),
  AUTHENTICATION     BLOB,
  REFRESH_TOKEN      VARCHAR2(256 BYTE)
)

I was working on the same issue.

Visit this link if anybody still need the complete working schema.

Hope this helps.

You have to map this to RAW or LONG RAW datatype in Oracle . We faced this exception and had to change the following fields in OAUTH tables .

  1. OAUTH_ACCESS_TOKEN

    TOKEN RAW

    AUTHENTICATION LONG RAW

    REFRESH_TOKEN RAW

  2. OAUTH_REFRESH_TOKEN

    TOKEN RAW

    AUTHENTICATION LONG RAW

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM