public AuthenticationController(Settings settings, ISaveChanges unitOfWork, AuthenticationDao authenticationDao, OAuth2Client oAuth2Client)
     : base(settings, unitOfWork)
 {
     Claws.NotNull(() => authenticationDao);
       Claws.NotNull(() => oAuth2Client);
       this.authenticationDao = authenticationDao;
       this.oAuth2Client = oAuth2Client;
 }
 public Connectors(IUrls urls, OAuth2Client.IStorage storage)
 {
     if (urls == null) throw new ArgumentNullException("urls");
     if (storage == null) throw new ArgumentNullException("storage");
     _urls = urls;
     _storage = storage;
     InitializeInternal();
 }
		public V1APIConnector(string urlPrefix, string username = null, string password = null, bool? integratedAuth = null,
							  ProxyProvider proxy = null, OAuth2Client.IStorage storage = null)
			: base(urlPrefix, new CredentialCache(), proxy)
		{
			var cache = _creds as CredentialCache;
			var uri = new Uri(urlPrefix);

			// Try the OAuth2 credential
			OAuth2Client.IStorage oauth2storage = null;
			if (storage != null)
			{
				oauth2storage = storage;
			}
			else
			{
				try
				{
					var s = OAuth2Client.Storage.JsonFileStorage.Default as OAuth2Client.IStorage;
					s.GetSecrets();
					oauth2storage = s;
				}
				catch (System.IO.FileNotFoundException)
				{
					// swallowed - meaning no oauth2 secrets configured.
				}
			}
			if (oauth2storage != null)
			{
				cache.Add(uri,
					"Bearer",
					new OAuth2Client.OAuth2Credential(
						"apiv1",
						oauth2storage,
						proxy != null ? proxy.CreateWebProxy() : null
						)
					);
			}

			if (username == null)
			{
				if (integratedAuth.GetValueOrDefault(true))
				{ // no constructor args - so use default integrated identity unless they say no.
					cache.Add(uri, "NTLM", CredentialCache.DefaultNetworkCredentials);
					cache.Add(uri, "Negotiate", CredentialCache.DefaultNetworkCredentials);
				}
			}
			else
			{
				var userPassCred = new NetworkCredential(username, password);
				cache.Add(uri, "Basic", userPassCred);

				if (!integratedAuth.GetValueOrDefault(false))
				{ // If there's a username, we'll assume the user doesn't want Windows Auth unless they ask.
					cache.Add(uri, "NTLM", userPassCred);
					cache.Add(uri, "Negotiate", userPassCred);
				}
			}
		}
		public IServices CreateServices(string baseUrl, OAuth2Client.IStorage storage)
		{
			var dataConnector = new V1OAuth2APIConnector(baseUrl + "/rest-1.oauth.v1/", storage);
			var metaConnector = new V1OAuth2APIConnector(baseUrl + "/meta.v1/", storage);
			_metaModel = new MetaModel(metaConnector);
			var services = new Services(_metaModel, dataConnector);

			return services;
		}
Beispiel #5
0
        public void DownloadFolder(OAuth2Client client, DropNet.DropNetClient DownloadClient, string Dir, string DestinationDirectory, string API, bool IsConsole)
        {
            if (Directory.Exists(DestinationDirectory) == false)
            {
                if (IsConsole)
                {
                    Console.WriteLine("Creating folder:" + DestinationDirectory);
                }
                Directory.CreateDirectory(DestinationDirectory);
            }

            var Data = client.GetFolderMeta(API, Dir);

            foreach (var item in Data.Contents)
            {
                if (item.IsDirectory)
                {
                    DownloadFolder(client, DownloadClient, item.Path, DestinationDirectory + @"\" + item.Path.Split('/')[item.Path.Split('/').Count() - 1], API, IsConsole);

                }
                else
                {
                    if (IsConsole)
                    {
                        Console.WriteLine("Downloading:" + Path.GetFileName(item.Path));
                    }

                    var NewFile = DownloadClient.GetFile(item.Path);

                    using (var fileStream = new FileStream(
                    DestinationDirectory + @"\" + Path.GetFileName(item.Path), FileMode.CreateNew, FileAccess.ReadWrite))
                    {
                        fileStream.Write(NewFile, 0, NewFile.Length);
                        fileStream.Flush(true);

                    }

                }
            }
        }
 public OAuth2CompletedEventArgs(OAuth2Client.OAuth2TokenResponse response,string state)
 {
     this.Response = response;
     this.State = state;
 }
 public ActivityLogClient(OAuth2Client oAuth2Client, UserSession userSession)
     : base(oAuth2Client, userSession)
 {
 }
 public UserProfileClient(OAuth2Client oAuth2Client, UserSession userSession)
     : base(oAuth2Client, userSession)
 {
 }
 protected AuthenticatedClientBase(OAuth2Client oAuth2Client, UserSession userSession)
 {
     this.OAuth2Client = oAuth2Client;
       this.UserSession = userSession;
 }