C# Client Library
A C# Client Library for the AnalyzeRe REST API
Loading...
Searching...
No Matches
BasicAuthenticationToken.cs
Go to the documentation of this file.
1using System;
2using System.Security;
3using System.Text;
4
6{
12 {
14 public string AuthorizationMethod => "Basic";
15
17 public AccessTokenStatus status { get; set; } = AccessTokenStatus.Unknown;
18
20 public string access_token { get; set; }
21
23 public string username { get; private set; }
24
26 public SecureString password { get; private set; }
27
30
39
43 public void GenerateAccessToken(string token_username, string token_password)
44 {
45 username = token_username;
46 password = new SecureString();
47 foreach (char c in token_password) { password.AppendChar(c); }
48 password.MakeReadOnly();
49
50 string credentials = String.Format("{0}:{1}", username, token_password);
51 byte[] bytes = Encoding.ASCII.GetBytes(credentials);
52 access_token = Convert.ToBase64String(bytes);
53 }
54
59 public override string ToString() => AuthorizationMethod + " " + access_token;
60 }
61}
An AccessToken storing basic authentication information for requests made to the server.
override string ToString()
Returns the representation of this access token that could be placed in an "Authorization" header.
string username
The username associated with this authentication token.
AccessTokenStatus status
The AccessToken's current AccessTokenStatus (unauthorized / valid).
SecureString password
The password associated with this authentication token.
string AuthorizationMethod
The Authorization Method included in the Authorization header.
BasicAuthenticationToken(string username, string password)
Instantiate a new BasicAuthenticationToken with supplied username and password parameters supplied.
BasicAuthenticationToken()
Instantiate a new BasicAuthenticationToken.
void GenerateAccessToken(string token_username, string token_password)
Provide basic authentication credentials so the user can log in.
An AccessToken storing authentication information for requests made to the server.
AccessTokenStatus
An AccessToken's status (unauthorized / valid).