/// <inheritdoc/> public override void Authenticate(Guid sessionId, IZyanDispatcher dispatcher) { // step1 request: User -> Host: I, A = g^a (identifies self, a = random number) var clientEphemeral = SrpClient.GenerateEphemeral(); var request1 = new Hashtable { { SrpProtocolConstants.SRP_STEP_NUMBER, 1 }, { SrpProtocolConstants.SRP_USERNAME, UserName }, { SrpProtocolConstants.SRP_CLIENT_PUBLIC_EPHEMERAL, clientEphemeral.Public }, }; // step1 response: Host -> User: s, B = kv + g^b (sends salt, b = random number) var response1 = dispatcher.Logon(sessionId, request1).Parameters; var salt = (string)response1[SrpProtocolConstants.SRP_SALT]; var serverPublicEphemeral = (string)response1[SrpProtocolConstants.SRP_SERVER_PUBLIC_EPHEMERAL]; // step2 request: User -> Host: M = H(H(N) xor H(g), H(I), s, A, B, K) var privateKey = SrpClient.DerivePrivateKey(salt, UserName, Password); var clientSession = SrpClient.DeriveSession(clientEphemeral.Secret, serverPublicEphemeral, salt, UserName, privateKey); var request2 = new Hashtable { { SrpProtocolConstants.SRP_STEP_NUMBER, 2 }, { SrpProtocolConstants.SRP_CLIENT_SESSION_PROOF, clientSession.Proof }, }; // step2 response: Host -> User: H(A, M, K) var response2 = dispatcher.Logon(sessionId, request2).Parameters; var serverSessionProof = (string)response2[SrpProtocolConstants.SRP_SERVER_SESSION_PROOF]; SrpClient.VerifySession(clientEphemeral.Public, clientSession, serverSessionProof); }
public override void Authenticate(Guid sessionId, IZyanDispatcher dispatcher) { var credentials = (Hashtable)CredentialsHashtable.Clone(); if (credentials.Count == 0) { throw new Exception("No credentials specified"); } // step 0 credentials["#"] = 0; var reply = dispatcher.Logon(sessionId, credentials); // check the reply var payload = reply.ErrorMessage; if (reply.ErrorMessage != "World") { throw new Exception("Bad reply for step 0"); } // step 1 credentials["#"] = 1; credentials["@"] = "Icanhaz"; reply = dispatcher.Logon(sessionId, credentials); // check the reply if (reply.ErrorMessage != "Cheezburger") { throw new Exception("Bad reply for step 1"); } }
public override void Authenticate(Guid sessionId, IZyanDispatcher dispatcher) { dispatcher.Logon(sessionId, new Hashtable { { SrpProtocolConstants.SRP_STEP_NUMBER, 3 }, }); }
public override void Authenticate(Guid sessionId, IZyanDispatcher dispatcher) { dispatcher.Logon(sessionId, new Hashtable { { SrpProtocolConstants.SRP_STEP_NUMBER, 2 }, { SrpProtocolConstants.SRP_CLIENT_SESSION_PROOF, "woof" }, }); }
/// <summary> /// Authenticates a specific user based on their credentials. /// </summary> /// <param name="sessionId">Session identity.</param> /// <param name="dispatcher">Remote dispatcher</param> public virtual void Authenticate(Guid sessionId, IZyanDispatcher dispatcher) { var credentials = CredentialsHashtable; if (credentials != null && credentials.Count == 0) { credentials = null; } var response = dispatcher.Logon(sessionId, credentials); if (!response.Completed) { throw new SecurityException(response.ErrorMessage ?? "Authentication is not completed."); } // this case is likely to be handled by ZyanDispatcher itself if (!response.Success) { throw new SecurityException(response.ErrorMessage ?? "Authentication is not successful."); } }
/// <summary> /// Führt einen entfernten Methodenaufruf aus. /// </summary> /// <param name="methodCallMessage">Remoting-Nachricht mit Details für den entfernten Methodenaufruf</param> /// <returns>Remoting Antwortnachricht</returns> private IMessage InvokeRemoteMethod(IMethodCallMessage methodCallMessage) { // Aufrufschlüssel vergeben Guid trackingID = Guid.NewGuid(); try { // Variable für Rückgabewert object returnValue = null; // Variable für Verdrahtungskorrelationssatz List <DelegateCorrelationInfo> correlationSet = null; // Wenn die Komponente SingleCallaktiviert ist ... if (_activationType == ActivationType.SingleCall) { // Korrelationssatz übernehmen (wird mit übertragen) correlationSet = _delegateCorrelationSet; } // Ereignisargumente für BeforeInvoke erstellen BeforeInvokeEventArgs cancelArgs = new BeforeInvokeEventArgs() { TrackingID = trackingID, InterfaceName = _interfaceType.FullName, DelegateCorrelationSet = correlationSet, MethodName = methodCallMessage.MethodName, Arguments = methodCallMessage.Args, Cancel = false }; // BeforeInvoke-Ereignis feuern _connection.OnBeforeInvoke(cancelArgs); // Wenn der Aufruf abgebrochen werden soll ... if (cancelArgs.Cancel) { // Wenn keine Abbruchausnahme definiert ist ... if (cancelArgs.CancelException == null) { // Standard-Abbruchausnahme erstellen cancelArgs.CancelException = new InvokeCanceledException(); } // InvokeCanceled-Ereignis feuern _connection.OnInvokeCanceled(new InvokeCanceledEventArgs() { TrackingID = trackingID, CancelException = cancelArgs.CancelException }); // Abbruchausnahme werfen throw cancelArgs.CancelException; } // Parametertypen ermitteln ParameterInfo[] paramDefs = methodCallMessage.MethodBase.GetParameters(); try { // Ggf. Delegaten-Parameter abfangen object[] checkedArgs = InterceptDelegateParameters(methodCallMessage); // Entfernten Methodenaufruf durchführen returnValue = _remoteInvoker.Invoke(trackingID, _interfaceType.FullName, correlationSet, methodCallMessage.MethodName, paramDefs, checkedArgs); // Ereignisargumente für AfterInvoke erstellen AfterInvokeEventArgs afterInvokeArgs = new AfterInvokeEventArgs() { TrackingID = trackingID, InterfaceName = _interfaceType.FullName, DelegateCorrelationSet = correlationSet, MethodName = methodCallMessage.MethodName, Arguments = methodCallMessage.Args, ReturnValue = returnValue }; // AfterInvoke-Ereignis feuern _connection.OnAfterInvoke(afterInvokeArgs); } catch (InvalidSessionException) { // Wenn automatisches Anmelden bei abgelaufener Sitzung aktiviert ist ... if (_autoLoginOnExpiredSession) { // Neu anmelden _remoteInvoker.Logon(_sessionID, _autoLoginCredentials); // Entfernten Methodenaufruf erneut versuchen returnValue = _remoteInvoker.Invoke(trackingID, _interfaceType.FullName, correlationSet, methodCallMessage.MethodName, paramDefs, methodCallMessage.Args); } } // Remoting-Antwortnachricht erstellen und zurückgeben return(new ReturnMessage(returnValue, null, 0, methodCallMessage.LogicalCallContext, methodCallMessage)); } catch (TargetInvocationException targetInvocationException) { // Aufrufausnahme als Remoting-Nachricht zurückgeben return(new ReturnMessage(targetInvocationException, methodCallMessage)); } catch (SocketException socketException) { // TCP-Sockelfehler als Remoting-Nachricht zurückgeben return(new ReturnMessage(socketException, methodCallMessage)); } catch (InvalidSessionException sessionException) { // Sitzungsfehler als Remoting-Nachricht zurückgeben return(new ReturnMessage(sessionException, methodCallMessage)); } }