fn attrib_parser(&mut self, tag: &str, attributes: Vec<OwnedAttribute>, upstream_tag: &str) {
        eprintln!("attrib_parser - tag={}, attr:{:?}", tag, attributes);
        eprintln!("Current upstream tag: {}", upstream_tag);

        match tag {
            "AssertionConsumerService" => {
                log::debug!("AssertionConsumerService: {:?}", attributes);
                match self
                    .service_attrib_parser(SamlBindingType::AssertionConsumerService, attributes)
                {
                    Ok(value) => {
                        let mut a = vec![value];
                        self.services.append(&mut a);
                    }
                    Err(error) => {
                        eprintln!("Failed to parse AssertionConsumerService: {:?}", error)
                    }
                }
            }
            "EntityDescriptor" => {
                for attribute in attributes {
                    log::debug!("attribute: {}", attribute);
                    match attribute.name.local_name.as_str() {
                        "entityID" => {
                            log::debug!("Setting entityID: {}", attribute.value);
                            self.entity_id = attribute.value;
                        }
                        "ID" => {
                            log::debug!("Setting entityID: {}", attribute.value);
                            self.entity_id = attribute.value;
                        }
                        // TODO validUntil example value "2100-01-01T00:00:42Z"
                        _ => {
                            eprintln!(
                                "found an EntityDescriptor attribute that's not entityID: {:?}",
                                attribute
                            );
                        }
                    }
                }
            }
            "SingleLogoutService" => {
                log::debug!("SingleLogoutService: {:?}", attributes);
                match self.service_attrib_parser(SamlBindingType::SingleLogoutService, attributes) {
                    Ok(value) => {
                        let mut a = vec![value];
                        self.services.append(&mut a);
                    }
                    Err(error) => eprintln!("Failed to parse SingleLogoutService: {:?}", error),
                }
            }

            "SPSSODescriptor" => {
                log::debug!("Dumping SPSSODescriptor: {:?}", attributes);
                for attribute in attributes {
                    match attribute.name.local_name.to_lowercase().as_str() {
                        "authnrequestssigned" => {
                            // AuthnRequestsSigned
                            match attribute.value.to_lowercase().as_str() {
                                "true" => self.authn_requests_signed = true,
                                "false" => self.authn_requests_signed = false,
                                _ => eprintln!(
                                    "Couldn't parse value of AuthnRequestsSigned: {}",
                                    attribute.value.to_lowercase()
                                ),
                            }
                        }
                        "wantassertionssigned" => {
                            // WantAssertionsSigned
                            match attribute.value.to_lowercase().as_str() {
                                "true" => self.want_assertions_signed = true,
                                "false" => self.want_assertions_signed = false,
                                _ => eprintln!(
                                    "Couldn't parse value of WantAssertionsSigned: {}",
                                    attribute.value.to_lowercase()
                                ),
                            }
                        }
                        "protocolsupportenumeration" => {
                            self.protocol_support_enumeration = Some(attribute.value.to_string())
                        }
                        _ => eprintln!("SPSSODescriptor attribute not handled {:?}", attribute), // protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol"
                                                                                                 // WantAssertionsSigned="true"
                    }
                }
            }
            // TODO: RequestInitiator
            "RequestInitiator" => log::warn!("RequestInitiator is yet to be implemented, skipping"),
            // TODO: SPSSODescriptor?
            // "SPSSODescriptor" => log::warn!("SPSSODescriptor is yet to be implemented, skipping"),
            // TODO: SigningMethod - should be relevant to how we respond
            "SigningMethod" => log::warn!("SigningMethod is yet to be implemented, skipping"),
            // TODO: DigestMethod - should be relevant to how we respond
            "DigestMethod" => log::warn!("DigestMethod is yet to be implemented, skipping"),

            "NameIDFormat" => log::debug!("Don't need to parse attributes for NameIDFormat"),
            "KeyDescriptor" => log::debug!("Don't need to parse attributes for KeyDescriptor"),
            "KeyInfo" => log::debug!("Don't need to parse attributes for KeyInfo"),
            "X509Certificate" => log::debug!("Don't need to parse attributes for X509Certificate"),
            "X509Data" => log::debug!("Don't need to parse attributes for X509Data"),
            "Logo" => log::debug!("Don't need to parse attributes for Logo"),
            "Description" => log::debug!("Don't need to parse attributes for Description"),
            _ => eprintln!(
                "!!! Asked to parse attributes for tag={}, not caught by anything {:?}",
                tag, attributes
            ),
        }
    }
/// Let's parse some attributes!
Let's parse some attributes!
Let ' s parse some attributes!
fn attrib_parser(&mut self, tag: &str, attributes: Vec<OwnedAttribute>, upstream_tag: &str) {
        eprintln!("attrib_parser - tag={}, attr:{:?}", tag, attributes);
        eprintln!("Current upstream tag: {}", upstream_tag);
        match tag {
            "AssertionConsumerService" => {
                log::debug!("AssertionConsumerService: {:?}", attributes);
                match self
                    .service_attrib_parser(SamlBindingType::AssertionConsumerService, attributes)
                {
                    Ok(value) => {
                        let mut a = vec![value];
                        self.services.append(&mut a);
                    }
                    Err(error) => {
                        eprintln!("Failed to parse AssertionConsumerService: {:?}", error)
                    }
                }
            }
            "EntityDescriptor" => {
                for attribute in attributes {
                    log::debug!("attribute: {}", attribute);
                    match attribute.name.local_name.as_str() {
                        "entityID" => {
                            log::debug!("Setting entityID: {}", attribute.value);
                            self.entity_id = attribute.value;
                        }
                        "ID" => {
                            log::debug!("Setting entityID: {}", attribute.value);
                            self.entity_id = attribute.value;
                        }
                        // TODO validUntil example value "2100-01-01T00:00:42Z"
                        _ => {
                            eprintln!(
                                "found an EntityDescriptor attribute that's not entityID: {:?}",
                                attribute
                            );
                        }
                    }
                }
            }
            "SingleLogoutService" => {
                log::debug!("SingleLogoutService: {:?}", attributes);
                match self.service_attrib_parser(SamlBindingType::SingleLogoutService, attributes) {
                    Ok(value) => {
                        let mut a = vec![value];
                        self.services.append(&mut a);
                    }
                    Err(error) => eprintln!("Failed to parse SingleLogoutService: {:?}", error),
                }
            }
            "SPSSODescriptor" => {
                log::debug!("Dumping SPSSODescriptor: {:?}", attributes);
                for attribute in attributes {
                    match attribute.name.local_name.to_lowercase().as_str() {
                        "authnrequestssigned" => {
                            // AuthnRequestsSigned
                            match attribute.value.to_lowercase().as_str() {
                                "true" => self.authn_requests_signed = true,
                                "false" => self.authn_requests_signed = false,
                                _ => eprintln!(
                                    "Couldn't parse value of AuthnRequestsSigned: {}",
                                    attribute.value.to_lowercase()
                                ),
                            }
                        }
                        "wantassertionssigned" => {
                            // WantAssertionsSigned
                            match attribute.value.to_lowercase().as_str() {
                                "true" => self.want_assertions_signed = true,
                                "false" => self.want_assertions_signed = false,
                                _ => eprintln!(
                                    "Couldn't parse value of WantAssertionsSigned: {}",
                                    attribute.value.to_lowercase()
                                ),
                            }
                        }
                        "protocolsupportenumeration" => {
                            self.protocol_support_enumeration = Some(attribute.value.to_string())
                        }
                        _ => eprintln!("SPSSODescriptor attribute not handled {:?}", attribute), // protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol"
                                                                                                 // WantAssertionsSigned="true"
                    }
                }
            }
            // TODO: RequestInitiator
            "RequestInitiator" => log::warn!("RequestInitiator is yet to be implemented, skipping"),
            // TODO: SPSSODescriptor?
            // "SPSSODescriptor" => log::warn!("SPSSODescriptor is yet to be implemented, skipping"),
            // TODO: SigningMethod - should be relevant to how we respond
            "SigningMethod" => log::warn!("SigningMethod is yet to be implemented, skipping"),
            // TODO: DigestMethod - should be relevant to how we respond
            "DigestMethod" => log::warn!("DigestMethod is yet to be implemented, skipping"),
            "NameIDFormat" => log::debug!("Don't need to parse attributes for NameIDFormat"),
            "KeyDescriptor" => log::debug!("Don't need to parse attributes for KeyDescriptor"),
            "KeyInfo" => log::debug!("Don't need to parse attributes for KeyInfo"),
            "X509Certificate" => log::debug!("Don't need to parse attributes for X509Certificate"),
            "X509Data" => log::debug!("Don't need to parse attributes for X509Data"),
            "Logo" => log::debug!("Don't need to parse attributes for Logo"),
            "Description" => log::debug!("Don't need to parse attributes for Description"),
            _ => eprintln!(
                "!!! Asked to parse attributes for tag={}, not caught by anything {:?}",
                tag, attributes
            ),
        }
    }
fn attrib_parser ( & mut self , tag : & str , attributes : Vec < OwnedAttribute > , upstream_tag : & str ) { eprintln ! ( " " tag attributes ) ; eprintln ! ( " " upstream_tag ) ; match tag { " " => { log :: debug ! ( " " attributes ) ; match self . service_attrib_parser ( SamlBindingType :: AssertionConsumerService , attributes ) { Ok ( value ) => { let mut a = vec ! [ value ] ; self . services . append ( & mut a ) ; } Err ( error ) => { eprintln ! ( " " error ) } } } " " => { for attribute in attributes { log :: debug ! ( " " attribute ) ; match attribute . name . local_name . as_str ( ) { " " => { log :: debug ! ( " " attribute value ) ; self . entity_id = attribute . value ; } " " => { log :: debug ! ( " " attribute value ) ; self . entity_id = attribute . value ; } // TODO validUntil example value "2100-01-01T00:00:42Z" _ => { eprintln ! ( " " attribute ) ; } } } } " " => { log :: debug ! ( " " attributes ) ; match self . service_attrib_parser ( SamlBindingType :: SingleLogoutService , attributes ) { Ok ( value ) => { let mut a = vec ! [ value ] ; self . services . append ( & mut a ) ; } Err ( error ) => eprintln ! ( " " error ) , } } " " => { log :: debug ! ( " " attributes ) ; for attribute in attributes { match attribute . name . local_name . to_lowercase ( ) . as_str ( ) { " " => { // AuthnRequestsSigned match attribute . value . to_lowercase ( ) . as_str ( ) { " " => self . authn_requests_signed = true , " " => self . authn_requests_signed = false , _ => eprintln ! ( " " attribute value to_lowercase ( ) ) , } } " " => { // WantAssertionsSigned match attribute . value . to_lowercase ( ) . as_str ( ) { " " => self . want_assertions_signed = true , " " => self . want_assertions_signed = false , _ => eprintln ! ( " " attribute value to_lowercase ( ) ) , } } " " => { self . protocol_support_enumeration = Some ( attribute . value . to_string ( ) ) } _ => eprintln ! ( " " attribute ) , // protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol" // WantAssertionsSigned="true" } } } // TODO: RequestInitiator " " => log :: warn ! ( " " ) , // TODO: SPSSODescriptor? // "SPSSODescriptor" => log::warn!("SPSSODescriptor is yet to be implemented, skipping"), // TODO: SigningMethod - should be relevant to how we respond " " => log :: warn ! ( " " ) , // TODO: DigestMethod - should be relevant to how we respond " " => log :: warn ! ( " " ) , " " => log :: debug ! ( " " ) , " " => log :: debug ! ( " " ) , " " => log :: debug ! ( " " ) , " " => log :: debug ! ( " " ) , " " => log :: debug ! ( " " ) , " " => log :: debug ! ( " " ) , " " => log :: debug ! ( " " ) , _ => eprintln ! ( " " tag attributes ) , } }
Let's parse some attributes!
Let ' s parse some attributes!
&mut self
tag
&str
attributes
Vec<OwnedAttribute>
upstream_tag
&str
&mut self
tag
&str
attributes
Vec<OwnedAttribute>
upstream_tag
&str