1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package goldengate.ftp.exec.file;
22
23 import goldengate.common.logging.GgInternalLogger;
24 import goldengate.common.logging.GgInternalLoggerFactory;
25 import goldengate.ftp.exec.exec.AbstractExecutor.CommandExecutor;
26
27
28
29
30
31
32
33 public class SimpleAuth {
34
35
36
37 private static final GgInternalLogger logger = GgInternalLoggerFactory
38 .getLogger(SimpleAuth.class);
39
40
41
42
43 public String user = null;
44
45
46
47
48 public String password = null;
49
50
51
52
53 public String[] accounts = null;
54
55
56
57
58
59 public boolean isAdmin = false;
60
61
62
63 public String storCmd = null;
64
65
66
67 public long storDelay = 0;
68
69
70
71 public String retrCmd = null;
72
73
74
75 public long retrDelay = 0;
76
77 public CommandExecutor commandExecutor = null;
78
79
80
81
82
83
84
85
86
87
88 public SimpleAuth(String user, String password, String[] accounts,
89 String storCmd, long storDelay, String retrCmd, long retrDelay) {
90 this.user = user;
91 this.password = password;
92 this.accounts = accounts;
93 this.storCmd = storCmd;
94 this.storDelay = storDelay;
95 this.retrCmd = retrCmd;
96 this.retrDelay = retrDelay;
97 this.commandExecutor = new CommandExecutor(retrCmd, retrDelay, storCmd, storDelay);
98 logger.info("Executor for "+user+" configured as [RETR: "+
99 commandExecutor.pretrCMD+":"+commandExecutor.pretrDelay+":"+
100 commandExecutor.pretrRefused+
101 "] [STOR: "+commandExecutor.pstorCMD+":"+
102 commandExecutor.pstorDelay+":"+commandExecutor.pstorRefused+"]");
103 }
104
105
106
107
108
109
110
111 public boolean isPasswordValid(String newpassword) {
112 if (password == null) {
113 return true;
114 }
115 if (newpassword == null) {
116 return false;
117 }
118 return password.equals(newpassword);
119 }
120
121
122
123
124
125
126
127 public boolean isAccountValid(String account) {
128 if (accounts == null) {
129 logger.debug("No account needed");
130 return true;
131 }
132 if (account == null) {
133 logger.debug("No account given");
134 return false;
135 }
136 for (String acct: accounts) {
137 if (acct.equals(account)) {
138 logger.debug("Account found");
139 return true;
140 }
141 }
142 logger.debug("No account found");
143 return false;
144 }
145
146
147
148
149
150
151 public void setAdmin(boolean isAdmin) {
152 this.isAdmin = isAdmin;
153 }
154 }