use of com.orientechnologies.orient.server.security.ODefaultServerSecurity in project orientdb by orientechnologies.
the class OServer method activate.
@SuppressWarnings("unchecked")
public OServer activate() throws ClassNotFoundException, InstantiationException, IllegalAccessException {
try {
serverSecurity = new ODefaultServerSecurity(this, serverCfg);
Orient.instance().setSecurity(serverSecurity);
// Checks to see if the OrientDB System Database exists and creates it if not.
// Make sure this happens after setSecurityFactory() is called.
initSystemDatabase();
for (OServerLifecycleListener l : lifecycleListeners) l.onBeforeActivate();
final OServerConfiguration configuration = serverCfg.getConfiguration();
tokenHandler = new OTokenHandlerImpl(this);
if (configuration.network != null) {
// REGISTER/CREATE SOCKET FACTORIES
if (configuration.network.sockets != null) {
for (OServerSocketFactoryConfiguration f : configuration.network.sockets) {
Class<? extends OServerSocketFactory> fClass = (Class<? extends OServerSocketFactory>) loadClass(f.implementation);
OServerSocketFactory factory = fClass.newInstance();
try {
factory.config(f.name, f.parameters);
networkSocketFactories.put(f.name, factory);
} catch (OConfigurationException e) {
OLogManager.instance().error(this, "Error creating socket factory", e);
}
}
}
// REGISTER PROTOCOLS
for (OServerNetworkProtocolConfiguration p : configuration.network.protocols) networkProtocols.put(p.name, (Class<? extends ONetworkProtocol>) loadClass(p.implementation));
// STARTUP LISTENERS
for (OServerNetworkListenerConfiguration l : configuration.network.listeners) networkListeners.add(new OServerNetworkListener(this, networkSocketFactories.get(l.socket), l.ipAddress, l.portRange, l.protocol, networkProtocols.get(l.protocol), l.parameters, l.commands));
} else
OLogManager.instance().warn(this, "Network configuration was not found");
try {
loadStorages();
loadUsers();
loadDatabases();
} catch (IOException e) {
final String message = "Error on reading server configuration";
OLogManager.instance().error(this, message, e);
throw OException.wrapException(new OConfigurationException(message), e);
}
registerPlugins();
for (OServerLifecycleListener l : lifecycleListeners) l.onAfterActivate();
running = true;
String httpAddress = "localhost:2480";
for (OServerNetworkListener listener : getNetworkListeners()) {
if (listener.getProtocolType().getName().equals(ONetworkProtocolHttpDb.class.getName()))
httpAddress = listener.getListeningAddress(true);
}
OLogManager.instance().info(this, "OrientDB Studio available at $ANSI{blue http://%s/studio/index.html}", httpAddress);
OLogManager.instance().info(this, "$ANSI{green:italic OrientDB Server is active} v" + OConstants.getVersion() + ".");
} catch (ClassNotFoundException e) {
running = false;
throw e;
} catch (InstantiationException e) {
running = false;
throw e;
} catch (IllegalAccessException e) {
running = false;
throw e;
} catch (RuntimeException e) {
running = false;
throw e;
} finally {
startupLatch.countDown();
}
return this;
}
Aggregations