Esempio n. 1
0
        public void add_a_single_key_attribute()
        {
            var response = new SamlResponse();
            response.AddAttribute("a", "1");

            response.Attributes.Get("a").ShouldBe("1");
        }
Esempio n. 2
0
 public SamlAuthenticationFailed(SamlResponse response)
 {
     Errors = response.Errors.Select(x => x.Message).ToArray();
     Name   = response.Subject.Name.Value;
     Issuer = response.Issuer;
     SamlId = response.Id;
 }
Esempio n. 3
0
 public SamlAuthenticationFailed(SamlResponse response)
 {
     Errors = response.Errors.Select(x => x.Message).ToArray();
     Name = response.Subject.Name.Value;
     Issuer = response.Issuer;
     SamlId = response.Id;
 }
        public void no_errors_if_response_is_signed()
        {
            var response = new SamlResponse
            {
                Signed = SignatureStatus.Signed
            };

            new SignatureIsRequired().Validate(response);

            response.Errors.Any().ShouldBeFalse();
        }
        public void SetUp()
        {
            var xml = new FileSystem().ReadStringFromFile("sample.xml");
            theOriginalResponse = new SamlResponseXmlReader(xml).Read();

            document = new SamlResponseXmlWriter(theOriginalResponse).Write();

            Debug.WriteLine(document.OuterXml);

            theSecondResponse = new SamlResponseXmlReader(document.OuterXml).Read();
        }
Esempio n. 6
0
        public void add_multiple_values_for_the_same_key()
        {
            var response = new SamlResponse();

            response.AddAttribute("a", "1");
            response.AddAttribute("a", "2");
            response.AddAttribute("a", "3");

            response.Attributes.Get("a").As<IEnumerable<string>>()
                .ShouldHaveTheSameElementsAs("1", "2", "3");
        }
        public void error_if_signature_is_missing()
        {
            var response = new SamlResponse
            {
                Signed = SignatureStatus.NotSigned
            };

            new SignatureIsRequired().Validate(response);

            response.Errors.Single()
                    .ShouldBe(new SamlError(SignatureStatus.NotSigned));
        }
 public void Handle(ISamlDirector director, SamlResponse response)
 {
     validate(response);
     if (response.Errors.Any())
     {
         _logger.InfoMessage(() => new SamlAuthenticationFailed(response));
         director.FailedUser(failedContinuation(response)); // just let it go to the login page
     }
     else
     {
         _logger.InfoMessage(() => new SamlAuthenticationSucceeded(response));
         var persistedUsername = createLocalUser(response);
         director.SuccessfulUser(persistedUsername, successfulContinuation(response));
     }
 }
        public void SetUp()
        {
            samlResponse = ObjectMother.Response();

            samlResponse.ShouldNotBeNull();
            samlResponse.Status.ShouldNotBeNull();

            cert = ObjectMother.Certificate2();
            samlCert = ObjectMother.SamlCertificateMatching(samlResponse.Issuer, new X509CertificateWrapper(cert));

            var store = new X509Store(StoreName.My, StoreLocation.LocalMachine);
            store.Open(OpenFlags.ReadWrite);
            store.Add(cert);

            var certificates = new InMemoryCertificateService(samlCert, cert);

            var xml = new SamlResponseWriter(certificates, new SamlResponseXmlSigner(), new AssertionXmlEncryptor()).Write(samlResponse);

            readResponse = new SamlResponseReader(certificates, new AssertionXmlDecryptor()).Read(xml);
        }
        public void SetUp()
        {
            var xml = new FileSystem().ReadStringFromFile("sample.xml");
            theReader = new SamlResponseXmlReader(xml);

            theResponse = theReader.Read();
        }
Esempio n. 11
0
 public SamlAuthenticationSucceeded(SamlResponse response)
 {
     Name   = response.Subject.Name.Value;
     Issuer = response.Issuer;
     SamlId = response.Id;
 }
        public void SetUp()
        {
            response = new SamlResponse();

            theRule = new AudienceValidationRule("foo:bar", "bar:foo");
        }
Esempio n. 13
0
        public HtmlDocument WriteRedirectionHtml(SamlResponse response)
        {
            var responseString = _writer.Write(response);

            return(new SamlResponseRedirectionDocument(responseString, response.Destination.ToString()));
        }
 public abstract bool CanHandle(SamlResponse response);
Esempio n. 15
0
 public SamlAuthenticationSucceeded(SamlResponse response)
 {
     Name = response.Subject.Name.Value;
     Issuer = response.Issuer;
     SamlId = response.Id;
 }
 protected virtual void validate(SamlResponse response)
 {
     // Nothing
 }
 protected abstract string createLocalUser(SamlResponse response);
 protected virtual FubuContinuation failedContinuation(SamlResponse response)
 {
     return(null);
 }
 protected virtual FubuContinuation successfulContinuation(SamlResponse response)
 {
     return(null);
 }
Esempio n. 20
0
        public HtmlDocument WriteRedirectionHtml(SamlResponse response)
        {
            var responseString = _writer.Write(response);

            return new SamlResponseRedirectionDocument(responseString, response.Destination.ToString());
        }
        public SamlValidationKeys Validate(SamlResponse response)
        {
            if (response.Issuer == _certificate.Issuer) return SamlValidationKeys.ValidCertificate;

            return SamlValidationKeys.CannotMatchIssuer;
        }