use of com.orientechnologies.orient.server.config.OServerConfigurationManager in project orientdb by orientechnologies.
the class OConsoleDatabaseApp method dropServerUser.
@SuppressWarnings("unchecked")
@ConsoleCommand(description = "Drop a server user. For more information look at http://orientdb.com/docs/last/Security.html#orientdb-server-security", onlineHelp = "Console-Command-Drop-Server-User")
public void dropServerUser(@ConsoleParameter(name = "user-name", description = "User name") String iServerUserName) {
if (iServerUserName == null || iServerUserName.length() == 0)
throw new IllegalArgumentException("User name null or empty");
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);
if (!serverCfg.existsUser(iServerUserName)) {
error("\nServer user '%s' not found in configuration", iServerUserName);
return;
}
serverCfg.dropUser(iServerUserName);
serverCfg.saveConfiguration();
message("\nServer user '%s' dropped correctly", iServerUserName);
} catch (Exception e) {
error("\nError on loading %s file: %s", serverCfgFile, e.toString());
}
}
use of com.orientechnologies.orient.server.config.OServerConfigurationManager 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.OServerConfigurationManager in project orientdb by orientechnologies.
the class OConsoleDatabaseApp method setServerUser.
@SuppressWarnings("unchecked")
@ConsoleCommand(description = "Set a server user. If the user already exists, the password and permissions are updated. For more information look at http://orientdb.com/docs/last/Security.html#orientdb-server-security", onlineHelp = "Console-Command-Set-Server-User")
public void setServerUser(@ConsoleParameter(name = "user-name", description = "User name") String iServerUserName, @ConsoleParameter(name = "user-password", description = "User password") String iServerUserPasswd, @ConsoleParameter(name = "user-permissions", description = "Permissions, look at http://orientdb.com/docs/last/Security.html#servers-resources") String iPermissions) {
if (iServerUserName == null || iServerUserName.length() == 0)
throw new IllegalArgumentException("User name null or empty");
if (iPermissions == null || iPermissions.length() == 0)
throw new IllegalArgumentException("User permissions null or empty");
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);
final String defAlgo = OGlobalConfiguration.SECURITY_USER_PASSWORD_DEFAULT_ALGORITHM.getValueAsString();
final String hashedPassword = OSecurityManager.instance().createHash(iServerUserPasswd, defAlgo, true);
serverCfg.setUser(iServerUserName, hashedPassword, iPermissions);
serverCfg.saveConfiguration();
message("\nServer user '%s' set correctly", iServerUserName);
} catch (Exception e) {
error("\nError on loading %s file: %s", serverCfgFile, e.toString());
}
}
use of com.orientechnologies.orient.server.config.OServerConfigurationManager in project orientdb by orientechnologies.
the class HookInstallServerTest method before.
@Before
public void before() throws MalformedObjectNameException, InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException, ClassNotFoundException, NullPointerException, IOException, IllegalArgumentException, SecurityException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
server = new OServer();
OServerConfigurationManager ret = new OServerConfigurationManager(this.getClass().getClassLoader().getResourceAsStream("com/orientechnologies/orient/server/network/orientdb-server-config.xml"));
OServerHookConfiguration hc = new OServerHookConfiguration();
hc.clazz = MyHook.class.getName();
ret.getConfiguration().hooks = new ArrayList<OServerHookConfiguration>();
ret.getConfiguration().hooks.add(hc);
server.startup(ret.getConfiguration());
server.activate();
OServerAdmin admin = new OServerAdmin("remote:localhost");
admin.connect("root", "D2AFD02F20640EC8B7A5140F34FCA49D2289DB1F0D0598BB9DE8AAA75A0792F3");
admin.createDatabase("test", "nothign", "memory");
admin.close();
}
Aggregations