// private constructor private TEMPOServerProxy() { // create the proxies _adminServices = new AdminServices.AdminServices(); _adminServices.Url = System.Configuration.ConfigurationManager.AppSettings["TEMPO.RequestBroker.AdminServices.AdminServices"]; _tsServices = new TSServices.TimeSheetServices(); _tsServices.Url = System.Configuration.ConfigurationManager.AppSettings["TEMPO.RequestBroker.TSServices.TimeSheetServices"]; _rsServices = new ReportingServices.ReportExecutionService(); _rsServices.Url = System.Configuration.ConfigurationManager.AppSettings["TEMPO.RequestBroker.ReportingServices.ReportingService"]; _rsServices.Credentials = new System.Net.NetworkCredential( System.Configuration.ConfigurationManager.AppSettings["TEMPO.Authorization.NetworkCredential.RS.UserName"], System.Configuration.ConfigurationManager.AppSettings["TEMPO.Authorization.NetworkCredential.RS.Password"], System.Configuration.ConfigurationManager.AppSettings["TEMPO.Authorization.NetworkCredential.RS.Domain"]); // authorization services _authservices = new TEMPO.Authorization.AuthFramework.AuthorizationServices(); _authservices.Url = System.Configuration.ConfigurationManager.AppSettings["TEMPO.Authorization.AuthFramework.AuthorizationServices"]; // Create a new instance of CredentialCache. CredentialCache credentialCache = new CredentialCache(); // Create a new instance of NetworkCredential using the client NetworkCredential credentials = new NetworkCredential(Thread.CurrentPrincipal.Identity.Name, ((TEMPOIdentity)Thread.CurrentPrincipal.Identity).Password); // Add the NetworkCredential to the CredentialCache for both proxies credentialCache.Add(new Uri(_adminServices.Url), "Basic", credentials); credentialCache.Add(new Uri(_tsServices.Url), "Basic", credentials); // Add the CredentialCache to the proxy class credentials. _tsServices.Credentials = credentialCache; _adminServices.Credentials = credentialCache; }
/// <summary> /// Create a new TEMPO Principal based on already establishd Identity /// </summary> /// <param name="identity">The TEMPOIdentity</param> public TEMPOPrincipal(TEMPOIdentity identity) { // assign to local var _identity = identity; // get the roles this user belongs too AuthFramework.AuthorizationServices authorization = new TEMPO.Authorization.AuthFramework.AuthorizationServices(); authorization.Url = System.Configuration.ConfigurationManager.AppSettings["TEMPO.Authorization.AuthFramework.AuthorizationServices"]; AuthFramework.AuthorizationDS authds = authorization.GetUserRoles(_identity.UserID); _roles = new string[authds.ModuleAuth.Count]; for (int i = 0; i < authds.ModuleAuth.Count; i++) { _roles[i] = authds.Module.FindByModuleID(authds.ModuleAuth[i].moduleid).ModuleName; } }
public TEMPOIdentity(string username, string password) { AuthFramework.AuthorizationServices authorization = new TEMPO.Authorization.AuthFramework.AuthorizationServices(); authorization.Url = System.Configuration.ConfigurationManager.AppSettings["TEMPO.Authorization.AuthFramework.AuthorizationServices"]; _userid = authorization.AuthenticateUser(username, password); if (_userid != -1) { _isauthenticated = true; _username = username; _password = password; } else { _isauthenticated = false; } }