public RemoteDesktop()
        {
            // Since this control will be updated constantly, and all graphics will be drawn by this class,
            // set the control's painting for best user-drawn performance.
            SetStyle(ControlStyles.AllPaintingInWmPaint |
                     ControlStyles.UserPaint |
                     ControlStyles.DoubleBuffer |
                     ControlStyles.Selectable | // BUG FIX (Edward Cooke) -- Adding Control.Select() support
                     ControlStyles.ResizeRedraw |
                     ControlStyles.Opaque,
                     true);

            // Show a screenshot of a Windows desktop from the manifest and cache to be used when painting in design mode
            // ReSharper disable once AssignNullToNotNullAttribute
            designModeDesktop =
                Image.FromStream(GetAssembly(GetType()).GetManifestResourceStream("VncSharp.Resources.screenshot.png"));

            // Use a simple desktop policy for design mode.  This will be replaced in Connect()
            desktopPolicy     = new VncDesignModeDesktopPolicy(this);
            AutoScroll        = desktopPolicy.AutoScroll;
            AutoScrollMinSize = desktopPolicy.AutoScrollMinSize;

            // Users of the control can choose to use their own Authentication GetPassword() method via the delegate above.  This is a default only.
            GetPassword = PasswordDialog.GetPassword;
        }
示例#2
0
        public RemoteDesktopWpf() : base()
        {
            InitializeComponent();

            // Use a simple desktop policy for design mode.  This will be replaced in Connect()
            desktopPolicy = new VncDesignModeDesktopPolicy(this);

            if (desktopPolicy.AutoScroll)
            {
                scrollviewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
                scrollviewer.VerticalScrollBarVisibility   = ScrollBarVisibility.Auto;
            }
            else
            {
                scrollviewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
                scrollviewer.VerticalScrollBarVisibility   = ScrollBarVisibility.Disabled;
            }

            // Users of the control can choose to use their own Authentication GetPassword() method via the delegate above.  This is a default only.
            GetPassword = new AuthenticateDelegate(PasswordDialogWpf.GetPassword);

            // EventHandler Settings
            this.designModeDesktop.SizeChanged += new System.Windows.SizeChangedEventHandler(SizeChangedEventHandler);
            this.designModeDesktop.MouseMove   += new MouseEventHandler(MouseDownUpMoveEventHandler);
            this.designModeDesktop.MouseDown   += new MouseButtonEventHandler(MouseDownUpMoveEventHandler);
            this.designModeDesktop.MouseUp     += new MouseButtonEventHandler(MouseDownUpMoveEventHandler);
            this.designModeDesktop.MouseWheel  += new MouseWheelEventHandler(MouseWHeelEventHandler);
        }
示例#3
0
        /// <summary>
        /// Starts authentication.
        /// </summary>
        /// <param name="userName">User login name.</param>
        /// <param name="password">Password.</param>
        /// <param name="tryApop"> If true and POP3 server supports APOP, then APOP is used, otherwise normal login used.</param>
        /// <param name="callback">Callback to call when the asynchronous operation is complete.</param>
        /// <param name="state">User data.</param>
        /// <returns>An IAsyncResult that references the asynchronous operation.</returns>
        /// <exception cref="ObjectDisposedException">Is raised when this object is disposed and this method is accessed.</exception>
        /// <exception cref="InvalidOperationException">Is raised when POP3 client is not connected or is already authenticated.</exception>
        public IAsyncResult BeginAuthenticate(string userName,
                                              string password,
                                              bool tryApop,
                                              AsyncCallback callback,
                                              object state)
        {
            if (IsDisposed)
            {
                throw new ObjectDisposedException(GetType().Name);
            }
            if (!IsConnected)
            {
                throw new InvalidOperationException("You must connect first.");
            }
            if (IsAuthenticated)
            {
                throw new InvalidOperationException("Session is already authenticated.");
            }

            AuthenticateDelegate asyncMethod = Authenticate;
            AsyncResultState     asyncState  = new AsyncResultState(this, asyncMethod, callback, state);

            asyncState.SetAsyncResult(asyncMethod.BeginInvoke(userName,
                                                              password,
                                                              tryApop,
                                                              asyncState.CompletedCallback,
                                                              null));

            return(asyncState);
        }
 /// <summary>
 /// Constructor of the BasicAuthentication middleware. Saves
 /// authentication and realm information for usage during
 /// invocation along with the next delegate for the middleware
 /// chaining.
 /// </summary>
 /// <param name="next">The next request middleware to be executed.</param>
 /// <param name="authenticate">The authentication method that will do
 /// the real stuff.</param>
 /// <param name="realm">The basic authentication realms. Can be a
 /// sentence defining the resources being protected.</param>
 /// <param name="purgatoryPeriod">How long (ms) the remote ip address
 /// has to wait before getting its 403 response. During that time,
 /// the remote ip address is kept in purgatory and its authentication
 /// requests will fail.</param>
 public BasicAuthenticationMiddleware(RequestDelegate next, AuthenticateDelegate authenticate, string realm, int purgatoryPeriod)
 {
     _next            = next;
     _authenticate    = authenticate;
     _realm           = realm;
     _purgatoryPeriod = purgatoryPeriod;
     _purgatory       = new HashSet <IPAddress>();
 }
示例#5
0
        public RemoteDesktopWPF()
        {
            InitializeComponent();
            _dispatcher = System.Windows.Threading.Dispatcher.CurrentDispatcher;

            // Users of the control can choose to use their own Authentication GetPassword() method via the delegate above.  This is a default only.
            GetPassword = new AuthenticateDelegate(PasswordDialog.GetPassword);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="authenticationTypes"></param>
        /// <param name="callback"></param>
        /// <param name="state"></param>
        /// <returns></returns>
        public async Task Authenticate(string[] authenticationTypes, Action <IIdentity, IDictionary <string, string>, IDictionary <string, object>, object> callback, object state)
        {
            AuthenticateDelegate authenticateDelegate = AuthenticateDelegate;

            if (authenticateDelegate != null)
            {
                await authenticateDelegate.Invoke(authenticationTypes, callback, state);
            }
        }
示例#7
0
 public RemoteDesktop(string host, int port, int display, string password)
 {
     this.host     = host;
     this.port     = port;
     this.display  = display;
     this.password = password;
     // Delegate that retrieves the given password
     GetPassword = () => password;
 }
        public void notify(Packet packet) {
			try {
				if (packet.ID.StartsWith("auth_get")) {
					Packet query = packet.getFirstChild("query");
					String token = query.getChildValue("token");
                    int sequence = Convert.ToInt32(query.getChildValue("sequence"));
                    String hash = auth.getZeroKHash(sequence, Encoding.UTF8.GetBytes(token), Encoding.UTF8.GetBytes(jabberModel.Password));
                    jabberModel.addResultHandler("0k_auth_" + Convert.ToString(counter), this);
                    StreamWriter output = packet.Session.Writer;
                    output.Write("<iq type='set' id='0k_auth_");
                    output.Write(Convert.ToString(counter++));
                    output.Write("'><query xmlns='jabber:iq:auth'><username>");
                    output.Write(jabberModel.User);
                    output.Write("</username><resource>");
                    output.Write(jabberModel.Resource);                    
                    output.Write("</resource><hash>");
                    output.Write(hash);
                    output.Write("</hash></query></iq>");
                    output.Flush();
                } else if (packet.Type.Equals("result")) {
					Console.WriteLine("Auth Handler passed");
					packet.Session.Status = Session.SessionStatus.authenticated;
					AuthenticateDelegate ad = new AuthenticateDelegate(jabberModel.gui.Authenticated);
					jabberModel.gui.Invoke(ad);
                } else if (packet.Type.Equals("error")) {
                    Console.WriteLine("Failed to authenticate: " + packet.getChildValue("error"));
					AuthenticationFailedDelegate afd = new AuthenticationFailedDelegate(jabberModel.gui.AuthenticationFailed);
					jabberModel.gui.Invoke(afd);
                }

                else

                {

                    Console.WriteLine("Unknown result: " + packet.ToString());

                }

            }

            catch (IOException ex)

            {

                Console.WriteLine(ex.StackTrace);

            }

        }
示例#9
0
        public void notify(Packet packet)
        {
            try {
                if (packet.ID.StartsWith("auth_get"))
                {
                    Packet query    = packet.getFirstChild("query");
                    String token    = query.getChildValue("token");
                    int    sequence = Convert.ToInt32(query.getChildValue("sequence"));
                    String hash     = auth.getZeroKHash(sequence, Encoding.UTF8.GetBytes(token), Encoding.UTF8.GetBytes(jabberModel.Password));
                    jabberModel.addResultHandler("0k_auth_" + Convert.ToString(counter), this);
                    StreamWriter output = packet.Session.Writer;
                    output.Write("<iq type='set' id='0k_auth_");
                    output.Write(Convert.ToString(counter++));
                    output.Write("'><query xmlns='jabber:iq:auth'><username>");
                    output.Write(jabberModel.User);
                    output.Write("</username><resource>");
                    output.Write(jabberModel.Resource);
                    output.Write("</resource><hash>");
                    output.Write(hash);
                    output.Write("</hash></query></iq>");
                    output.Flush();
                }
                else if (packet.Type.Equals("result"))
                {
                    Console.WriteLine("Auth Handler passed");
                    packet.Session.Status = Session.SessionStatus.authenticated;
                    AuthenticateDelegate ad = new AuthenticateDelegate(jabberModel.gui.Authenticated);
                    jabberModel.gui.Invoke(ad);
                }
                else if (packet.Type.Equals("error"))
                {
                    Console.WriteLine("Failed to authenticate: " + packet.getChildValue("error"));
                    AuthenticationFailedDelegate afd = new AuthenticationFailedDelegate(jabberModel.gui.AuthenticationFailed);
                    jabberModel.gui.Invoke(afd);
                }

                else

                {
                    Console.WriteLine("Unknown result: " + packet.ToString());
                }
            }

            catch (IOException ex)

            {
                Console.WriteLine(ex.StackTrace);
            }
        }
示例#10
0
        public void AuthenticateAsync(Func <string, string> userAuthCallback, Action <Action> completeCallback)
        {
            lock (authLock)
            {
                if (isAuthenticating)
                {
                    throw new InvalidOperationException("SportsClient is currently authenticating...");
                }
                isAuthenticating = true;

                AuthenticateDelegate dlgt = Authenticate;
                dlgt.BeginInvoke(userAuthCallback, ar => completeCallback(() =>
                {
                    ((AuthenticateDelegate)ar.AsyncState)
                    .EndInvoke(ar);
                    IsAuthenticated  = true;
                    isAuthenticating = false;
                }), dlgt);
            }
        }
示例#11
0
        public RemoteDesktop() : base()
        {
            // Since this control will be updated constantly, and all graphics will be drawn by this class,
            // set the control's painting for best user-drawn performance.
            SetStyle(ControlStyles.AllPaintingInWmPaint |
                     ControlStyles.UserPaint |
                     ControlStyles.DoubleBuffer |
                     ControlStyles.Selectable |             // BUG FIX (Edward Cooke) -- Adding Control.Select() support
                     ControlStyles.ResizeRedraw |
                     ControlStyles.Opaque,
                     true);

            // Allow for partial viewing of the remote desktop
            AutoScroll        = true;
            AutoScrollMinSize = new Size(608, 427);             // just a default for Design graphic. Will get changed once connected.

            // Show a screenshot of a Windows desktop from the manifest and cache to be used when painting in design mode
            designModeDesktop = Image.FromStream(Assembly.GetAssembly(GetType()).GetManifestResourceStream("VncSharp.Resources.screenshot.png"));

            // Users of the control can choose to use their own Authentication GetPassword() method via the delegate above.  This is a default only.
            GetPassword = new AuthenticateDelegate(PasswordDialog.GetPassword);
        }
示例#12
0
        VncClient vnc; // The Client object handling all protocol-level interaction

        #endregion Fields

        #region Constructors

        public VncDesktop()
            : base()
        {
            // Since this control will be updated constantly, and all graphics will be drawn by this class,
            // set the control's painting for best user-drawn performance.
            SetStyle(ControlStyles.AllPaintingInWmPaint |
                     ControlStyles.UserPaint |
                     ControlStyles.DoubleBuffer |
                     ControlStyles.Selectable |   // BUG FIX (Edward Cooke) -- Adding Control.Select() support
                     ControlStyles.ResizeRedraw |
                     ControlStyles.Opaque,
                     true);

            // Show a screenshot of a Windows desktop from the manifest and cache to be used when painting in design mode
            designModeDesktop = Image.FromStream(Assembly.GetAssembly(typeof(RemoteDesktop)).GetManifestResourceStream("VncSharp.Resources.screenshot.png"));

            // Use a simple desktop policy for design mode.  This will be replaced in Connect()
            desktopPolicy = new VncDesignModeDesktopPolicy(this);
            AutoScroll = desktopPolicy.AutoScroll;
            AutoScrollMinSize = desktopPolicy.AutoScrollMinSize;

            // Users of the control can choose to use their own Authentication GetPassword() method via the delegate above.  This is a default only.
            GetPassword = new AuthenticateDelegate(PasswordDialog.GetPassword);
        }
示例#13
0
 public Hook(AuthenticationHandler handler, AuthenticateDelegate chained)
 {
     _handler = handler;
     Chained  = chained;
 }
		public RemoteDesktopWpf() : base()
		{
            InitializeComponent();

			// Use a simple desktop policy for design mode.  This will be replaced in Connect()
            desktopPolicy = new VncDesignModeDesktopPolicy(this);

            if (desktopPolicy.AutoScroll)
            {
                scrollviewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
                scrollviewer.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
            } else {
                scrollviewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
                scrollviewer.VerticalScrollBarVisibility = ScrollBarVisibility.Disabled;
            }
            
			// Users of the control can choose to use their own Authentication GetPassword() method via the delegate above.  This is a default only.
			GetPassword = new AuthenticateDelegate(PasswordDialogWpf.GetPassword);

            // EventHandler Settings
            this.designModeDesktop.SizeChanged +=new System.Windows.SizeChangedEventHandler(SizeChangedEventHandler);
            this.designModeDesktop.MouseMove += new MouseEventHandler(MouseDownUpMoveEventHandler);
            this.designModeDesktop.MouseDown += new MouseButtonEventHandler(MouseDownUpMoveEventHandler);
            this.designModeDesktop.MouseUp += new MouseButtonEventHandler(MouseDownUpMoveEventHandler);
            this.designModeDesktop.MouseWheel +=new MouseWheelEventHandler(MouseWHeelEventHandler);
		}
 public Hook(AuthenticationHandler handler, AuthenticateDelegate chained)
 {
     _handler = handler;
     Chained = chained;
 }
        VncClient vnc; // The Client object handling all protocol-level interaction

        #endregion Fields

        #region Constructors

        public RemoteDesktop()
            : base()
        {
            // Since this control will be updated constantly, and all graphics will be drawn by this class,
            // set the control's painting for best user-drawn performance.
            SetStyle(ControlStyles.AllPaintingInWmPaint |
                     ControlStyles.UserPaint			|
                     ControlStyles.DoubleBuffer			|
                     ControlStyles.Selectable           |   // BUG FIX (Edward Cooke) -- Adding Control.Select() support
                     ControlStyles.ResizeRedraw			|
                     ControlStyles.Opaque,
                     true);

            // Allow for partial viewing of the remote desktop
            AutoScroll = true;
            AutoScrollMinSize = new Size(608, 427); // just a default for Design graphic. Will get changed once connected.

            // Show a screenshot of a Windows desktop from the manifest and cache to be used when painting in design mode
            designModeDesktop = Image.FromStream(Assembly.GetAssembly(GetType()).GetManifestResourceStream("VncSharp.Resources.screenshot.png"));

            // Users of the control can choose to use their own Authentication GetPassword() method via the delegate above.  This is a default only.
            GetPassword = new AuthenticateDelegate(PasswordDialog.GetPassword);
        }
示例#17
0
 /// <summary>
 /// Extension methods that initialize basic authentication.
 /// </summary>
 /// <param name="builder">The application builder instance.</param>
 /// <param name="authenticate">The authentication delegate used to
 /// authenticate user credentials.</param>
 /// <param name="realm">The basic authentication realm.</param>
 /// <param name="purgatoryPeriod">How long (ms) the remote ip address
 /// has to wait before getting its 403 response. During that time,
 /// the remote ip address is kept in purgatory and its authentication
 /// requests will fail.</param>
 /// <returns>Return the application builder instance for method chaining.</returns>
 public static IApplicationBuilder UseBasicAuthentication(this IApplicationBuilder builder, AuthenticateDelegate authenticate, string realm = "", int purgatoryPeriod = 500)
 {
     return(builder.UseMiddleware <BasicAuthenticationMiddleware>(authenticate, realm, purgatoryPeriod));
 }
示例#18
0
 public static void Authenticate(AuthenticateDelegate callback)
 {
     Log.Debug("[Google] Authenticate");
     GoogleImpl.Authenticate(callback);
 }
示例#19
0
 public RemoteDesktop()
 {
     // Delegate that retrieves the given password
     GetPassword = () => password;
 }
示例#20
0
        public IAsyncResult BeginAuthenticate(string userName,string password,AsyncCallback callback,object state)
        {
            if(this.IsDisposed){
                throw new ObjectDisposedException(this.GetType().Name);
            }
            if(!this.IsConnected){
				throw new InvalidOperationException("You must connect first.");
			}
			if(this.IsAuthenticated){
				throw new InvalidOperationException("Session is already authenticated.");
			}

            AuthenticateDelegate asyncMethod = new AuthenticateDelegate(this.Authenticate);
            AsyncResultState asyncState = new AsyncResultState(this,asyncMethod,callback,state);
            asyncState.SetAsyncResult(asyncMethod.BeginInvoke(userName,password,new AsyncCallback(asyncState.CompletedCallback),null));

            return asyncState;
        }
示例#21
0
 public static void Authenticate(AuthenticateDelegate callback)
 {
     Log.Debug("[NetmarblePC] Authenticate");
     netmarblePCImpl.Authenticate(callback);
 }