/// <summary> /// Requesthandler /// /// Trys to select the client desired authentication mechanism and responds with the selection status /// </summary> /// <param name="subsystem"></param> /// <param name="requestCtx"></param> private void HandleSelectAuthenticationMechanismsRequest(AuthenticationSubsystem subsystem, RequestContext <SelectAuthenticationMechanismsRequest, SelectAuthenticationMechanismsResponse> requestCtx) { List <string> compatibleAuthenticationMechanisms = ListCompatibleAuthenticationMechanisms(); try { if (compatibleAuthenticationMechanisms.Contains(requestCtx.Request.AuthMechanismToSelect)) { MyServerContext.ServerAuthenticationContext = new ServerAuthenticationContext(); MyServerContext.ServerAuthenticationContext.AuthenticationMechanism = CreateAuthenticationMechanism(requestCtx.Request.AuthMechanismToSelect); MyServerContext.ServerAuthenticationContext.AuthenticationMechanism.Initialize(_context); SelectAuthenticationMechanismsResponse response = requestCtx.CreateResponse(); response.Succeeded = true; response.Execute(); } else { SelectAuthenticationMechanismsResponse response = requestCtx.CreateResponse(); response.Succeeded = false; response.SetKnownErrorCode(AuthenticationSubsystemResponseBase.ErrorCodeEnum.AuthenticationMechanismNotAvailable); response.Execute(); } } catch (Exception ex) { SelectAuthenticationMechanismsResponse response = requestCtx.CreateResponse(); response.Succeeded = false; response.CustomErrorMessage = string.Format("An unexpected error occured: {0}", ex.Message); response.Execute(); } }
/// <summary> /// Requesthandler /// /// Looks for all configured and compatible authentication methods for the requesting client /// </summary> /// <param name="subsystem"></param> /// <param name="requestCtx"></param> private void HandleListAuthenticationMechanisms(AuthenticationSubsystem subsystem, RequestContext <ListAuthenticationMechanismsRequest, ListAuthenticationMechanismsResponse> requestCtx) { ListAuthenticationMechanismsResponse response = requestCtx.CreateResponse(); response.AuthenticationModes = ListCompatibleAuthenticationMechanisms().ToArray(); response.Execute(); }
/// <summary> /// Starts the authentication process /// </summary> /// <param name="subsystem"></param> /// <param name="requestCtx"></param> private void HandleAuthenticateRequest(AuthenticationSubsystem subsystem, RequestContext <AuthenticateRequest, AuthenticateResponse> requestCtx) { if (MyServerContext.ServerAuthenticationContext == null || MyServerContext.ServerAuthenticationContext.AuthenticationMechanism == null) { AuthenticateResponse response = requestCtx.CreateResponse(); response.Succeeded = false; response.SetKnownErrorCode(AuthenticationSubsystemResponseBase.ErrorCodeEnum.NoAuthenticationMechanismSelected); response.Execute(); } else { MyServerContext.ServerAuthenticationContext.AuthenticationMechanism.Authenticate(requestCtx); } }