blob: a3a2db65010d61dcb2af3af9a1a95d2a6ea0f3ba (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
package server;
import java.rmi.*;
import java.rmi.registry.LocateRegistry;
import java.rmi.server.UnicastRemoteObject;
import java.sql.Connection;
import java.util.UUID;
import Models.*;
import sql.SQL;
@SuppressWarnings("serial")
public class ServerMethod extends UnicastRemoteObject implements ServerInterface
{
protected static String m_strName;
public ServerMethod() throws RemoteException
{
super(); // call base class constructor
}
public static void main(String argv[])
{
try
{
LocateRegistry.createRegistry(9999);
m_strName = "TheRMIExample";
System.out.println("Server: Registering RMIExampleImpl as \"" + m_strName +"\"");
//System.setSecurityManager(new RMISecurityManager());
ServerMethod Example = new ServerMethod();
Naming.rebind("rmi://141.79.128.121:9999/"+m_strName, Example);
System.out.println("Server: Ready...");
}
catch (Exception e)
{
System.out.println("Server: Failed to register RMIExampleImpl: " + e);
}
}
@Override
public User getFtpUser() throws RemoteException {
User user=new User();
user.setUsername(UUID.randomUUID().toString().substring(0, 8));
user.setPass(UUID.randomUUID().toString().substring(0, 8));
user.setPath("/srv/openslx/nfs/temp");
SQL sql=new SQL();
Connection con=sql.getConnection();
sql.writeFTPUser(con, user.getUsername(), user.getPass());
return user;
}
@Override
public int DeleteFtpUser(String user) throws RemoteException {
SQL sql=new SQL();
Connection con=sql.getConnection();
int ret = sql.DeleteUser(con, user);
return ret;
}
}
|