Exemplo n.º 1
0
        internal static User Create(IntPtr userPtr)
        {
            var userHandle = new SyncUserHandle();

            userHandle.SetHandle(userPtr);
            return(new User(userHandle));
        }
        private static unsafe void RefreshAccessTokenCallback(IntPtr userHandlePtr, IntPtr sessionHandlePtr, sbyte *urlBuffer, IntPtr urlLength)
        {
            var userHandle = new SyncUserHandle();

            userHandle.SetHandle(userHandlePtr);
            var user = new User(userHandle);

            var sessionHandle = new SessionHandle();

            sessionHandle.SetHandle(sessionHandlePtr);

            var realmUri = new Uri(new string(urlBuffer, 0, (int)urlLength, System.Text.Encoding.UTF8));

            user.RefreshAccessToken(realmUri.AbsolutePath)
            .ContinueWith(t =>
            {
                if (t.IsFaulted)
                {
                    // TODO: raise error event on the session
                }
                else
                {
                    sessionHandle.RefreshAccessToken(t.Result.Item1, t.Result.Item2);
                }
            });
        }
Exemplo n.º 3
0
        public SyncUserHandle GetUser()
        {
            var handle = new SyncUserHandle();
            var ptr    = NativeMethods.get_user(this);

            handle.SetHandle(ptr);
            return(handle);
        }
Exemplo n.º 4
0
        private static SyncUserHandle GetHandle(IntPtr ptr)
        {
            if (ptr == IntPtr.Zero)
            {
                return(null);
            }

            var handle = new SyncUserHandle();

            handle.SetHandle(ptr);
            return(handle);
        }
Exemplo n.º 5
0
        public User GetUser()
        {
            var ptr = NativeMethods.get_user(this);

            if (ptr == IntPtr.Zero)
            {
                return(null);
            }

            var handle = new SyncUserHandle();

            handle.SetHandle(ptr);
            return(new User(handle));
        }
Exemplo n.º 6
0
        public static SyncUserHandle GetSyncUser(string identity, string refreshToken, string authServerUrl, bool isAdmin)
        {
            NativeException ex;
            var             userPtr = NativeMethods.get_sync_user(identity, (IntPtr)identity.Length,
                                                                  refreshToken, (IntPtr)refreshToken.Length,
                                                                  authServerUrl, (IntPtr)authServerUrl?.Length,
                                                                  isAdmin, out ex);

            ex.ThrowIfNecessary();

            var handle = new SyncUserHandle();

            handle.SetHandle(userPtr);
            return(handle);
        }
Exemplo n.º 7
0
        private static SyncUserHandle GetHandle(IntPtr ptr)
        {
            if (ptr == IntPtr.Zero)
            {
                return null;
            }

            var handle = new SyncUserHandle();
            handle.SetHandle(ptr);
            return handle;
        }
        private static unsafe void RefreshAccessTokenCallback(IntPtr userHandlePtr, IntPtr sessionHandlePtr, sbyte* urlBuffer, IntPtr urlLength)
        {
            var userHandle = new SyncUserHandle();
            userHandle.SetHandle(userHandlePtr);
            var user = new User(userHandle);

            var session = Session.SessionForPointer(sessionHandlePtr);

            var realmUri = new Uri(new string(urlBuffer, 0, (int)urlLength, System.Text.Encoding.UTF8));

            user.RefreshAccessToken(realmUri.AbsolutePath)
                .ContinueWith(t =>
            {
                if (t.IsFaulted)
                {
                    session.RaiseError(t.Exception.GetBaseException());
                }
                else
                {
                    session.Handle.RefreshAccessToken(t.Result.Item1, t.Result.Item2);
                }
            }).ContinueWith(t =>
            {
                userHandle.Dispose();
            });
        }