[JAVA-865] SASL auth payload is Binary (type 0/3 as byte[]) or a String Created: 06/Jul/13  Updated: 24/Jan/14  Resolved: 24/Jan/14

Status: Closed
Project: Java Driver
Component/s: Authentication
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Critical - P2
Reporter: Scott Hernandez (Inactive) Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates JAVA-883 Use built-in encoder/decoder for inte... Closed
Related
is related to CSHARP-773 Handle string SASL return payload value Closed
Backwards Compatibility: Fully Compatible

 Description   

This line needs to be adjusted to support the correct types:
https://github.com/mongodb/mongo-java-driver/blob/master/src/main/com/mongodb/DBPort.java#L493

See c++ impl: https://github.com/mongodb/mongo/blob/master/src/mongo/client/sasl_client_authenticate.cpp#L56



 Comments   
Comment by Jeffrey Yemin [ 08/Jul/13 ]

This could happen if MongoClientOptions.dbDecoderFactory property is set to a factory that decodes binary subtype 0 differently than the default encoder.

Comment by Jeffrey Yemin [ 06/Jul/13 ]

What server version? I've tested with 2.4 and it has worked.

Comment by Scott Hernandez (Inactive) [ 06/Jul/13 ]

After looking a bit more it seems like this should be working since the bson callback should be converting both 0/3 subtypes to byte[].
https://github.com/mongodb/mongo-java-driver/blob/master/src/main/org/bson/BasicBSONCallback.java#L154

Comment by Scott Hernandez (Inactive) [ 06/Jul/13 ]

Yes.

org.bson.types.Binary cannot be cast to [B
    at com.mongodb.DBPort$SaslAuthenticator.authenticate(DBPort.java:493)
    at com.mongodb.DBPort.authenticate(DBPort.java:322)
    at com.mongodb.DBPort.checkAuth(DBPort.java:333)
    at com.mongodb.DBTCPConnector.innerCall(DBTCPConnector.java:243)
    at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:216)
    at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:288)
    at com.mongodb.DB.command(DB.java:262)
    at com.mongodb.DB.command(DB.java:244)
    at com.mongodb.DB.command(DB.java:301)
    at com.mongodb.Mongo.getDatabaseNames(Mongo.java:384)

Comment by Jeffrey Yemin [ 06/Jul/13 ]

Are you getting an exception?

Generated at Thu Feb 08 08:53:15 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.