diff --git a/ArcGISRESTAdmin/AGSClient.cs b/ArcGISRESTAdmin/AGSClient.cs
index 491e7b0..2c8fb1e 100644
--- a/ArcGISRESTAdmin/AGSClient.cs
+++ b/ArcGISRESTAdmin/AGSClient.cs
@@ -70,7 +70,7 @@ public AGSClient(string serverUrl, string username, string password)
/// Authenticate against the defined ArcGIS Server and store the received token for future administrative requests.
///
///
- public async Task Authenticate()
+ public async Task Authenticate(int? desiredExpiration = null)
{
Uri encryptionInfoEndpoint = new Uri(ServerUrl, "publicKey");
var ei = await GetStringAsync(encryptionInfoEndpoint, addToken: false);
@@ -78,7 +78,7 @@ public async Task Authenticate()
byte[] exponent = EncodingHelper.HexToBytes(ei["publicKey"].Value());
byte[] modulus = EncodingHelper.HexToBytes(ei["modulus"].Value());
- string encryptedUsername, encryptedPassword, encryptedClient;
+ string encryptedUsername, encryptedPassword, encryptedClient, encryptedExpiration = null;
using (RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(512))
{
@@ -88,14 +88,17 @@ public async Task Authenticate()
encryptedUsername = EncodingHelper.BytesToHex(rsa.Encrypt(Encoding.UTF8.GetBytes(Username), false));
encryptedPassword = EncodingHelper.BytesToHex(rsa.Encrypt(Encoding.UTF8.GetBytes(Password), false));
encryptedClient = EncodingHelper.BytesToHex(rsa.Encrypt(Encoding.UTF8.GetBytes("requestip"), false));
+ if (desiredExpiration != null) encryptedExpiration = EncodingHelper.BytesToHex(rsa.Encrypt(Encoding.UTF8.GetBytes(desiredExpiration.Value.ToString()), false));
}
Uri tokenEndpoint = new Uri(ServerUrl, "generateToken");
- var data = new[] { new KeyValuePair("username", encryptedUsername),
- new KeyValuePair("password", encryptedPassword),
- new KeyValuePair("client", encryptedClient),
- new KeyValuePair("encrypted", "true") };
+ var data = new Dictionary();
+ data["username"] = encryptedUsername;
+ data["password"] = encryptedPassword;
+ data["client"] = encryptedClient;
+ if (encryptedExpiration != null) data["expiration"] = encryptedExpiration;
+ data["encrypted"] = "true";
var content = new FormUrlEncodedContent(data);
var tokenInfo = await PostAsync(tokenEndpoint, content, addToken: false);
diff --git a/ArcGISRestCLI/Program.cs b/ArcGISRestCLI/Program.cs
index 346a31c..925bbc4 100644
--- a/ArcGISRestCLI/Program.cs
+++ b/ArcGISRestCLI/Program.cs
@@ -71,9 +71,9 @@ static async Task DoWork()
// upload a pre-created .sd to create a new service
- Console.Out.WriteLine(@"Uploading C:\Presentations\Demo.sd..");
+ //Console.Out.WriteLine(@"Uploading C:\Presentations\Demo.sd..");
- var publishResponse = await ags.PublishServiceDefinition(new System.IO.FileInfo(@"C:\Presentations\Demo.sd"));
+ //var publishResponse = await ags.PublishServiceDefinition(new System.IO.FileInfo(@"C:\Presentations\Demo.sd"));
}
}
}