aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs67
1 files changed, 45 insertions, 22 deletions
diff --git a/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs b/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs
index 47bc860..ae71945 100644
--- a/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs
@@ -49,11 +49,20 @@ namespace OpenSim.Server.Handlers.Authentication
49 // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 49 // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50 50
51 private IAuthenticationService m_AuthenticationService; 51 private IAuthenticationService m_AuthenticationService;
52 private bool m_AllowSetPassword = false;
52 53
53 public AuthenticationServerPostHandler(IAuthenticationService service) : 54 public AuthenticationServerPostHandler(IAuthenticationService service) :
55 this(service, null) {}
56
57 public AuthenticationServerPostHandler(IAuthenticationService service, IConfig config) :
54 base("POST", "/auth") 58 base("POST", "/auth")
55 { 59 {
56 m_AuthenticationService = service; 60 m_AuthenticationService = service;
61
62 if (config != null)
63 {
64 m_AllowSetPassword = config.GetBoolean("AllowSetPassword", m_AllowSetPassword);
65 }
57 } 66 }
58 67
59 public override byte[] Handle(string path, Stream request, 68 public override byte[] Handle(string path, Stream request,
@@ -113,31 +122,45 @@ namespace OpenSim.Server.Handlers.Authentication
113 122
114 switch (method) 123 switch (method)
115 { 124 {
116 case "authenticate": 125 case "authenticate":
117 if (!request.ContainsKey("PASSWORD")) 126 if (!request.ContainsKey("PASSWORD"))
127 return FailureResult();
128
129 token = m_AuthenticationService.Authenticate(principalID, request["PASSWORD"].ToString(), lifetime);
130
131 if (token != String.Empty)
132 return SuccessResult(token);
118 return FailureResult(); 133 return FailureResult();
119 134
120 token = m_AuthenticationService.Authenticate(principalID, request["PASSWORD"].ToString(), lifetime); 135 case "setpassword":
121 136 if (!m_AllowSetPassword)
122 if (token != String.Empty) 137 return FailureResult();
123 return SuccessResult(token); 138
124 return FailureResult(); 139 if (!request.ContainsKey("PASSWORD"))
125 case "verify": 140 return FailureResult();
126 if (!request.ContainsKey("TOKEN")) 141
142 if (m_AuthenticationService.SetPassword(principalID, request["PASSWORD"].ToString()))
143 return SuccessResult();
144 else
145 return FailureResult();
146
147 case "verify":
148 if (!request.ContainsKey("TOKEN"))
149 return FailureResult();
150
151 if (m_AuthenticationService.Verify(principalID, request["TOKEN"].ToString(), lifetime))
152 return SuccessResult();
153
127 return FailureResult(); 154 return FailureResult();
128 155
129 if (m_AuthenticationService.Verify(principalID, request["TOKEN"].ToString(), lifetime)) 156 case "release":
130 return SuccessResult(); 157 if (!request.ContainsKey("TOKEN"))
131 158 return FailureResult();
132 return FailureResult(); 159
133 case "release": 160 if (m_AuthenticationService.Release(principalID, request["TOKEN"].ToString()))
134 if (!request.ContainsKey("TOKEN")) 161 return SuccessResult();
162
135 return FailureResult(); 163 return FailureResult();
136
137 if (m_AuthenticationService.Release(principalID, request["TOKEN"].ToString()))
138 return SuccessResult();
139
140 return FailureResult();
141 } 164 }
142 165
143 return FailureResult(); 166 return FailureResult();