Class: WSS4R::Security::Security
- Inherits:
-
Object
- Object
- WSS4R::Security::Security
- Defined in:
- lib/wss4r/security/security.rb
Constant Summary collapse
- @@resolver =
Resolver.new()
Instance Attribute Summary collapse
-
#tokens ⇒ Object
readonly
Returns the value of attribute tokens.
Instance Method Summary collapse
- #add_security_resolver(resolver) ⇒ Object
- #add_security_token(token) ⇒ Object
- #clear_resolver! ⇒ Object
- #clear_tokens! ⇒ Object
-
#initialize ⇒ Security
constructor
A new instance of Security.
- #process_document_marshal(document) ⇒ Object
- #process_document_unmarshal(document) ⇒ Object
- #resolver ⇒ Object
Constructor Details
#initialize ⇒ Security
Returns a new instance of Security.
57 58 59 |
# File 'lib/wss4r/security/security.rb', line 57 def initialize() @tokens = Array.new() end |
Instance Attribute Details
#tokens ⇒ Object (readonly)
Returns the value of attribute tokens.
53 54 55 |
# File 'lib/wss4r/security/security.rb', line 53 def tokens @tokens end |
Instance Method Details
#add_security_resolver(resolver) ⇒ Object
65 66 67 |
# File 'lib/wss4r/security/security.rb', line 65 def add_security_resolver(resolver) @@resolver.push(resolver) end |
#add_security_token(token) ⇒ Object
61 62 63 |
# File 'lib/wss4r/security/security.rb', line 61 def add_security_token(token) @tokens.push(token) end |
#clear_resolver! ⇒ Object
69 70 71 |
# File 'lib/wss4r/security/security.rb', line 69 def clear_resolver!() @@resolver.clear() end |
#clear_tokens! ⇒ Object
73 74 75 |
# File 'lib/wss4r/security/security.rb', line 73 def clear_tokens!() @tokens.clear() end |
#process_document_marshal(document) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/wss4r/security/security.rb', line 81 def process_document_marshal(document) return if (@tokens.size() == 0) SOAPParser.document=(document) document.root.add_namespace("xmlns:wsu", Namespaces::WSU) document.root.add_namespace("xmlns:wsse", Namespaces::WSSE) document.root.add_namespace("xmlns:wsa", Namespaces::WSA) document.root.add_namespace("xmlns:xenc", Namespaces::XENCD) document.root.add_namespace("xmlns:xsd", Namespaces::XSD) document.root.add_namespace("xmlns:xsi", Namespaces::XSI) root = document.root() soap_prefix = nil soap_ns=nil root.attributes.each_attribute() {|attr| if (attr.value() == Namespaces::S11) soap_prefix = attr.name() soap_ns = Namespaces::S11 end if (attr.value() == Namespaces::S12) soap_prefix = attr.name() soap_ns = Namespaces::S12 end } SOAPParser::soap_ns=(soap_ns) SOAPParser::soap_prefix=(soap_prefix) soap_body = XPath.first(document, "/env:Envelope/env:Body", {SOAPParser::soap_prefix => SOAPParser::soap_ns}) #soap_body = XPath.first(document, soap_prefix+":Envelope/"+soap_prefix+":Body") #soap_body = SOAPParser.part(SOAPParser::BODY) return if !soap_body root.delete_element(soap_body) soap_header = SOAPParser.part(SOAPParser::HEADER) if (soap_header == nil) soap_header = root.add_element(Names::HEADER) end root.add_element(soap_body) security = WSS4R::Security::Xml::Security.new() security.process(document) @tokens.each{|token| token.process(document) } ####Sort security = XPath.first(root, "/env:Envelope/env:Header/wsse:Security")#, {SOAPParser::soap_prefix=>SOAPParser::soap_ns}) = XPath.first(security, "wsu:Timestamp") @t = @s = security children = security.children() children.each{|child| security.delete(child) } children.delete() security.add_element() children.each{|child| security.add_element(child) } end |
#process_document_unmarshal(document) ⇒ Object
141 142 143 144 |
# File 'lib/wss4r/security/security.rb', line 141 def process_document_unmarshal(document) security = WSS4R::Security::Xml::Security.new() security.unprocess(document) end |
#resolver ⇒ Object
77 78 79 |
# File 'lib/wss4r/security/security.rb', line 77 def resolver() @@resolver end |