public override AudienceSpecifiedNotificationBase DeepCloneWithAudience(IAudience audience) { var result = new AudienceVoidNotification( audience); return(result); }
static IAudience Op <T>(IAudience a, IAudience init) where T : class, IAudienceCompounder, new() { if (a != null) { if (init is T) { var self = init as T; List <IAudience> list = self.Audiences.ToList(); if (a is T) { var other = a as T; list.AddRange(other.Audiences); } else { list.Add(a); } self.Audiences = list; } else { return new T { Audiences = new[] { init, a } } }; } return(init); }
/// <summary> /// 新しいインスタンスを生成します。 /// </summary> /// <param name="singer">歌手</param> /// <param name="audience">観客</param> public House(ILoggerFactory loggerFactory, ISinger singer, IAudience audience) { _logger = loggerFactory.CreateLogger <House>(); Singer = singer; Audience = audience; }
/// Generated the token in format JWT /// </summary> /// <param name="data">Data for generated token</param> /// <returns>Token generated</returns> /// <author> Natalia Ladino - [email protected] </author> public string Protect(AuthenticationTicket data) { string audienceId = data.Properties.Dictionary.ContainsKey(AudiencePropertyKey) ? data.Properties.Dictionary[AudiencePropertyKey] : null; if (string.IsNullOrWhiteSpace(audienceId)) { throw new InvalidOperationException(Resources.Message_es.InvalidAudience); } blAUdience = new BlAudience(); Audience audience = blAUdience.GetAudienceByClientId(audienceId); if (!string.IsNullOrEmpty(audience.Secret)) { string symmetricKeyAsBase64 = audience.Secret; var keyByteArray = TextEncodings.Base64Url.Decode(symmetricKeyAsBase64); var signingKey = new HmacSigningCredentials(keyByteArray); var issued = data.Properties.IssuedUtc; var expires = data.Properties.ExpiresUtc; var token = new JwtSecurityToken(issuerGenerated, audienceId, data.Identity.Claims, issued.Value.LocalDateTime, expires.Value.LocalDateTime, signingKey); var handler = new JwtSecurityTokenHandler(); var jwt = handler.WriteToken(token); return(jwt); } else { throw new InvalidOperationException(Resources.Message_es.ExceptionSecret); } }
/// <summary> /// Initializes a new instance of the <see cref="AudienceSpecifiedNotificationBase"/> class. /// </summary> /// <param name="audience">Audience to send the notification to.</param> protected AudienceSpecifiedNotificationBase( IAudience audience) { new { audience }.AsArg().Must().NotBeNull(); this.Audience = audience; }
public GetDeliveryChannelConfigsOp DeepCloneWithAudience(IAudience audience) { var result = new GetDeliveryChannelConfigsOp( this.Notification?.DeepClone(), audience); return(result); }
public GetAudienceResult DeepCloneWithAudience(IAudience audience) { var result = new GetAudienceResult( audience, this.Failures?.DeepClone(), this.FailureAction.DeepClone()); return(result); }
public PrepareToSendOnChannelOp DeepCloneWithAudience(IAudience audience) { var result = new PrepareToSendOnChannelOp( this.Notification?.DeepClone(), audience, this.DeliveryChannel?.DeepClone(), this.InheritableTags?.DeepClone()); return(result); }
public static IAudience Or(this IAudience a, IAudience b) { if (a == null) throw new ArgumentNullException("a"); if (a is AudienceBase) return (a as AudienceBase).Or(b); throw new InvalidOperationException("Type is not supported: " + a.GetType().FullName); }
/// <summary> /// Initializes a new instance of the <see cref="GetDeliveryChannelConfigsOp"/> class. /// </summary> /// <param name="notification">The notification to send.</param> /// <param name="audience">The audience for the notification.</param> public GetDeliveryChannelConfigsOp( INotification notification, IAudience audience) { new { notification }.AsArg().Must().NotBeNull(); new { audience }.AsArg().Must().NotBeNull(); this.Notification = notification; this.Audience = audience; }
public ArgonautUser(bool validated, IAudience audience, string validationFailureUserMessage = "") { if (audience == null) { this.Validated = false; } this.Validated = validated; this.Audience = audience; this.ValidationFailureUserMessage = validationFailureUserMessage; }
/// <summary> /// Initializes a new instance of the <see cref="GetAudienceResult"/> class. /// </summary> /// <param name="audience">The resolved audience.</param> /// <param name="failures">The failures that occurred when executing the operation.</param> /// <param name="failureAction">The action to take when <paramref name="failures"/> contains one or more elements.</param> public GetAudienceResult( IAudience audience, IReadOnlyCollection <IFailure> failures, FailureAction failureAction) { new { failures }.AsArg().Must().NotContainAnyNullElementsWhenNotNull(); new { failureAction }.AsArg().Must().NotBeEqualTo(FailureAction.Unknown); this.Audience = audience; this.Failures = failures; this.FailureAction = failureAction; }
public JWTBuilder(IAudience audience) { if (audience == null) { throw new ArgumentNullException(nameof(IAudience)); } _audience = audience; this.validationParameters = new JWTValidationParametersGenerator(audience); this._standardClaims = new List <Claim>(); this._additionalClaims = new List <Claim>(); }
public static AudienceNot Not(this IAudience a) { if (a == null) { return(null); } if (a is AudienceBase) { return((a as AudienceBase).Not()); } throw new InvalidOperationException("Type is not supported: " + a.GetType().FullName); }
public static IAudience Or(this IAudience a, IAudience b) { if (a == null) { throw new ArgumentNullException("a"); } if (a is AudienceBase) { return((a as AudienceBase).Or(b)); } throw new InvalidOperationException("Type is not supported: " + a.GetType().FullName); }
/// <summary> /// Initializes a new instance of the <see cref="PrepareToSendOnChannelOp"/> class. /// </summary> /// <param name="notification">The notification to send.</param> /// <param name="audience">The audience for the notification.</param> /// <param name="deliveryChannel">The channel on which to deliver the notification.</param> /// <param name="inheritableTags">OPTIONAL tags that can be inherited from a prior step in the workflow. DEFAULT is null, indicating that there was no prior step or that no tags have been established in the workflow.</param> public PrepareToSendOnChannelOp( INotification notification, IAudience audience, IDeliveryChannel deliveryChannel, IReadOnlyCollection <NamedValue <string> > inheritableTags = null) { new { notification }.AsArg().Must().NotBeNull(); new { audience }.AsArg().Must().NotBeNull(); new { deliveryChannel }.AsArg().Must().NotBeNull(); this.Notification = notification; this.Audience = audience; this.DeliveryChannel = deliveryChannel; this.InheritableTags = inheritableTags; }
public static void AddArgonaut(this IServiceCollection services, IAudience audience) { if (services == null) { throw new ArgumentNullException(nameof(services)); } if (audience == null) { throw new ArgumentNullException(nameof(audience)); } var jwtBuilder = new Argonaut.Internal.JWTBuilder(audience); services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options => options.TokenValidationParameters = jwtBuilder.validationParameters.SecretAndExpirationDate()); }
private async Task <GetDeliveryChannelConfigsResult> GetDeliveryChannelConfigsAsync( INotification notification, IAudience audience) { GetDeliveryChannelConfigsResult result; try { var getDeliveryChannelConfigsOp = new GetDeliveryChannelConfigsOp(notification, audience); result = await this.getDeliveryChannelConfigsProtocol.ExecuteAsync(getDeliveryChannelConfigsOp); result.AsOp().Must().NotBeNull(Invariant($"Executing {nameof(GetDeliveryChannelConfigsOp)} should not return null.")); } catch (Exception ex) { result = new GetDeliveryChannelConfigsResult(null, new[] { new ExceptionThrownFailure(ex.ToString()) }, FailureAction.Stop); } return(result); }
/// <summary> /// Configuration of server of authorization /// </summary> /// <param name="app">Param of current context</param> public void ConfigureOAuth(IAppBuilder app) { blAUdience = new BlAudience(); List <string> allowedAudienceIds = new List <string>(); List <IIssuerSecurityTokenProvider> providers = new List <IIssuerSecurityTokenProvider>(); var issuer = ConfigurationManager.AppSettings["issuer"]; List <Audience> AudiencesList = blAUdience.GetAudiences(); app.Use <BlAuthenticationMiddleware>(); //Allows override of Invoke OWIN commands ////El objetivo de esta petición es sobreescribir la petición para //// invocar el negocio BlAuthenticationMiddleware y retornar el codigo de no autorizado en la generación del token. OAuthAuthorizationServerOptions OAuthServerOptions = new OAuthAuthorizationServerOptions() { //For Dev enviroment only (on production should be AllowInsecureHttp = false) AllowInsecureHttp = bool.Parse(ConfigurationManager.AppSettings["allowInsecureHttp"]), TokenEndpointPath = new PathString(ConfigurationManager.AppSettings["pathToken"]), AccessTokenExpireTimeSpan = TimeSpan.FromMinutes(Convert.ToInt16(ConfigurationManager.AppSettings["expiredToken"])), Provider = new BlCustomOAuthProvider(), AccessTokenFormat = new BlCustomJwtFormat(issuer) }; // OAuth 2.0 Bearer Access Token Generation app.UseOAuthAuthorizationServer(OAuthServerOptions); //// El objetivo de esta instrucción es configurar el servidor de autorización. foreach (var validAudience in AudiencesList) { allowedAudienceIds.Add(validAudience.ClientId); providers.Add(new SymmetricKeyIssuerSecurityTokenProvider(issuer, TextEncodings.Base64Url.Decode(validAudience.Secret))); } // Api controllers with an [Authorize] attribute will be validated with JWT app.UseJwtBearerAuthentication( new JwtBearerAuthenticationOptions { AuthenticationMode = AuthenticationMode.Active, AllowedAudiences = allowedAudienceIds.ToArray(), IssuerSecurityTokenProviders = providers.ToArray() }); }
private AuditResult CheckUser(SampleEmployee person, IAudience audience, JSchema schema) { IList <ValidationError> errors = new List <ValidationError>(); var userToCheck = person.ToJson(); //var schema = audience.Schema.GetProviderSpecificSchema(this.Name); bool valid = userToCheck.IsValid(schema, out errors); // map these to our own error object var auditErrors = new List <AuditError>(); foreach (var error in errors) { auditErrors.Add(new AuditError(error, audience, this, schema)); } var result = new AuditResult(person, auditErrors); return(result); }
static IAudience BatchOps(IEnumerable <IAudience> arr, IAudience init, Func <IAudience, IAudience> op) { IAudience res = init; if (arr != null) { arr = from a in arr where a != null select a; if (arr.Count() != 0) { foreach (IAudience a in arr) { if (a == null) { continue; } res = op(a); } } } return(res); }
private async Task <PrepareToSendOnChannelResult> PrepareToSendOnChannelAsync( INotification notification, IAudience audience, IDeliveryChannel channel, IReadOnlyCollection <NamedValue <string> > inheritableTags) { PrepareToSendOnChannelResult result; try { var prepareToSendOnChannelOp = new PrepareToSendOnChannelOp(notification, audience, channel, inheritableTags); result = await this.prepareToSendOnChannelProtocol.ExecuteAsync(prepareToSendOnChannelOp); result.AsOp().Must().NotBeNull(Invariant($"Executing {nameof(PrepareToSendOnChannelOp)} should not return null.")); } catch (Exception ex) { result = new PrepareToSendOnChannelResult(null, new[] { new ExceptionThrownFailure(ex.ToString()) }, PrepareToSendOnChannelFailureAction.DoNotSendOnChannel); } return(result); }
/// <summary> /// Validate the request /// </summary> /// <param name="context">Context of the request</param> /// <returns>Request validated</returns> public override Task ValidateClientAuthentication(OAuthValidateClientAuthenticationContext context) { try { blAUdience = new BlAudience(); string clientId = string.Empty; string clientSecret = string.Empty; if (!context.TryGetBasicCredentials(out clientId, out clientSecret)) { context.TryGetFormCredentials(out clientId, out clientSecret); } if (context.ClientId == null) { context.SetError("ClienteId_Invalido", Resources.Message_es.InvalidClient); return(Task.FromResult <object>(null)); } Audience audience = blAUdience.GetAudienceByClientId(clientId); if (audience == null) { context.SetError("ClienteId_Invalido", string.Format(Resources.Message_es.InvalidClient, context.ClientId)); return(Task.FromResult <object>(null)); } context.Validated(); return(Task.FromResult <object>(null)); } catch (Exception ex) { ExceptionLogging.LogException(ex); return(Task.FromResult <object>(null)); } }
public Push(IAudience audience, String alert = null, IEnumerable<BaseAlert> deviceAlerts = null) : this(alert, deviceAlerts) { Audience = audience; }
public virtual AudienceSpecifiedNotificationBase DeepCloneWithAudience(IAudience audience) { throw new NotImplementedException("This method should be abstract. It was generated as virtual so that you aren't forced to override it when you create a new model that derives from this model. It will be overridden in the generated designer file."); }
public Persistence(ILogger <Persistence> logger, IDatabase database, IAudience audience) { _logger = logger; _database = database; _audience = audience; }
public ProductService(ILogger <ProductService> logger, IMicroKernel kernel, IAudience audience) { _logger = logger; _kernel = kernel; _audience = audience; }
public Push(IAudience audience, String alert = null, IEnumerable <BaseAlert> deviceAlerts = null) : this(alert, deviceAlerts) { Audience = audience; }
/// <summary> /// Initializes a new instance of the <see cref="AudienceVoidNotification"/> class. /// </summary> /// <param name="audience">The audience.</param> public AudienceVoidNotification( IAudience audience) : base(audience) { }
static public JWTBuilder New(IAudience options) { var builder = new JWTBuilder(options); return(builder); }
public AudienceController(IAudience audienceService, ILogger <AudienceController> logger, IHostingEnvironment env) { _audienceService = audienceService; _logger = logger; _env = env; }
public AuthorizationController(ILogger <AuthorizationController> logger, IAudience audienceService) { _logger = logger; _audienceService = audienceService; }