/// <summary>Initializes a new instance of the <see cref="PingFederateTokenRequestContext"/> class.</summary>
 /// <param name="context">The context.</param>
 /// <param name="options">The options.</param>
 /// <param name="state">The state.</param>
 /// <param name="code">The code.</param>
 /// <param name="properties">The properties</param>
 public PingFederateTokenRequestContext(IOwinContext context, PingFederateAuthenticationOptions options, string state, string code, AuthenticationProperties properties)
     : base(context)
 {
     this.Context = context;
     this.Options = options;
     this.State = state;
     this.Code = code;
     this.Properties = properties;
 }
 /// <summary>Initializes a new instance of the <see cref="PingFederateTokenRequestContext"/> class.</summary>
 /// <param name="context">The context.</param>
 /// <param name="options">The options.</param>
 /// <param name="state">The state.</param>
 /// <param name="code">The code.</param>
 /// <param name="properties">The properties</param>
 public PingFederateTokenRequestContext(IOwinContext context, PingFederateAuthenticationOptions options, string state, string code, AuthenticationProperties properties)
     : base(context)
 {
     this.Context    = context;
     this.Options    = options;
     this.State      = state;
     this.Code       = code;
     this.Properties = properties;
 }
        protected override void ProcessCore(IdentityProvidersArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            IdentityProvider identityProvider   = this.GetIdentityProvider();
            string           authenticationType = this.GetAuthenticationType();

            //Settings from config
            string clientId        = Settings.GetSetting("MyProject.ClientId");
            string clientSecret    = Settings.GetSetting("MyProject.ClientSecret");
            string pingFederateUrl = Settings.GetSetting("MyProject.PingFederateUrl");
            string callbackPath    = Settings.GetSetting("MyProject.CallbackPath");

            var provider = new PingFederateAuthenticationProvider()
            {
                OnAuthenticated = (context) =>
                {
                    //Log token, only if need to check all available values inside it else comment out this line.
                    Sitecore.Diagnostics.Log.Info(context.Identity.Claims.FirstOrDefault(x => x.Type == "id_token").Value, this);

                    //Add additional claims for property mapping as this library has limited mappings covered inside
                    context.Identity.AddClaim(new Claim("uid", context.User.Value <string>("uid")));
                    context.Identity.AddClaim(new Claim("mail", context.User.Value <string>("mail")));
                    context.Identity.AddClaim(new Claim("displayName", context.User.Value <string>("displayName")));

                    //Add additional claims for groups/memberOf mapping as this library has limited mappings covered inside
                    if (context.User.Value <JArray>("memberOf") != null)
                    {
                        foreach (var groups in context.User.Value <JArray>("memberOf"))
                        {
                            context.Identity.AddClaim(new Claim("memberOf", GetMemberGroup(groups.Value <string>())));
                        }
                    }

                    //Transform all mappings
                    ClaimsIdentity identity = context.Identity;

                    foreach (Transformation current in identityProvider.Transformations)
                    {
                        current.Transform(identity, new TransformationContext(FederatedAuthenticationConfiguration, identityProvider));
                    }
                    return(System.Threading.Tasks.Task.FromResult(0));
                }
            };

            var options = new PingFederateAuthenticationOptions();

            options.AuthenticationType = GetAuthenticationType();
            options.ClientId           = clientId;
            options.ClientSecret       = clientSecret;
            options.Provider           = provider;
            options.PingFederateUrl    = pingFederateUrl;
            options.CallbackPath       = new PathString(callbackPath);
            args.App.UsePingFederateAuthentication(options);
        }
 /// <summary>Initializes a new instance of the <see cref="PingFederateAuthenticatingContext"/> class.</summary>
 /// <param name="context">The context.</param>
 /// <param name="options">The options.</param>
 public PingFederateAuthenticatingContext(IOwinContext context, PingFederateAuthenticationOptions options)
     : base(context)
 {
     this.Context = context;
     this.Options = options;
 }
 /// <summary>Initializes a new instance of the <see cref="PingFederateAuthenticatingContext"/> class.</summary>
 /// <param name="context">The context.</param>
 /// <param name="options">The options.</param>
 public PingFederateAuthenticatingContext(IOwinContext context, PingFederateAuthenticationOptions options)
     : base(context)
 {
     this.Context = context;
     this.Options = options;
 }