예제 #1
0
 private bool ValidateLogout(ModelStateDictionary modelState, Api.SamlDownParty samlDownParty)
 {
     var isValid = true;
     try
     {
         if (!samlDownParty.LoggedOutUrl.IsNullOrWhiteSpace())
         {
             if (samlDownParty.LogoutBinding == null)
             {
                 throw new Exception("Logout binding is required.");
             }
         }
         else
         {
             samlDownParty.SingleLogoutUrl = null;
             samlDownParty.LogoutBinding = null;
         }
     }
     catch (Exception ex)
     {
         isValid = false;
         logger.Warning(ex);
         modelState.TryAddModelError(nameof(samlDownParty.LogoutBinding).ToCamelCase(), ex.Message);
     }
     return isValid;
 }
예제 #2
0
        private bool ValidateMetadataNameIdFormats(ModelStateDictionary modelState, Api.SamlDownParty samlDownParty)
        {
            var isValid = true;

            try
            {
                if (samlDownParty.MetadataNameIdFormats?.Count > 0)
                {
                    foreach (var nameIdFormat in samlDownParty.MetadataNameIdFormats)
                    {
                        try
                        {
                            _ = new Uri(nameIdFormat);
                        }
                        catch (Exception ex)
                        {
                            throw new Exception($"Metadata NameId format '{nameIdFormat}' not a Uri.", ex);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                isValid = false;
                logger.Warning(ex);
                modelState.TryAddModelError(nameof(samlDownParty.MetadataNameIdFormats).ToCamelCase(), ex.Message);
            }

            return(isValid);
        }
예제 #3
0
 public bool ValidateSignatureAlgorithm(ModelStateDictionary modelState, Api.SamlDownParty samlDownParty) => ValidateSignatureAlgorithm(modelState, nameof(samlDownParty.SignatureAlgorithm), samlDownParty.SignatureAlgorithm);
예제 #4
0
 private bool ValidateSignatureAlgorithmAndSigningKeys(ModelStateDictionary modelState, Api.SamlDownParty samlDownParty)
 {
     return ValidateSignatureAlgorithm(modelState, nameof(samlDownParty.SignatureAlgorithm), samlDownParty.SignatureAlgorithm) &&
         ValidateSigningKeys(modelState, nameof(samlDownParty.Keys), samlDownParty.Keys);
 }
예제 #5
0
 public bool ValidateApiModel(ModelStateDictionary modelState, Api.SamlDownParty samlDownParty)
 {
     return ValidateSignatureAlgorithmAndSigningKeys(modelState, samlDownParty) &&
         ValidateLogout(modelState, samlDownParty);
 }