1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.waarp.http.protocol.servlet;
22
23 import org.waarp.common.command.exception.Reply421Exception;
24 import org.waarp.common.command.exception.Reply530Exception;
25 import org.waarp.http.protocol.HttpSession;
26 import org.waarp.openr66.context.R66Session;
27
28 import java.util.Map;
29
30
31
32
33
34 public class HttpAuthentDefault implements HttpAuthent {
35
36
37
38
39 protected String user;
40 protected byte[] key;
41
42
43
44
45 public HttpAuthentDefault() {
46
47 }
48
49 @Override
50 public final void initializeAuthent(final Map<String, String> arguments) {
51 user = arguments.get(FIELD_USER);
52 final String skey = arguments.get(FIELD_KEY);
53 key = org.waarp.common.digest.FilesystemBasedDigest.getFromHex(skey);
54 }
55
56 @Override
57 public final void checkAuthent(final HttpSession httpSession,
58 final R66Session session)
59 throws IllegalArgumentException {
60 try {
61 session.getAuth().connection(user, key, false);
62 } catch (final Reply530Exception e) {
63 httpSession.error(e, session.getBusinessObject());
64 } catch (final Reply421Exception e) {
65 httpSession.error(e, session.getBusinessObject());
66 }
67 }
68
69 @Override
70 public final String getUserId() {
71 return user;
72 }
73
74 @Override
75 public final void finalizeTransfer(final HttpSession httpSession,
76 final R66Session session)
77 throws IllegalArgumentException {
78
79 }
80 }