예제 #1
0
        public void add_a_single_key_attribute()
        {
            var response = new SamlResponse();
            response.AddAttribute("a", "1");

            response.Attributes.Get("a").ShouldBe("1");
        }
예제 #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;
 }
예제 #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();
        }
예제 #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));
        }
예제 #8
0
 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();
        }
예제 #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");
        }
예제 #13
0
        public HtmlDocument WriteRedirectionHtml(SamlResponse response)
        {
            var responseString = _writer.Write(response);

            return(new SamlResponseRedirectionDocument(responseString, response.Destination.ToString()));
        }
예제 #14
0
 public abstract bool CanHandle(SamlResponse response);
예제 #15
0
 public SamlAuthenticationSucceeded(SamlResponse response)
 {
     Name = response.Subject.Name.Value;
     Issuer = response.Issuer;
     SamlId = response.Id;
 }
예제 #16
0
 protected virtual void validate(SamlResponse response)
 {
     // Nothing
 }
예제 #17
0
 protected abstract string createLocalUser(SamlResponse response);
예제 #18
0
 protected virtual FubuContinuation failedContinuation(SamlResponse response)
 {
     return(null);
 }
예제 #19
0
 protected virtual FubuContinuation successfulContinuation(SamlResponse response)
 {
     return(null);
 }
예제 #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;
        }