public static object HookAuthentication(this OwinRequest request, IAuthenticationHandler handler) { var chained = request.Get<AuthenticateDelegate>("security.Authenticate"); var hook = new Hook(handler, chained); request.Set<AuthenticateDelegate>("security.Authenticate", hook.Authenticate); return hook; }
/// <summary> /// Creates a new instance. /// </summary> /// <param name="photoService">The photo service.</param> /// <param name="authenticationHandler">The authentication handler.</param> /// <param name="dialogService">The dialog service.</param> public DebugViewModel(IPhotoService photoService, IAuthenticationHandler authenticationHandler, IDialogService dialogService) { _photoService = photoService; _authenticationHandler = authenticationHandler; _dialogService = dialogService; ThrowExceptionCommand = new RelayCommand(OnThrowException); }
private async Task <Exception> CreateMismatchedSignInHandlerException(string scheme, IAuthenticationHandler handler) { var schemes = await GetAllSignInSchemeNames(); var mismatchError = $"The authentication handler registered for scheme '{scheme}' is '{handler.GetType().Name}' which cannot be used for SignInAsync. "; if (string.IsNullOrEmpty(schemes)) { // CookieAuth is the only implementation of sign-in. return(new InvalidOperationException(mismatchError + $"Did you forget to call AddAuthentication().AddCookie(\"Cookies\") and SignInAsync(\"Cookies\",...)?")); } return(new InvalidOperationException(mismatchError + $"The registered sign-in schemes are: {schemes}.")); }
public AuthController(IAuthenticationHandler authHandler, ILogger <AuthController> logger) { _authHandler = authHandler; _logger = logger; }
public TestClient(IAuthenticationHandler authenticationHandler, IHeaderHandlerFactory headerHandlers, TypeWrapper interfaceType) : base(authenticationHandler, headerHandlers, interfaceType) { }
public AccountController(IAuthenticationHandler authenticationHandler) { this.authenticationHandler = authenticationHandler; }
public AcsControllerActionInvoker(ICookieToAuthenticationHeaderHandler cookieToAuthorizationHeaderHandler, IAuthenticationHandler authenticationHandler) { this.cookieToAuthorizationHeaderHandler = cookieToAuthorizationHeaderHandler; this.authenticationHandler = authenticationHandler; }
/// <summary> /// Initializes a new instance of the <see cref="ServiceClient" /> class. /// </summary> /// <param name="authenticationHandler">The authentication handler.</param> public ServiceClient(IAuthenticationHandler authenticationHandler) { _authenticationHandler = authenticationHandler; _mobileServiceClient = AzureAppService.Current; }
public AuthenticationController(IAuthenticationHandler authenticationHandler) { _authenticationHandler = authenticationHandler; }
private void RegisterAuthenticationHandler() { var auth = Context.GetAuthentication(); PriorHandler = auth.Handler; auth.Handler = this; }
public override V3Message execute(Request message, RequestContext context) { object returnValue = null; switch (operation) { case SUBSCRIBE_OPERATION: { IDestination destObj = ORBConfig.GetInstance().GetDataServices().GetDestinationManager().GetDestination(destination); Hashtable headers = new Hashtable(); RTMPConnection connection = (RTMPConnection)ConnectionHub.getConnectionLocal(); if (destObj != null) { String selectorName = (String)this.headers["DSSelector"]; String subtopic = (String)this.headers["DSSubtopic"]; String dsId = connection == null ? (String)this.headers["DSId"] : connection.GetHashCode().ToString(); String channel = (String)this.headers["DSEndpoint"]; Subscriber subscriber = SubscriptionsManager.GetInstance().getSubscriber( Subscriber.buildId(dsId, destObj.GetName(), subtopic, selectorName)); if (clientId == null || clientId.Equals("")) { clientId = Guid.NewGuid().ToString().ToUpper(); } if (subscriber != null) { if (subscriber.addClient(clientId.ToString())) { destObj.GetServiceHandler().HandleSubscribe(subscriber, clientId.ToString(), this); } return(new AckMessage(messageId, clientId, null, headers)); } object wsContext = ThreadContext.getProperties()[ORBConstants.WEB_SOCKET_MODE]; if (wsContext != null) { subscriber = new WebSocketSubscriber(selectorName, destObj, (UserContext)wsContext); } else if (connection != null) { subscriber = new DedicatedSubscriber(selectorName, destObj); subscriber.setChannelId(RTMPHandler.getChannelId()); subscriber.setConnection(connection); } else { subscriber = SubscriberFactory.CreateSubscriber(channel, selectorName, destObj); } subscriber.setDSId(dsId); subscriber.setSubtopic(subtopic); subscriber.addClient((String)clientId); try { SubscriptionsManager.GetInstance().AddSubscriber(dsId, destObj.GetName(), subscriber); } catch (Exception e) { if (Log.isLogging(LoggingConstants.EXCEPTION)) { Log.log(LoggingConstants.EXCEPTION, e); } } destObj.GetServiceHandler().HandleSubscribe(subscriber, clientId.ToString(), this); } else { String error = "Unknown destination " + destination + ". Cannot handle subscription request"; if (Log.isLogging(LoggingConstants.ERROR)) { Log.log(LoggingConstants.ERROR, error); } return(new ErrMessage(messageId, new Exception(error))); } return(new AckMessage(messageId, clientId, null, headers)); } break; case UNSUBSCRIBE_OPERATION: { String subtopic = (String)this.headers["DSSubtopic"]; String dsId = (String)this.headers["DSId"]; String selectorName = (String)this.headers["DSSelector"]; RTMPConnection connection = (RTMPConnection)ConnectionHub.getConnectionLocal(); if (connection != null) { dsId = connection.GetHashCode().ToString(); } Subscriber subscriber = SubscriptionsManager.GetInstance().getSubscriber( Subscriber.buildId(dsId, destination, subtopic, selectorName)); if (subscriber != null) { SubscriptionsManager.GetInstance().unsubscribe(subscriber, clientId.ToString(), this); } } break; case DISCONNECT_OPERATION: { String dsId = (String)this.headers["DSId"]; RTMPConnection connection = (RTMPConnection)ConnectionHub.getConnectionLocal(); if (connection != null) { dsId = connection.GetHashCode().ToString(); } SubscriptionsManager subscriptionsManager = SubscriptionsManager.GetInstance(); List <Subscriber> subscribers = subscriptionsManager.getSubscribersByDsId(dsId); if (subscribers != null) { foreach (Subscriber subscriber in subscribers) { if (subscriber != null) { subscriptionsManager.unsubscribe(subscriber, this); } } } subscriptionsManager.removeSubscriber(dsId); } break; case POLL_OPERATION: { String dsId = (String)this.headers["DSId"]; RTMPConnection connection = (RTMPConnection)ConnectionHub.getConnectionLocal(); if (connection != null) { dsId = connection.GetHashCode().ToString() + ""; } try { WebORBArray <V3Message> messages = new WebORBArray <V3Message>(SubscriptionsManager.GetInstance().getMessages(dsId)); if (messages.Count == 0) { return(new AckMessage(null, null, null, new Hashtable())); } return(new CommandMessage(CLIENT_SYNC_OPERATION, messages)); } catch (Exception e) { String error = "Invalid client id " + dsId; if (Log.isLogging(LoggingConstants.ERROR)) { Log.log(LoggingConstants.ERROR, error, e); } return(new ErrMessage(messageId, new Exception(error))); } } break; case CLIENT_PING_OPERATION: { Hashtable headers = new Hashtable(); RTMPConnection connection = (RTMPConnection)ConnectionHub.getConnectionLocal(); if (connection != null) { headers.Add("DSId", connection.GetHashCode().ToString()); } else { headers.Add("DSId", Guid.NewGuid().ToString().ToUpper()); } return(new AckMessage(messageId, clientId, null, headers)); } break; case LOGOUT_OPERATION: { ThreadContext.setCallerCredentials(null, null); Thread.CurrentPrincipal = null; } break; case LOGIN_OPERATION: { String credentials = (String)((IAdaptingType)((object[])body.body)[0]).defaultAdapt(); byte[] bytes = Convert.FromBase64String(credentials); credentials = new String(Encoding.UTF8.GetChars(bytes)); IAuthenticationHandler authHandler = ORBConfig.GetInstance().getSecurity().GetAuthenticationHandler(); if (authHandler == null) { ErrMessage errorMessage = new ErrMessage(messageId, new ServiceException("Missing authentication handler")); errorMessage.faultCode = "Client.Authentication"; return(errorMessage); } int index = credentials.IndexOf(":"); string userid = null; string password = null; if (index != -1 && index != 0 && index != credentials.Length - 1) { userid = credentials.Substring(0, index); password = credentials.Substring(index + 1); try { IPrincipal principal = authHandler.CheckCredentials(userid, password, message); try { Thread.CurrentPrincipal = principal; ThreadContext.currentHttpContext().User = principal; } catch (Exception exception) { if (Log.isLogging(LoggingConstants.ERROR)) { Log.log(LoggingConstants.ERROR, "Unable to set current principal. Make sure your current permission set allows Principal Control", exception); } throw exception; } Credentials creds = new Credentials(); creds.userid = userid; creds.password = password; ThreadContext.setCallerCredentials(creds, principal); } catch (Exception exception) { ErrMessage errorMessage = new ErrMessage(messageId, exception); errorMessage.faultCode = "Client.Authentication"; return(errorMessage); } } else { ErrMessage errorMessage = new ErrMessage(messageId, new ServiceException("Invalid credentials")); errorMessage.faultCode = "Client.Authentication"; return(errorMessage); } } break; } return(new AckMessage(messageId, clientId, returnValue, new Hashtable())); }
/// <summary> /// This method registers an encryption handler with the Security container, which can encrypt and decrypt a binary blob. /// </summary> /// <param name="identifier">The identifier. This is used to identify the handler so that it can be assigned to multiple channels.</param> /// <param name="handler">The actual handler.</param> public void RegisterAuthenticationHandler(string identifier, IAuthenticationHandler handler) { mSecurity.RegisterAuthenticationHandler(identifier, handler); }
public Hook(IAuthenticationHandler handler, AuthenticateDelegate chained) { _handler = handler; Chained = chained; }
public RegSysCommand(IAuthenticationHandler authenticationHandler) { _authenticationHandler = authenticationHandler; }
private async Task <Exception> CreateMismatchedSignOutHandlerException(string scheme, IAuthenticationHandler handler) { var schemes = await GetAllSignOutSchemeNames(); var mismatchError = $"The authentication handler registered for scheme '{scheme}' is '{handler.GetType().Name}' which cannot be used for {nameof(SignOutAsync)}. "; if (string.IsNullOrEmpty(schemes)) { // CookieAuth is the most common implementation of sign-out, but OpenIdConnect and WsFederation also support it. return(new InvalidOperationException(mismatchError + $"Did you forget to call AddAuthentication().AddCookie(\"Cookies\") and {nameof(SignOutAsync)}(\"Cookies\",...)?")); } return(new InvalidOperationException(mismatchError + $"The registered sign-out schemes are: {schemes}.")); }
public AcsControllerFactory(ICookieToAuthenticationHeaderHandler cookieToAuthorizationHeaderHandler, IAuthenticationHandler authenticationHandler) { this.actionInvoker = new AcsControllerActionInvoker(cookieToAuthorizationHeaderHandler, authenticationHandler); }
public void RegisterAuthenticationHandler(IHttpAuthenticationFeature auth) { PriorHandler = auth.Handler; auth.Handler = this; }
public static Mock <IAuthenticationHandlerProvider> CreateMockAuthenticationHandlerProvider(IAuthenticationHandler handler = null) { var mock = new Mock <IAuthenticationHandlerProvider>(); mock.Setup(m => m.GetHandlerAsync(It.IsAny <HttpContext>(), It.IsAny <string>())).ReturnsAsync(() => { return(handler ?? CreateMockAuthenticationHandler().Object); }); return(mock); }
public Connection(IAuthenticationHandler authenticationHandler) { _httpClient = new HttpClient(); }