mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-17 11:19:15 +00:00
bug6095: handle persistence aspect of "nulling" AICore credentials
This commit is contained in:
+11
-6
@@ -64,16 +64,21 @@ public class MongoObjectFactoryImpl implements MongoObjectFactory {
|
||||
|
||||
@Override
|
||||
public void updateCredentials(Credentials credentials, ClientSession clientSessionOrNull) {
|
||||
final Pair<String, String> credentialsAsEncodedStringAndSalt = CredentialsParser.create().getAsEncodedString(credentials);
|
||||
final Document credentialsDocument = new Document()
|
||||
.append(FieldNames.AIAGENT_CREDENTIALS_ENCODED_AS_STRING.name(), credentialsAsEncodedStringAndSalt.getA())
|
||||
.append(FieldNames.AIAGENT_CRETENTIALS_SALT.name(), credentialsAsEncodedStringAndSalt.getB());
|
||||
if (clientSessionOrNull == null) {
|
||||
credentialsCollection.drop();
|
||||
credentialsCollection.insertOne(credentialsDocument);
|
||||
} else {
|
||||
credentialsCollection.drop(clientSessionOrNull);
|
||||
credentialsCollection.insertOne(clientSessionOrNull, credentialsDocument);
|
||||
}
|
||||
if (credentials != null) {
|
||||
final Pair<String, String> credentialsAsEncodedStringAndSalt = CredentialsParser.create().getAsEncodedString(credentials);
|
||||
final Document credentialsDocument = new Document()
|
||||
.append(FieldNames.AIAGENT_CREDENTIALS_ENCODED_AS_STRING.name(), credentialsAsEncodedStringAndSalt.getA())
|
||||
.append(FieldNames.AIAGENT_CRETENTIALS_SALT.name(), credentialsAsEncodedStringAndSalt.getB());
|
||||
if (clientSessionOrNull == null) {
|
||||
credentialsCollection.insertOne(credentialsDocument);
|
||||
} else {
|
||||
credentialsCollection.insertOne(clientSessionOrNull, credentialsDocument);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user