use of com.orientechnologies.orient.server.config.OServerUserConfiguration in project orientdb by orientechnologies.
the class OConsoleDatabaseApp method listServerUsers.
@SuppressWarnings("unchecked")
@ConsoleCommand(description = "Display all the server user names. For more information look at http://orientdb.com/docs/last/Security.html#orientdb-server-security", onlineHelp = "Console-Command-List-Server-User")
public void listServerUsers() {
final File serverCfgFile = new File("../config/orientdb-server-config.xml");
if (!serverCfgFile.exists())
throw new OConfigurationException("Cannot access to file " + serverCfgFile);
try {
final OServerConfigurationManager serverCfg = new OServerConfigurationManager(serverCfgFile);
message("\nSERVER USERS\n");
final Set<OServerUserConfiguration> users = serverCfg.getUsers();
if (users.isEmpty())
message("\nNo users found");
else
for (OServerUserConfiguration u : users) {
message("\n- '%s', permissions: %s", u.name, u.resources);
}
} catch (Exception e) {
error("\nError on loading %s file: %s", serverCfgFile, e.toString());
}
}
use of com.orientechnologies.orient.server.config.OServerUserConfiguration in project orientdb by orientechnologies.
the class ODistributedAbstractPlugin method getLocalNodeConfiguration.
@Override
public ODocument getLocalNodeConfiguration() {
final ODocument nodeCfg = new ODocument();
nodeCfg.setTrackingChanges(false);
nodeCfg.field("id", nodeId);
nodeCfg.field("uuid", nodeUuid);
nodeCfg.field("name", nodeName);
nodeCfg.field("publicAddress", getPublicAddress());
nodeCfg.field("startedOn", startedOn);
nodeCfg.field("status", getNodeStatus());
nodeCfg.field("connections", serverInstance.getClientConnectionManager().getTotal());
final List<Map<String, Object>> listeners = new ArrayList<Map<String, Object>>();
nodeCfg.field("listeners", listeners, OType.EMBEDDEDLIST);
for (OServerNetworkListener listener : serverInstance.getNetworkListeners()) {
final Map<String, Object> listenerCfg = new HashMap<String, Object>();
listeners.add(listenerCfg);
listenerCfg.put("protocol", listener.getProtocolType().getSimpleName());
listenerCfg.put("listen", listener.getListeningAddress(true));
}
// STORE THE TEMP USER/PASSWD USED FOR REPLICATION
final OServerUserConfiguration user = serverInstance.getUser(REPLICATOR_USER);
if (user != null)
nodeCfg.field("user_replicator", serverInstance.getUser(REPLICATOR_USER).password);
nodeCfg.field("databases", getManagedDatabases());
final long maxMem = Runtime.getRuntime().maxMemory();
final long totMem = Runtime.getRuntime().totalMemory();
final long freeMem = Runtime.getRuntime().freeMemory();
final long usedMem = totMem - freeMem;
nodeCfg.field("usedMemory", usedMem);
nodeCfg.field("freeMemory", freeMem);
nodeCfg.field("maxMemory", maxMem);
nodeCfg.field("latencies", getMessageService().getLatencies(), OType.EMBEDDED);
nodeCfg.field("messages", getMessageService().getMessageStats(), OType.EMBEDDED);
for (Iterator<ODatabaseLifecycleListener> it = Orient.instance().getDbLifecycleListeners(); it.hasNext(); ) {
final ODatabaseLifecycleListener listener = it.next();
if (listener != null)
listener.onLocalNodeConfigurationRequest(nodeCfg);
}
return nodeCfg;
}
use of com.orientechnologies.orient.server.config.OServerUserConfiguration in project orientdb by orientechnologies.
the class ODefaultPasswordAuthenticator method config.
// OSecurityComponent
public void config(final OServer oServer, final OServerConfigurationManager serverCfg, final ODocument jsonConfig) {
super.config(oServer, serverCfg, jsonConfig);
try {
if (jsonConfig.containsField("users")) {
List<ODocument> usersList = jsonConfig.field("users");
for (ODocument userDoc : usersList) {
OServerUserConfiguration userCfg = createServerUser(userDoc);
if (userCfg != null) {
String checkName = userCfg.name;
if (!isCaseSensitive())
checkName = checkName.toLowerCase(Locale.ENGLISH);
usersMap.put(checkName, userCfg);
}
}
}
} catch (Exception ex) {
OLogManager.instance().error(this, "config() Exception: %s", ex.getMessage());
}
}
use of com.orientechnologies.orient.server.config.OServerUserConfiguration in project orientdb by orientechnologies.
the class ODefaultPasswordAuthenticator method createServerUser.
// Derived implementations can override this method to provide new server user implementations.
protected OServerUserConfiguration createServerUser(final ODocument userDoc) {
OServerUserConfiguration userCfg = null;
if (userDoc.containsField("username") && userDoc.containsField("resources")) {
final String user = userDoc.field("username");
final String resources = userDoc.field("resources");
String password = userDoc.field("password");
if (password == null)
password = "";
userCfg = new OServerUserConfiguration(user, password, resources);
}
return userCfg;
}
use of com.orientechnologies.orient.server.config.OServerUserConfiguration in project orientdb by orientechnologies.
the class ODefaultServerSecurity method createSuperUser.
private void createSuperUser() {
if (superUser == null)
throw new OSecuritySystemException("ODefaultServerSecurity.createSuperUser() SuperUser cannot be null");
try {
// Assign a temporary password so that we know if authentication requests coming from the SuperUser are from us.
superUserPassword = OSecurityManager.instance().createSHA256(String.valueOf(new java.util.Random().nextLong()));
superUserCfg = new OServerUserConfiguration(superUser, superUserPassword, "*");
} catch (Exception ex) {
OLogManager.instance().error(this, "createSuperUser() Exception: ", ex);
}
if (superUserPassword == null)
throw new OSecuritySystemException("ODefaultServerSecurity Could not create SuperUser");
}
Aggregations