Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Namespaces and Uri's can now be configured #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions lib/akami/wsse.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ module Akami
#
# Building Web Service Security.
class WSSE

#Configurable Attributes
[:wse_namespace, :wsu_namespace, :password_text_uri, :password_digest_uri].each do |attribute|
attr_accessor attribute
attr_writer attribute
end

# Namespace for WS Security Secext.
WSE_NAMESPACE = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
Expand All @@ -22,6 +28,13 @@ class WSSE
# PasswordDigest URI.
PASSWORD_DIGEST_URI = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest"

def initialize
@wse_namespace = WSE_NAMESPACE
@wsu_namespace = WSU_NAMESPACE
@password_text_uri = PASSWORD_TEXT_URI
@password_digest_uri = PASSWORD_DIGEST_URI
end

# Returns a value from the WSSE Hash.
def [](key)
hash[key]
Expand Down Expand Up @@ -113,9 +126,9 @@ def security_hash(namespace, tag, hash)
{
"wsse:Security" => {
"#{namespace}:#{tag}" => hash,
:attributes! => { "#{namespace}:#{tag}" => { "wsu:Id" => "#{tag}-#{count}", "xmlns:wsu" => WSU_NAMESPACE } }
:attributes! => { "#{namespace}:#{tag}" => { "wsu:Id" => "#{tag}-#{count}", "xmlns:wsu" => @wsu_namespace } }
},
:attributes! => { "wsse:Security" => { "xmlns:wsse" => WSE_NAMESPACE } }
:attributes! => { "wsse:Security" => { "xmlns:wsse" => @wse_namespace } }
}
end

Expand Down
44 changes: 44 additions & 0 deletions spec/akami/wsse_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,50 @@
wsse.should be_digest
end
end

describe "#wse_namespace" do
it "returns the default wse namespace" do
wsse.wse_namespace.should == Akami::WSSE::WSE_NAMESPACE
end

it "sets the wse_namespace" do
wsse.wse_namespace = "test"
wsse.wse_namespace.should == "test"
end
end

describe "#wsu_namespace" do
it "returns the default wsu namespace" do
wsse.wsu_namespace.should == Akami::WSSE::WSU_NAMESPACE
end

it "sets the wsu_namespace" do
wsse.wsu_namespace = "test"
wsse.wsu_namespace.should == "test"
end
end

describe "#password_text_uri" do
it "returns the default password text uri" do
wsse.password_text_uri.should == Akami::WSSE::PASSWORD_TEXT_URI
end

it "sets the password_text_uri" do
wsse.password_text_uri = "test"
wsse.password_text_uri.should == "test"
end
end

describe "#password_digest_uri" do
it "returns the default password digest uri" do
wsse.password_digest_uri.should == Akami::WSSE::PASSWORD_DIGEST_URI
end

it "sets the password_digest_uri" do
wsse.password_digest_uri = "test"
wsse.password_digest_uri.should == "test"
end
end

describe "#to_xml" do
context "with no credentials" do
Expand Down