Пример #1
0
 /// <summary>
 ///     Führt die Authorizierung des Connectors durch
 /// </summary>
 /// <param name="access">Die notwendigen Zugriffdaten</param>
 public override void Connect(MemberStorageAccess access)
 {
     _userId          = access.UserId;
     Client.UserLogin = new UserLogin {
         Secret = access.Secret, Token = access.Token
     };
 }
Пример #2
0
 /// <summary>
 ///     Diese Methode wird nur zur Kompatibilität des Interface implementiert.
 ///     Für Google-Drive wird die Authorizierung über die <see cref="CustomGoogleDataStore" /> sichergestellt
 /// </summary>
 /// <param name="access">Wird nicht benötigt</param>
 public override void Connect(MemberStorageAccess access)
 {
     if (Service == null)
     {
         throw new InvalidOperationException("No connection could be established");
     }
 }
        /// <summary>
        /// Speichert den Token für die Authorisierung in die Datenbank
        /// </summary>
        /// <typeparam name="T">Typ des Wertes der gespichert wird</typeparam>
        /// <param name="key">Code oder Token, je nach Schritt in der Authorisierung</param>
        /// <param name="value">Der Wert der gespeichert werden soll</param>
        /// <returns>Task ohne Rückgabewert</returns>
        public Task StoreAsync <T>(string key, T value)
        {
            var access = GetAccess(key);
            var token  = NewtonsoftJsonSerializer.Instance.Serialize(value);

            if (access == null)
            {
                var memberId = GetMemberIdFromKey(key);
                access = new MemberStorageAccess
                {
                    MemberId = memberId,
                    Secret   = "x",
                    Token    = token,
                    Type     = StorageProviderType.GoogleDrive
                };
                _repository.Add(access);
            }
            else
            {
                access.Token = token;
                _repository.Update(access);
            }

            return(TaskEx.Delay(0));
        }
Пример #4
0
        public static async Task <ODConnection> SignInToMicrosoftAccount(string oldRefreshToken,
                                                                         MemberStorageAccess access)
        {
            AppTokenResult appToken = null;

            if (!string.IsNullOrEmpty(oldRefreshToken))
            {
                //  appToken = await MicrosoftAccountOAuth.RedeemRefreshTokenAsync(msa_client_id, msa_client_secret, oldRefreshToken);
            }

            if (null == appToken)
            {
                //appToken = await MicrosoftAccountOAuth.LoginAuthorizationCodeFlowAsync(msa_client_id,
                //   msa_client_secret,
                //  new[] { "wl.offline_access", "wl.basic", "wl.signin", "onedrive.readwrite" });
            }

            if (null != appToken)
            {
                SaveRefreshToken(appToken.RefreshToken);

                return(new ODConnection("https://api.onedrive.com/v1.0", new OAuthTicket(appToken)));
            }

            return(null);
        }
Пример #5
0
 public GeoUpdate()
 {
     Mapper.InitializeMappers();
     _memberRepository = new MemberRepository();
     _memberStorage    = new MemberStorageAccess();
     _authService      = new Authorization();
 }
Пример #6
0
 public GroupService()
 {
     _GroupStorageAccess  = new GroupStorageAccess();
     _GroupRepository     = new GroupRepository();
     _MemberStorageAccess = new MemberStorageAccess();
     _LocationService     = new LocationService();
     _MemberRepository    = new MemberRepository();
 }
        /// <summary>
        /// Löscht die Googlezugriffsdaten aus der Datenbank
        /// </summary>
        /// <typeparam name="T">Typ des Schlüssels</typeparam>
        /// <param name="key">Der Token, der gelöscht werden soll</param>
        /// <returns>Task ohne Rückgabewert</returns>
        // ReSharper disable once UnusedTypeParameter: Der Typparameter, wird vom Interface verlangt, aber hier nicht benötigt
        public Task DeleteAsync <T>(string key)
        {
            var access = new MemberStorageAccess {
                MemberId = int.Parse(key)
            };

            _repository.Delete(access);
            return(TaskEx.Delay(0));
        }
Пример #8
0
 public ReportService()
 {
     _LocationRepository    = new LocationRepository();
     _GroupRepository       = new GroupRepository();
     _MemberRepository      = new MemberRepository();
     _MemberService         = new MemberService();
     _GroupService          = new GroupService();
     _GeoService            = new GeoUpdate();
     _LiveSessionRepository = new LiveSessionRepository();
     //Storage Classes
     _GroupStorageAccess          = new GroupStorageAccess();
     _MemberStorageAccess         = new MemberStorageAccess();
     _ReportRepository            = new ReportRepository();
     _SessionHistoryStorageAccess = new SessionHistoryStorageAccess();
 }
Пример #9
0
        public void EditGroup(Group grp, string partitionKey = null, string rowkey = null, bool isCreate = false)
        {
            LastUpdateDate = DateTime.UtcNow;

            var entityGrp = new entities.Group();

            entityGrp.GroupID       = Convert.ToInt16(grp.GroupID);
            entityGrp.GroupName     = grp.GroupName;
            entityGrp.EnrollmentKey = grp.EnrollmentKey;
            entityGrp.Email         = grp.Email;
            entityGrp.PhoneNumber   = grp.PhoneNumber;
            entityGrp.Location      = grp.GroupLocation;
            entityGrp.GroupType     = Convert.ToInt32(grp.Type);
            entityGrp.IsActive      = grp.IsActive;

            entityGrp.EnrollmentType            = Convert.ToInt32(grp.EnrollmentType);
            entityGrp.RowKey                    = grp.GroupID;
            entityGrp.PartitionKey              = grp.GroupLocation;
            entityGrp.ParentGroupID             = grp.ParentGroupID;
            entityGrp.NotifySubgroups           = grp.NotifySubgroups;
            entityGrp.SubGroupIdentificationKey = grp.SubGroupIdentificationKey;
            entityGrp.ShapeFileID               = grp.ShapeFileID;
            entityGrp.GeoLocation               = grp.GeoLocation;
            entityGrp.ShowIncidents             = grp.ShowIncidents;

            var _GroupStorageAccess = new GroupStorageAccess();

            _GroupStorageAccess.UpdateGroup(entityGrp);

            var entityAdmin = new entities.AdminUser();

            entityAdmin.AdminID              = Convert.ToInt16(grp.GroupID);
            entityAdmin.Email                = grp.Email;
            entityAdmin.GroupIDCSV           = grp.GroupID;
            entityAdmin.Name                 = grp.GroupName;
            entityAdmin.MobileNumber         = grp.PhoneNumber;
            entityAdmin.LiveUserID           = grp.LiveInfo.LiveID;
            entityAdmin.AllowGroupManagement = grp.AllowGroupManagement;
            entityAdmin.PartitionKey         = isCreate ? grp.GroupLocation : partitionKey;
            entityAdmin.RowKey               = isCreate ? Guid.NewGuid().ToString() : rowkey;

            var _MemberStorageAccess = new MemberStorageAccess();

            _MemberStorageAccess.SaveGroupAdmin(entityAdmin);
        }
Пример #10
0
        /// <summary>
        ///     Wird aufgerufen nachdem der Benutzer den Zugriff authorisiert hat
        ///     Die ist der 2. Schritt
        /// </summary>
        /// <returns></returns>
        public Member GetUserAuthentication()
        {
            var userLogin = Client.GetAccessToken();
            var info      = Client.AccountInfo();
            var isNew     = false;

            var access = CurrentMember.StorageAccesses.FirstOrDefault(
                s => s.Type == StorageProviderType.Dropbox && s.MemberId == CurrentMember.Id);

            if (access == null)
            {
                access = new MemberStorageAccess
                {
                    Type     = StorageProviderType.Dropbox,
                    MemberId = CurrentMember.Id,
                };

                isNew = true;
            }

            access.Secret = userLogin.Secret;
            access.Token  = userLogin.Token;
            access.UserId = info.uid.ToString();

            if (isNew)
            {
                Repository.Add(access);
                CurrentMember.StorageAccessType = StorageProviderType.Dropbox;
                Repository.Update(CurrentMember);
            }
            else
            {
                Repository.Update(access);
            }

            CheckFolderStructure();

            CurrentMember.StorageAccesses = new List <MemberStorageAccess> {
                access
            };
            return(CurrentMember);
        }
Пример #11
0
        /// <summary>
        ///     Wird aufgerufen nachdem der Benutzer den Zugriff authorisiert hat
        ///     Die ist der 2. Schritt
        /// </summary>
        /// <returns></returns>
        public Member GetUserAuthentication(Uri requestUri)
        {
            var result = DropboxOAuth2Helper.ParseTokenFragment(requestUri);

            var isNew  = false;
            var access = CurrentMember.StorageAccesses.FirstOrDefault(
                s => s.Type == StorageProviderType.Dropbox && s.MemberId == CurrentMember.Id);

            if (access == null)
            {
                access = new MemberStorageAccess
                {
                    Type     = StorageProviderType.Dropbox,
                    MemberId = CurrentMember.Id,
                };

                isNew = true;
            }

            access.Token  = result.AccessToken;
            access.UserId = result.Uid;

            if (isNew)
            {
                Repository.Add(access);
                CurrentMember.StorageAccessType = StorageProviderType.Dropbox;
                Repository.Update(CurrentMember);
            }
            else
            {
                Repository.Update(access);
            }
            _access = access;
            CheckFolderStructure();

            CurrentMember.StorageAccesses = new List <MemberStorageAccess> {
                access
            };
            return(CurrentMember);
        }
Пример #12
0
        internal bool Authorize(HttpContext context, int memberId)
        {
            try
            {
                var abstractContext = new HttpContextWrapper(context);
                var result          = _liveAuthClient.ExchangeAuthCodeAsync(abstractContext).Result;

                _session = result.Session;
                var access =
                    Repository.Queryable <MemberStorageAccess>()
                    .FirstOrDefault(
                        s => s.MemberId == memberId && s.Type == StorageProviderType.OneDrive);
                if (access == null)
                {
                    access = new MemberStorageAccess
                    {
                        MemberId = memberId,
                        Token    = _session.RefreshToken,
                        Secret   = "onedrive",
                        Type     = StorageProviderType.OneDrive
                    };
                    Repository.Add(access);
                }
                else
                {
                    access.Token = _session.RefreshToken;
                    Repository.Update(access);
                }

                CheckFolderStructure();
                return(true);
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }

            return(false);
        }
Пример #13
0
 /// <summary>
 /// Stellt eine Verbindung zum Provider her
 /// </summary>
 /// <param name="access">Informationen mit denen der Benutzer angemeldet werden kann</param>
 public override void Connect(MemberStorageAccess access)
 {
     CheckForSession();
 }
Пример #14
0
 /// <summary>
 /// Verbinden den Connector mit den Provider
 /// </summary>
 /// <param name="access">Die Informationen, die zur Anmeldung notwendig sind</param>
 public abstract void Connect(MemberStorageAccess access);
Пример #15
0
 public override void Connect(MemberStorageAccess access)
 {
 }
Пример #16
0
 /// <summary>
 ///     Führt die Authorizierung des Connectors durch
 /// </summary>
 /// <param name="access">Die notwendigen Zugriffdaten</param>
 public override void Connect(MemberStorageAccess access)
 {
     _userId = access.UserId;
     _access = access;
 }