private void ReAuthenticateIfRequired() { // fAuthExpiration will only be set for CWSAuthentication or LegacyRCSAuthentication if (fAuthExpiration != null && fAuthExpiration.Value < DateTime.Now.AddMinutes(1)) { string token = ""; if (fAuthMode.Equals(AuthenticationMode.CWSAuthentication)) { token = fAuthService.AuthenticateUser(fUsername, fPassword); } else // AuthenticationMode.LegacyRCSAuthentication { //RCSAuthentication.OTAuthentication otAuthRCS = new RCSAuthentication.OTAuthentication(); //token = fRCSAuthService.AuthenticateApplication( ref otAuthRCS, fUsername, fPassword ); } OTCSAuthentication.OTAuthentication otAuth = new OTCSAuthentication.OTAuthentication(); otAuth.AuthenticationToken = token; fAuthExpiration = fAuthService.GetSessionExpirationDate(ref otAuth); UpdateAuthenticationTokens(otAuth.AuthenticationToken); } }
private string AuthenticateUser( string serviceRoot, string serviceSuffix, string username, string password) { string token = ""; InitAuthenticationService(serviceRoot, serviceSuffix); if (fAuthMode == AuthenticationMode.SingleSignOn) { BasicHttpBinding binding = (BasicHttpBinding)fAuthService.Endpoint.Binding; binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly; binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows; } else { token = fAuthService.AuthenticateUser(username, password); // get the expiry date for the token OTCSAuthentication.OTAuthentication otAuth = new OTCSAuthentication.OTAuthentication(); otAuth.AuthenticationToken = token; fAuthExpiration = fAuthService.GetSessionExpirationDate(ref otAuth); token = otAuth.AuthenticationToken; } return(token); }
private string AuthenticateUserRCS( string cwsServiceRoot, string cwsServiceSuffix, string rcsAuthServiceURL, string username, string password) { string token = ""; InitRCSAuthenticationService(rcsAuthServiceURL); //RCSAuthentication.OTAuthentication otAuthRCS = new RCSAuthentication.OTAuthentication(); //token = fRCSAuthService.AuthenticateApplication(ref otAuthRCS, username, password); if (fAuthMode.Equals(AuthenticationMode.LegacyRCSAuthentication)) { InitAuthenticationService(cwsServiceRoot, cwsServiceSuffix); // get the expiry date for the token OTCSAuthentication.OTAuthentication otAuthCS = new OTCSAuthentication.OTAuthentication(); otAuthCS.AuthenticationToken = token; fAuthExpiration = fAuthService.GetSessionExpirationDate(ref otAuthCS); token = otAuthCS.AuthenticationToken; } return(token); }