Search in sources :

Example 1 with OServerUserConfiguration

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());
    }
}
Also used : OConfigurationException(com.orientechnologies.orient.core.exception.OConfigurationException) OServerUserConfiguration(com.orientechnologies.orient.server.config.OServerUserConfiguration) OServerConfigurationManager(com.orientechnologies.orient.server.config.OServerConfigurationManager) OSystemException(com.orientechnologies.common.exception.OSystemException) OConfigurationException(com.orientechnologies.orient.core.exception.OConfigurationException) ORetryQueryException(com.orientechnologies.orient.core.exception.ORetryQueryException) OIOException(com.orientechnologies.common.io.OIOException) ODatabaseException(com.orientechnologies.orient.core.exception.ODatabaseException) ConsoleCommand(com.orientechnologies.common.console.annotation.ConsoleCommand)

Example 2 with OServerUserConfiguration

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;
}
Also used : OServerUserConfiguration(com.orientechnologies.orient.server.config.OServerUserConfiguration) OServerNetworkListener(com.orientechnologies.orient.server.network.OServerNetworkListener) OClusterPositionMap(com.orientechnologies.orient.core.storage.impl.local.paginated.OClusterPositionMap) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 3 with OServerUserConfiguration

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());
    }
}
Also used : OServerUserConfiguration(com.orientechnologies.orient.server.config.OServerUserConfiguration) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 4 with OServerUserConfiguration

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;
}
Also used : OServerUserConfiguration(com.orientechnologies.orient.server.config.OServerUserConfiguration)

Example 5 with OServerUserConfiguration

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");
}
Also used : OServerUserConfiguration(com.orientechnologies.orient.server.config.OServerUserConfiguration)

Aggregations

OServerUserConfiguration (com.orientechnologies.orient.server.config.OServerUserConfiguration)5 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)2 ConsoleCommand (com.orientechnologies.common.console.annotation.ConsoleCommand)1 OSystemException (com.orientechnologies.common.exception.OSystemException)1 OIOException (com.orientechnologies.common.io.OIOException)1 OConfigurationException (com.orientechnologies.orient.core.exception.OConfigurationException)1 ODatabaseException (com.orientechnologies.orient.core.exception.ODatabaseException)1 ORetryQueryException (com.orientechnologies.orient.core.exception.ORetryQueryException)1 OClusterPositionMap (com.orientechnologies.orient.core.storage.impl.local.paginated.OClusterPositionMap)1 OServerConfigurationManager (com.orientechnologies.orient.server.config.OServerConfigurationManager)1 OServerNetworkListener (com.orientechnologies.orient.server.network.OServerNetworkListener)1