[JAVA-1958] SCRAM-SHA1 authentication is not available on Android Created: 11/Sep/15  Updated: 01/Mar/18  Resolved: 04/Oct/16

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

Type: Improvement Priority: Major - P3
Reporter: Matteo Furlan Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: Android
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Android 21


Issue Links:
Duplicate
duplicates JAVA-2792 Server Connection Closed
is duplicated by JAVA-2026 Use of MongoCredential throws unhandl... Closed

 Description   

New description:

As of MongoDB 3.0, the default authentication protocol is a SASL implementation of SCRAM-SHA1. The driver relies on the following classes to implement it:

import javax.crypto.Mac;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.SecretKeySpec;
import javax.security.sasl.SaslClient;
import javax.security.sasl.SaslException

Some or all of these are not available on Android, which does not offer a full implementation of the JRE.

Also of note is that PLAIN and GSSAPI authentication mechanisms also rely on the availability of a SASL library, so those won't function properly either.

Previous description:

I'm developing an Android app that use the java mongodb driver 3.0.3 to connect to every instance of mongodb.

At runtime I have some error:

09-11 19:13:50.898 7418-7418/it.mysite.mongodbviewer W/org.bson.ObjectId﹕ Failed to get process identifier from JMX, using random number instead java.lang.NoClassDefFoundError: Failed resolution of: Ljava/lang/management/ManagementFactory;

and

com.mongodb.MongoException: java.lang.NoClassDefFoundError: com.mongodb.connection.ScramSha1Authenticator$ScramSha1SaslClient
that generate a loop with this:

I/art﹕ Rejecting re-init on previously-failed class java.lang.Class

Anyone has a solution? java/lang/management/ManagementFactory seems not to exist for Android, how can you solve? If this is the center of the problem.

More information at http://stackoverflow.com/questions/32529484/mongodb-3-x-driver-android-compatibility/32531278#32531278



 Comments   
Comment by Ross Lawley [ 04/Oct/16 ]

Due to the limitations of Android JRE the classes aren't available. Currently, there are no plans to support this, so I'm closing the ticket as Won't Fix.

Comment by tzachi dar [ 25/Sep/15 ]

Seems like I was able to find something very limited that work:
This "s=%7B%22CaptureDateTime%22:%20-1%7D&l=1" does a query that gets one object (l=1) ordered by CaptureDateTime.

Comment by tzachi dar [ 25/Sep/15 ]

Hi, I have tried to use the rest api instead of the mongodb on android.

Storing objects seems to work fine (using the rest api). but when doing a query I can't seem to have the query details actually work.

I try to follow the rules on http://docs.mongolab.com/data-api/#utf-8

for example, I try to follow this example:

"f" example (include) - return all documents but include only the "firstName" and "lastName" fields:
https://api.mongolab.com/api/1/databases/my-db/collections/my-coll?f=

{"firstName": 1, "lastName": 1}

&apiKey=myAPIKey

and it does not work.
I get all the objects.

My query is "f=

{\"CaptureDateTime\": 1}

";

This is being translated to f%3D%7B%22CaptureDateTime%22%3A%201%7D

and so my query is:

String url = BASE_URL + dbName + "/collections/" + collectionName "?" + f%3D%7B%22CaptureDateTime%22%3A%201%7D "apiKey=" + apiKey;

but I get all thoughts of objects.

Do you know what I'm doing wrong?
Can you please give me examples to queries that work in java. (or maybe in other languages)?

Comment by Jeffrey Yemin [ 14/Sep/15 ]

As I stated earlier we don't consider this a bug, but we will consider this as a feature request.

Comment by Matteo Furlan [ 12/Sep/15 ]

Hi Jeff,
excuse me, I answered just now on Stack Overflow. I haven't received any mail from the site.
Did you know if is scheduled for the addition of compatibility for Android? Can I require it?
Thanks alot for the disponibility

Comment by Jeffrey Yemin [ 11/Sep/15 ]

Hi Matteo,

The Java driver documentation has never claimed Android support, so I don't consider this to be a bug. As I answered on Stack Overflow, the reason it doesn't work is because Android does not contain the full set of classes required by a compliant implementation of the JRE. That said, I offered several workarounds and suggestions on Stack Overflow, and I'm happy to continue discussing the available options.

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