
com.arcadedb.server.security.ServerSecurityUser Maven / Gradle / Ivy
The newest version!
/*
* Copyright © 2021-present Arcade Data Ltd ([email protected])
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-FileCopyrightText: 2021-present Arcade Data Ltd ([email protected])
* SPDX-License-Identifier: Apache-2.0
*/
package com.arcadedb.server.security;
import com.arcadedb.database.Database;
import com.arcadedb.database.DatabaseInternal;
import com.arcadedb.security.SecurityManager;
import com.arcadedb.security.SecurityUser;
import com.arcadedb.serializer.json.JSONArray;
import com.arcadedb.serializer.json.JSONObject;
import com.arcadedb.server.ArcadeDBServer;
import java.util.*;
import java.util.concurrent.*;
public class ServerSecurityUser implements SecurityUser {
private final ArcadeDBServer server;
private final JSONObject userConfiguration;
private final String name;
private Set databasesNames;
private String password;
private final ConcurrentHashMap databaseCache = new ConcurrentHashMap();
public ServerSecurityUser(final ArcadeDBServer server, final JSONObject userConfiguration) {
this.server = server;
this.userConfiguration = userConfiguration;
this.name = userConfiguration.getString("name");
this.password = userConfiguration.has("password") ? userConfiguration.getString("password") : null;
if (userConfiguration.has("databases")) {
final JSONObject userDatabases = userConfiguration.getJSONObject("databases");
databasesNames = Collections.unmodifiableSet(userDatabases.keySet());
} else {
databasesNames = Collections.emptySet();
}
}
@Override
public ServerSecurityUser addDatabase(final String databaseName, final String[] groups) {
final Set newDatabaseName = new HashSet<>(databasesNames);
final JSONObject userDatabases = userConfiguration.getJSONObject("databases");
final Set
© 2015 - 2025 Weber Informatics LLC | Privacy Policy