Revision 5d80d038
b/trunk/Pithos.Client.WPF/PithosAccount.cs | ||
---|---|---|
139 | 139 |
public static Uri GetLoginUri(Uri serverUri) |
140 | 140 |
{ |
141 | 141 |
//<=0.13 |
142 |
var loginUri = serverUri.Combine("/login");
|
|
142 |
var loginUri = serverUri.Combine("login"); |
|
143 | 143 |
//var loginUri = new Uri("https://astakos.synnefo.dev.grnet.gr/astakos/weblogin/login"); |
144 |
|
|
145 |
//>0.13 |
|
146 |
|
|
147 |
var tokenUri = serverUri.Combine("astakos/identity/v2.0/tokens"); |
|
148 |
|
|
149 |
// WebClient webClient = new WebClient(); |
|
144 |
// WebClient webClient = new WebClient(); |
|
150 | 145 |
// string catalogResult = webClient.UploadString(tokenUri, ""); |
151 | 146 |
// MessageBox.Show(tokenUri.ToString()); |
152 | 147 |
|
153 |
WebRequest webRequest = WebRequest.Create(tokenUri);
|
|
148 |
WebRequest webRequest = WebRequest.Create(serverUri);
|
|
154 | 149 |
webRequest.Method = "POST"; |
155 | 150 |
|
151 |
try |
|
152 |
{ |
|
156 | 153 |
using (WebResponse response = webRequest.GetResponse()) |
157 | 154 |
{ |
155 |
try |
|
156 |
{ |
|
157 |
using (Stream stream = response.GetResponseStream()) |
|
158 |
{ |
|
159 |
StreamReader read = new StreamReader(stream, true); |
|
160 |
String responseStr = read.ReadToEnd(); |
|
161 |
|
|
162 |
dynamic okeanosServices = JsonConvert.DeserializeObject(responseStr); |
|
163 |
|
|
164 |
Uri webLogin = new Uri(okeanosServices["access"]["serviceCatalog"][0]["endpoints"][0]["publicURL"].ToString()); |
|
165 |
|
|
166 |
webLogin = webLogin.Combine("login"); |
|
167 |
|
|
168 |
//foreach (var service in okeanosServices["access"]["serviceCatalog"]) |
|
169 |
//{ |
|
170 |
// foreach (var epoint in service["endpoints"]) |
|
171 |
// { |
|
172 |
// } |
|
173 |
//} |
|
174 |
// Dictionary<string, string> OkeanosServices = JsonConvert.DeserializeObject<Dictionary<string, string>>(responseStr); |
|
175 |
return webLogin; |
|
176 |
} |
|
177 |
} |
|
158 | 178 |
|
159 |
using (Stream stream = response.GetResponseStream())
|
|
179 |
catch (Exception ex)
|
|
160 | 180 |
{ |
161 |
StreamReader read = new StreamReader(stream, true); |
|
162 |
String responseStr = read.ReadToEnd(); |
|
181 |
MessageBox.Show("Stream Failed"); |
|
182 |
return loginUri; |
|
183 |
} |
|
163 | 184 |
|
164 |
Dictionary<string, string> Services = JsonConvert.DeserializeObject<Dictionary<string, string>>(responseStr); |
|
165 | 185 |
|
166 |
// var myService = JsonConvert.DeserializeObject<accessUris>(responseStr); |
|
167 |
// MessageBox.Show(myService.access.ToString()); |
|
168 |
} |
|
169 |
} |
|
170 |
return loginUri; |
|
186 |
} |
|
171 | 187 |
} |
188 |
|
|
189 |
catch (Exception ex) |
|
190 |
{ |
|
191 |
MessageBox.Show("Service URL Failed"); |
|
192 |
return loginUri; |
|
193 |
} |
|
194 |
} |
|
172 | 195 |
|
173 | 196 |
|
174 | 197 |
} |
Also available in: Unified diff