Class: WSS4R::Security::Xml::KeyInfo
- Inherits:
-
Object
- Object
- WSS4R::Security::Xml::KeyInfo
- Defined in:
- lib/wss4r/security/xml/key_info.rb
Constant Summary collapse
- KEY_IDENTIFIER =
"KEY_IDENTIFIER"
- REFERENCE =
"REFERENCE"
Instance Attribute Summary collapse
-
#key_identifier ⇒ Object
Returns the value of attribute key_identifier.
-
#security_token ⇒ Object
Returns the value of attribute security_token.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #get_xml(parent) ⇒ Object
-
#initialize(p, *type) ⇒ KeyInfo
constructor
A new instance of KeyInfo.
Constructor Details
#initialize(p, *type) ⇒ KeyInfo
Returns a new instance of KeyInfo.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/wss4r/security/xml/key_info.rb', line 11 def initialize(p, *type) if (p.kind_of?(SecurityToken)) @security_token = p if (type != nil) @type = type else @type = KEY_IDENTIFIER end else reference = XPath.first(p, "wsse:SecurityTokenReference/wsse:Reference", {"wsse" => Namespaces::WSSE}) @uri = reference.attribute("URI").value()[1..-1] @value_type = reference.attribute("ValueType").value() @ref_element = XPath.first(p.document(), "//*[@wsu:Id='"+@uri+"']") @security_token = X509SecurityToken.new(@ref_element.text()) end end |
Instance Attribute Details
#key_identifier ⇒ Object
Returns the value of attribute key_identifier.
6 7 8 |
# File 'lib/wss4r/security/xml/key_info.rb', line 6 def key_identifier @key_identifier end |
#security_token ⇒ Object
Returns the value of attribute security_token.
6 7 8 |
# File 'lib/wss4r/security/xml/key_info.rb', line 6 def security_token @security_token end |
#type ⇒ Object
Returns the value of attribute type.
6 7 8 |
# File 'lib/wss4r/security/xml/key_info.rb', line 6 def type @type end |
Instance Method Details
#get_xml(parent) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/wss4r/security/xml/key_info.rb', line 28 def get_xml(parent) key_info = parent.add_element(Names::KEY_INFO) security_token_ref = key_info.add_element(Names::SECURITY_TOKEN_REFERENCE) security_token_ref.add_namespace("xmlns:wsu", Namespaces::WSU) wsu_id = REXML::Attribute.new("wsu:Id",security_token_ref.object_id().to_s()) security_token_ref.add_attribute(wsu_id) if (@type == "KEY_IDENTIFIER") key_identifier = security_token_ref.add_element(Names::KEY_IDENTIFIER) key_identifier.add_attribute("ValueType", Types::VALUE_KEYIDENTIFIER) key_identifier.add_attribute("EncodingType", Types::ENCODING_X509V3) key_identifier.text=(@security_token.key_identifier()) else reference = security_token_ref.add_element(Names::REFERENCE_WSSE) reference.add_attribute("ValueType", Types::REFERENCE_VALUETYPE_X509) reference.add_attribute("URI", "#"+@security_token.get_id()) end parent end |