diff --git a/NSspi/Contexts/ClientContext.cs b/NSspi/Contexts/ClientContext.cs
index 60374ce..c68799d 100644
--- a/NSspi/Contexts/ClientContext.cs
+++ b/NSspi/Contexts/ClientContext.cs
@@ -24,7 +24,7 @@ namespace NSspi.Contexts
public SecurityStatus Init( byte[] serverToken, out byte[] outToken )
{
- long expiry = 0;
+ long rawExpiry = 0;
SecurityStatus status;
@@ -82,7 +82,7 @@ namespace NSspi.Contexts
ref this.ContextHandle.rawHandle,
outAdapter.Handle,
ref this.finalAttribs,
- ref expiry
+ ref rawExpiry
);
}
else
@@ -101,7 +101,7 @@ namespace NSspi.Contexts
ref this.ContextHandle.rawHandle,
outAdapter.Handle,
ref this.finalAttribs,
- ref expiry
+ ref rawExpiry
);
}
}
@@ -111,6 +111,8 @@ namespace NSspi.Contexts
{
this.Initialized = true;
outToken = null;
+
+ this.Expiry = TimeStamp.Calc( rawExpiry );
}
else if ( status == SecurityStatus.ContinueNeeded )
{
diff --git a/NSspi/Contexts/Context.cs b/NSspi/Contexts/Context.cs
index 37ebbf3..16acc7b 100644
--- a/NSspi/Contexts/Context.cs
+++ b/NSspi/Contexts/Context.cs
@@ -53,6 +53,8 @@ namespace NSspi.Contexts
}
}
+ public DateTime Expiry { get; protected set; }
+
public bool Disposed { get; private set; }
public void Dispose()
diff --git a/NSspi/Contexts/ServerContext.cs b/NSspi/Contexts/ServerContext.cs
index 39f66e5..9f80768 100644
--- a/NSspi/Contexts/ServerContext.cs
+++ b/NSspi/Contexts/ServerContext.cs
@@ -30,7 +30,7 @@ namespace NSspi.Contexts
SecureBuffer outBuffer = new SecureBuffer( new byte[12288], BufferType.Token );
SecurityStatus status;
- long expiry = 0;
+ long rawExpiry = 0;
SecureBufferAdapter clientAdapter;
SecureBufferAdapter outAdapter;
@@ -50,7 +50,7 @@ namespace NSspi.Contexts
ref this.ContextHandle.rawHandle,
outAdapter.Handle,
ref this.finalAttribs,
- ref expiry
+ ref rawExpiry
);
}
else
@@ -64,7 +64,7 @@ namespace NSspi.Contexts
ref this.ContextHandle.rawHandle,
outAdapter.Handle,
ref this.finalAttribs,
- ref expiry
+ ref rawExpiry
);
@@ -87,6 +87,8 @@ namespace NSspi.Contexts
nextToken = null;
}
+ this.Expiry = TimeStamp.Calc( rawExpiry );
+
InitProviderCapabilities();
}
else if ( status == SecurityStatus.ContinueNeeded )
diff --git a/NSspi/Credentials/Credential.cs b/NSspi/Credentials/Credential.cs
index 95371e4..55a8df0 100644
--- a/NSspi/Credentials/Credential.cs
+++ b/NSspi/Credentials/Credential.cs
@@ -19,14 +19,15 @@ namespace NSspi.Credentials
private SecurityPackage securityPackage;
private SafeCredentialHandle safeCredHandle;
- private long expiry;
+
+ private DateTime expiry;
public Credential(SecurityPackage package, CredentialType credentialType)
{
this.disposed = false;
this.securityPackage = package;
- this.expiry = 0;
+ this.expiry = DateTime.MinValue;
Init( package, credentialType );
}
@@ -35,6 +36,7 @@ namespace NSspi.Credentials
{
string packageName;
CredentialUse use;
+ long rawExpiry = 0;
// -- Package --
if ( package == SecurityPackage.Kerberos )
@@ -90,7 +92,7 @@ namespace NSspi.Credentials
IntPtr.Zero,
IntPtr.Zero,
ref this.safeCredHandle.rawHandle,
- ref this.expiry
+ ref rawExpiry
);
}
@@ -98,6 +100,8 @@ namespace NSspi.Credentials
{
throw new SSPIException( "Failed to call AcquireCredentialHandle", status );
}
+
+ this.expiry = TimeStamp.Calc( rawExpiry );
}
~Credential()
@@ -177,6 +181,14 @@ namespace NSspi.Credentials
}
}
+ public DateTime Expiry
+ {
+ get
+ {
+ return this.expiry;
+ }
+ }
+
public SafeCredentialHandle Handle
{
get
@@ -203,6 +215,5 @@ namespace NSspi.Credentials
this.disposed = true;
}
}
-
}
}
diff --git a/NSspi/NSspi.csproj b/NSspi/NSspi.csproj
index b8c65d8..dba79ff 100644
--- a/NSspi/NSspi.csproj
+++ b/NSspi/NSspi.csproj
@@ -80,6 +80,7 @@
+
diff --git a/NSspi/TimeStamp.cs b/NSspi/TimeStamp.cs
new file mode 100644
index 0000000..32ece40
--- /dev/null
+++ b/NSspi/TimeStamp.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace NSspi
+{
+ public static class TimeStamp
+ {
+ public static readonly DateTime Epoch = new DateTime( 1601, 1, 1, 0, 0, 0, DateTimeKind.Utc );
+
+ public static DateTime Calc( long rawExpiry )
+ {
+ return TimeStamp.Epoch.AddTicks( rawExpiry );
+ }
+ }
+}