コード例 #1
0
ファイル: Service.cs プロジェクト: capturePointer/DiskLocker
        private object OnRemovePathFromProtection( object message )
        {
            var packet = ( RemovePathFromProtectionMessage )message;
            var ret = new OperationResult();

            if ( !this.CheckSession( packet.SessionKey ) )
            {
                ret.Value = false;
                return ret;
            }

            bool removeResult;

            bool result = DevIoCore.IoRemovePathFromProtection( packet.UniqueKey, out removeResult );

            if ( result && removeResult )
            {
                string path = this.GetPathByUniqueKey( packet.UniqueKey );

                if ( path != null )
                {
                    PathManager pathManager = new PathManager();
                    result = pathManager.DeletePath( path );
                }
                else
                {
                    ret.Value = false;
                    return ret;
                }
            }

            if ( result && removeResult )
            {
                result = this.paths.Remove( packet.UniqueKey );
            }

            ret.Value = result && removeResult;
            return ret;
        }
コード例 #2
0
ファイル: Service.cs プロジェクト: capturePointer/DiskLocker
        private object OnHasPasswords( object message )
        {
            var packet = ( CreateAuthSessionKeyMessage )message;
            var ret = new OperationResult();

            PasswordManager passwordManager = new PasswordManager();

            ret.Value = passwordManager.HasPasswords();
            return ret;
        }
コード例 #3
0
ファイル: Service.cs プロジェクト: capturePointer/DiskLocker
        private object OnDeletePassword( object message )
        {
            var packet = ( DeletePasswordMessage )message;
            var ret = new OperationResult();

            if ( !this.CheckSession( packet.SessionKey ) )
            {
                ret.Value = false;
                return ret;
            }

            PasswordManager passwordManager = new PasswordManager();

            string password = HashManager.Sha256( packet.Password );

            bool result = passwordManager.CheckPassword( password );

            if ( result )
            {
                result = passwordManager.DeletePassword( password );
                this.DeleteSession( packet.SessionKey );
            }

            ret.Value = result;
            return ret;
        }
コード例 #4
0
ファイル: Service.cs プロジェクト: capturePointer/DiskLocker
        private object OnChangePassword( object message )
        {
            var packet = ( ChangePasswordMessage )message;
            var ret = new OperationResult();

            if ( !this.CheckSession( packet.SessionKey ) )
            {
                ret.Value = false;
                return ret;
            }

            if ( !this.IsPasswordCorrect( packet.OldPassword ) )
            {
                ret.Value = false;
                return ret;
            }

            if ( !this.IsPasswordCorrect( packet.NewPassword ) )
            {
                ret.Value = false;
                return ret;
            }

            PasswordManager passwordManager = new PasswordManager();

            string oldPassword = HashManager.Sha256( packet.OldPassword );

            bool result = passwordManager.CheckPassword( oldPassword );

            if ( result )
            {
                string newPassword = HashManager.Sha256( packet.NewPassword );
                result = passwordManager.ChangePassword( oldPassword, newPassword );
            }

            ret.Value = result;
            return ret;
        }
コード例 #5
0
ファイル: Service.cs プロジェクト: capturePointer/DiskLocker
        private object OnAddPathForProtection( object message )
        {
            var packet = ( AddPathForProtectionMessage )message;
            var ret = new OperationResult();

            if ( !this.CheckSession( packet.SessionKey ) )
            {
                ret.Value = false;
                return ret;
            }

            PathManager pathManager = new PathManager();

            if ( pathManager.ExistsPath( packet.Path ) )
            {
                ret.Value = false;
                return ret;
            }

            bool result = true;

            result = pathManager.InsertPath( packet.Path, packet.WeakProtection );

            /* TODO: check correct path */

            uint uniqueKey = 0;

            if ( result )
            {
                result = this.SafeAddPathForProtection( packet.Path, packet.WeakProtection, out uniqueKey );
            }

            if ( result )
            {
                paths.Add( uniqueKey, packet.Path );
            }

            ret.Value = result;
            return ret;
        }
コード例 #6
0
ファイル: Service.cs プロジェクト: capturePointer/DiskLocker
        private object OnAddPassword( object message )
        {
            var packet = ( AddPasswordMessage )message;
            var ret = new OperationResult();

            PasswordManager passwordManager = new PasswordManager();

            bool hasPasswords = passwordManager.HasPasswords();

            if ( !this.CheckSession( packet.SessionKey ) && hasPasswords )
            {
                ret.Value = false;
                return ret;
            }

            if ( !this.IsPasswordCorrect( packet.NewPassword ) )
            {
                ret.Value = false;
                return ret;
            }

            string newPassword = HashManager.Sha256( packet.NewPassword );

            passwordManager.InsertPassword( newPassword );

            ret.Value = true;
            return ret;
        }