Skip to content

JdbcOAuth2AuthorizedClientService is dependend on non-standard driver behaviour #9023

@queueseven

Description

@queueseven

Describe the bug
I'm using the JdbcOAuth2AuthorizedClientService with the MariaDB java connector. Authorization fails with a SQLSyntaxErrorException:

Can only convert a byte[] to BINARY, VARBINARY or LONGVARBINARY

To Reproduce
Use the JdbcOAuth2AuthorizedClientService with the MariaDB java connector.

Expected behavior
No exception should be thrown.

The problem is these two lines:

parameters.add(new SqlParameterValue(Types.BLOB, accessToken.getTokenValue().getBytes(StandardCharsets.UTF_8)));

parameters.add(new SqlParameterValue(Types.BLOB, refreshTokenValue));

According to the JDBC specification, a driver has to implement conversions between byte[] <=> BINARY, VARBINARY, LONGVARBINARY and java.sql.Blob <=> BLOB. While some drivers implement a conversion between byte[] and BLOB, it's a non-standard behaviour and you can't rely on it.

So, in this case, the byte[]s should be wrapped in an appropriate java.sql.Blob type.

Metadata

Metadata

Assignees

Labels

in: oauth2An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose)status: duplicateA duplicate of another issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions