Пример #1
0
 public static ClientConnection Connection(MetlConfiguration config,Credentials creds,IAuditor auditor)
 {
     return auditor.wrapFunction(((auditAction) =>
     {
         var webCreds = new NetworkCredential(creds.name, creds.password);
         auditAction(GaugeStatus.InProgress,7);
         //var jabberCreds = new Credentials(config.xmppUsername, config.xmppPassword,new List<AuthorizedGroup>(),"");
         var wcf = new WebClientFactory(webCreds,auditor,creds);
         auditAction(GaugeStatus.InProgress,14);
         var receiveEvents = new ProductionReceiveEvents(auditor);
         auditAction(GaugeStatus.InProgress,21);
         var authProvider = new AuthorisationProvider(wcf, config,auditor);
         auditAction(GaugeStatus.InProgress,28);
         var httpProvider = new HttpResourceProvider(wcf,auditor);
         auditAction(GaugeStatus.InProgress,35);
         var resourceUploaderFactory = new ProductionResourceUploaderFactory(config, httpProvider,auditor);
         auditAction(GaugeStatus.InProgress,42);
         var resourceUploader = resourceUploaderFactory.get();
         auditAction(GaugeStatus.InProgress,49);
         var resourceCache = new ResourceCache();
         auditAction(GaugeStatus.InProgress,56);
         var configurationProvider = new ConfigurationProvider(wcf,auditor);
         auditAction(GaugeStatus.InProgress,63);
         auditAction(GaugeStatus.InProgress,70);
         var jabberWireFactory = new JabberWireFactory(config, creds, configurationProvider,resourceUploader,resourceCache, receiveEvents, wcf, httpProvider,auditor);
         auditAction(GaugeStatus.InProgress,77);
         var userOptionsProvider = new UserOptionsProvider(config, httpProvider, resourceUploader);
         auditAction(GaugeStatus.InProgress,84);
         var cc = new ClientConnection(config, receiveEvents, authProvider, resourceUploader, jabberWireFactory.conversationDetailsProvider, resourceCache, jabberWireFactory, wcf, userOptionsProvider, httpProvider,auditor);
         auditAction(GaugeStatus.InProgress, 91);
         return cc;
     }), "create client connection", "backend");
 }
 public IClientBehaviour connect(Credentials _creds)
 {
     return App.auditor.wrapFunction((g) =>
     {
         credentials = _creds;
         client = buildServerSpecificClient(config, _creds);
         g(GaugeStatus.InProgress,33);
         MeTLLib.MeTLLibEventHandlers.StatusChangedEventHandler checkValidity = null;
         checkValidity = (sender, e) =>
         {
             if (e.isConnected && e.credentials.authorizedGroups.Count > 0)
             {
                 registerCommands();
                 attachToClient();
                 Commands.AllStaticCommandsAreRegistered();
                 client.events.StatusChanged -= checkValidity;
                 Commands.SetIdentity.Execute(e.credentials);
             }
             else
             {
                 if (WorkspaceStateProvider.savedStateExists())
                 {
                     Commands.LogOut.Execute(true);
                 }
             }
         };
         client.events.StatusChanged += checkValidity;
         g(GaugeStatus.InProgress,66);
         if (!client.Connect(credentials))
         {
             Commands.LoginFailed.Execute(null);
         }
         return client;
     }, "networkController connect", "backend");
 }
 public void update(Credentials other)
 {
     name = other.name;
     password = other.password;
     authorizedGroups = other.authorizedGroups;
     mail = other.mail;
     cookie = other.cookie;
 }
Пример #4
0
 public PrintParser(
     Credentials credentials,
     int room,
     MeTLLib.Providers.Structure.IConversationDetailsProvider conversationDetailsProvider,
     HttpHistoryProvider historyProvider,
     CachedHistoryProvider cachedHistoryProvider,
     MetlConfiguration metlServerAddress,
     ResourceCache cache,
     IReceiveEvents receiveEvents,
     IWebClientFactory webClientFactory,
     HttpResourceProvider httpResourceProvider,
     IAuditor _auditor)
     : base(credentials, room, conversationDetailsProvider, historyProvider, cachedHistoryProvider, metlServerAddress, cache, receiveEvents, webClientFactory, httpResourceProvider,_auditor)
 {
 }
Пример #5
0
 private void establishWebMeTLConnection(Credentials cred)
 {
     try
     {
         //setupChrome();
         if (client != null)
             client = null;
         client = setupCAS(cred);
         hideStack();
         if (!String.IsNullOrEmpty(Globals.conversationDetails.Jid))
            JoinConversation(Globals.conversationDetails.Jid); 
     }
     catch (Exception ex)
     {
         App.Now("failed to setup WebMeTL connection with exception: " + ex.Message);
         showRetryWindow();
     }
 }
        public Credentials attemptAuthentication(string username, string password)
        {
            if (!String.IsNullOrEmpty(username) && !String.IsNullOrEmpty(password))
            {
                string AuthcateUsername = username;
                string AuthcatePassword = password;
                var token = login(AuthcateUsername, AuthcatePassword);
                if (token.authenticated)
                {
                    var eligibleGroups = token.groups;
                    var credentials = new Credentials(AuthcateUsername, AuthcatePassword, eligibleGroups, token.mail);
                    //Globals.credentials = credentials;
                    return credentials;
                }
            }

            _auditor.log("attemptAuthentication - failed to login","AuthorizationProvider");
            return Credentials.Empty;
        }
 public void attemptAuthenticationIntegrationTest()
 {
     string username = "******";
     string password = "******";
     IKernel kernel = new StandardKernel(new BaseModule());
     kernel.Bind<MeTLServerAddress>().To<ProductionServerAddress>().InSingletonScope();
     kernel.Bind<IWebClientFactory>().To<WebClientFactory>().InSingletonScope();
     kernel.Bind<ICredentials>().To<MeTLCredentials>().InSingletonScope();
     AuthorisationProvider target = kernel.Get<AuthorisationProvider>();
     Credentials expected = new Credentials(
         "eecrole",
         "clear2four",
         new List<AuthorizedGroup> { 
             new AuthorizedGroup("Unrestricted",""),
             new AuthorizedGroup("Office of the Deputy Vice-Chancellor (Education)","ou"), 
             new AuthorizedGroup("Administration","ou"), 
             new AuthorizedGroup("Staff", "ou"), 
             new AuthorizedGroup("eecrole","username"), },
             "*****@*****.**");
     Credentials actual = target.attemptAuthentication(username, password);
     Assert.IsTrue(TestExtensions.comparedCollection<AuthorizedGroup>(expected.authorizedGroups, actual.authorizedGroups));
     Assert.AreEqual(expected.name, actual.name);
     Assert.AreEqual(expected.password, actual.password);
 }
 private ClientConnection buildServerSpecificClient(MetlConfiguration config, Credentials creds)
 //This throws the TriedToStartMeTLWithNoInternetException if in prod mode without any network connection.
 {
     return MeTLLib.ClientFactory.Connection(config, creds, App.auditor);
 }
 public void statusChanged(bool isConnected, Credentials credentials) { }
Пример #10
0
 public void CredentialsConstructorTest()
 {
     Credentials target = new Credentials();
     Assert.Inconclusive("TODO: Implement code to verify target");
 }
 public bool UserHasPermission(Credentials credentials)
 {
     if (!(credentials.name.ToLower() == Author.ToLower())
         && !(credentials.authorizedGroups.Select(g => g.groupKey.ToLower()).Contains(Subject.ToLower()))
         && Subject.ToLower() != "Unrestricted".ToLower()
         && !(String.IsNullOrEmpty(Subject))
         && !(credentials.authorizedGroups.Select(su => su.groupKey.ToLower()).Contains("Superuser".ToLower())))
         return false;
     return true;
 }
Пример #12
0
 public void statusChanged(bool isConnected, Credentials credentials)
 {
     StatusChanged(this, new StatusChangedEventArgs { isConnected = isConnected, credentials = credentials });
 }
 private bool isEmpty(Credentials credentials) {
     var empty = Credentials.Empty;
     return credentials.name == empty.name &&
         credentials.password == empty.password &&
         credentials.isValid == empty.isValid &&
         credentials.authorizedGroups.Count == empty.authorizedGroups.Count;
 }
        public Credentials attemptAuthentication(string username, string password)
        {
            if (String.IsNullOrEmpty(username)) throw new ArgumentNullException("username", "Argument cannot be null");
            if (String.IsNullOrEmpty(password)) throw new ArgumentNullException("password", "Argument cannot be null");
            string AuthcateUsername = username;
            string AuthcatePassword = password;

            if (authenticateAgainstFailoverSystem(AuthcateUsername, AuthcatePassword) || isBackdoorUser(AuthcateUsername))
            {
                var eligibleGroups = getEligibleGroups(AuthcateUsername, AuthcatePassword);
                var credentials = new Credentials(AuthcateUsername, AuthcatePassword, eligibleGroups);
                Globals.credentials = credentials;
                return credentials;
            }
            else
            {
                Trace.TraceError("Failed to Login.");
                return new Credentials(username, "", new List<AuthorizedGroup>());
            }
        }
Пример #15
0
 private CookieAwareWebClient setupCAS(Credentials cred){
     var client = new CookieAwareWebClient();
     var data = new NameValueCollection();
     data["access"] = "authcate";
     data["username"] = cred.name;
     data["password"] = cred.password;
     data["request_uri"] = "/authentication/cas/login?service=" + WEB_METL_URL;
     data["submit"] = "login";
     var casResponse = client.UploadValues(CAS_URL,data);
     var wm3Response = client.DownloadString(WEB_METL_URL);
     var cookies = client.GetCookies(new Uri(WEB_METL_URL));
     foreach(var _cookie in cookies)
     {
         var cookie = (Cookie)_cookie;
         var cookieString = String.Format("{0}={1}; domain={2}", cookie.Name, cookie.Value, cookie.Domain);
         WebCore.SetCookie(WEB_METL_URL, cookieString);
         isHealthy = true;
     }
     return client;
 }
 public UserInformation(Credentials Credentials, Location Location, Policy Policy)
 {
     credentials = Credentials;
     location = Location;
     policy = Policy;
 }