wss4r 0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. data/README +300 -0
  2. data/lib/wss4r/aws/utils.rb +37 -0
  3. data/lib/wss4r/config/config.rb +105 -0
  4. data/lib/wss4r/rpc/proxy.rb +26 -0
  5. data/lib/wss4r/rpc/router.rb +46 -0
  6. data/lib/wss4r/rpc/wssdriver.rb +19 -0
  7. data/lib/wss4r/security/crypto/certificate.rb +21 -0
  8. data/lib/wss4r/security/crypto/cipher.rb +161 -0
  9. data/lib/wss4r/security/crypto/hash.rb +35 -0
  10. data/lib/wss4r/security/exceptions/exceptions.rb +62 -0
  11. data/lib/wss4r/security/resolver.rb +23 -0
  12. data/lib/wss4r/security/security.rb +148 -0
  13. data/lib/wss4r/security/util/hash_util.rb +39 -0
  14. data/lib/wss4r/security/util/names.rb +38 -0
  15. data/lib/wss4r/security/util/namespaces.rb +21 -0
  16. data/lib/wss4r/security/util/reference_elements.rb +15 -0
  17. data/lib/wss4r/security/util/soap_parser.rb +73 -0
  18. data/lib/wss4r/security/util/transformer_factory.rb +29 -0
  19. data/lib/wss4r/security/util/types.rb +25 -0
  20. data/lib/wss4r/security/util/xmlcanonicalizer.rb +427 -0
  21. data/lib/wss4r/security/util/xmlutils.rb +58 -0
  22. data/lib/wss4r/security/xml/encrypted_data.rb +110 -0
  23. data/lib/wss4r/security/xml/encrypted_key.rb +74 -0
  24. data/lib/wss4r/security/xml/key_info.rb +52 -0
  25. data/lib/wss4r/security/xml/reference.rb +53 -0
  26. data/lib/wss4r/security/xml/reference_list.rb +24 -0
  27. data/lib/wss4r/security/xml/security.rb +92 -0
  28. data/lib/wss4r/security/xml/signature.rb +69 -0
  29. data/lib/wss4r/security/xml/signature_value.rb +26 -0
  30. data/lib/wss4r/security/xml/signed_info.rb +83 -0
  31. data/lib/wss4r/security/xml/timestamp.rb +47 -0
  32. data/lib/wss4r/security/xml/tokentypes.rb +180 -0
  33. data/lib/wss4r/server/wssstandaloneserver.rb +27 -0
  34. data/lib/wss4r/soap/processor.rb +92 -0
  35. data/lib/wss4r/tokenresolver/authenticateuserresolver.rb +34 -0
  36. data/lib/wss4r/tokenresolver/certificateresolver.rb +62 -0
  37. data/lib/wss4r/tokenresolver/databaseresolver.rb +56 -0
  38. data/lib/wss4r/tokenresolver/resolver.rb +13 -0
  39. metadata +95 -0
@@ -0,0 +1,34 @@
1
+ module WSS4R
2
+
3
+ module Tokenresolver
4
+ class AuthenticateUserResolver < Resolver
5
+
6
+ def authenticate_user(usernametoken)
7
+ puts (usernametoken)
8
+ if usernametoken.type() == UsernameToken::HASHED
9
+ stamp = Base64.decode64(usernametoken.nonce())+usernametoken.created()
10
+ stamp = stamp + authenticate_token(usernametoken)
11
+ hash = CryptHash.new().digest_b64(stamp)
12
+ return hash.to_s() == usernametoken.hash().to_s()
13
+ else
14
+ return authenticate_token_plain(usernametoken.username(), usernametoken.password())
15
+ end
16
+ false
17
+ end
18
+ end
19
+
20
+ def authenticate_token(usernametoken)
21
+ usernametoken.username().reverse()
22
+ end
23
+
24
+ def authenticate_token_plain(username, password)
25
+ @username = username
26
+ @password = password
27
+ return (username.reverse() == password)
28
+ end
29
+
30
+ end #Tokenresolver
31
+ end #WSS4R
32
+
33
+
34
+
@@ -0,0 +1,62 @@
1
+ require "wss4r/tokenresolver/resolver.rb"
2
+ require "wss4r/security/crypto/certificate"
3
+
4
+ module WSS4R
5
+ module Tokenresolver
6
+ class CertificateDirectoryResolver < Resolver
7
+
8
+ def initialize(directory)
9
+ File.stat(directory).directory?
10
+ @directory = directory
11
+ end
12
+
13
+ def certificate_by_key_identifier(key_identifier)
14
+ files = Dir[@directory + "/*.cer"]
15
+ files.each{|f|
16
+ certificate = Certificate.new(File.read(f))
17
+ if (key_identifier == certificate.key_identifier())
18
+ certificate.filename=(f)
19
+ return certificate
20
+ end
21
+ }
22
+ nil
23
+ end
24
+
25
+ def private_key(certificate, passphrase=nil)
26
+ if (certificate.filename() != nil)
27
+ if passphrase
28
+ return (RSA.new(File.read(certificate.filename()), passphrase))
29
+ else
30
+ return (RSA.new(File.read(certificate.filename() + ".key")))
31
+ end
32
+ end
33
+ files = Dir[@directory + "/*.key"]
34
+ files.each{|f|
35
+ pkey = RSA.new(File.read(f))
36
+ if (certificate.check_private_key(pkey))
37
+ return pkey
38
+ end
39
+ }
40
+ return nil
41
+ end
42
+
43
+ def certificate_by_subject(subject)
44
+ files = Dir[@directory + "/*.cer"]
45
+ files.each{|f|
46
+ certificate = Certificate.new(File.read(f))
47
+ if (certificate.subject().to_s() == subject)
48
+ certificate.filename=(f)
49
+ return certificate
50
+ end
51
+ }
52
+ nil
53
+ end
54
+ end
55
+ end
56
+ end
57
+
58
+
59
+ #c = WSS4R::Tokenresolver::CertificateDirectoryResolver.new("./certs")
60
+ #cert = c.get_certificate_by_key_identifier("tUYo1KhZtRDiUf1LVNDUopTczmo=")
61
+ #key = c.get_private_key(cert)
62
+ #puts(key.to_s())
@@ -0,0 +1,56 @@
1
+ require "sqlite3"
2
+ require "openssl"
3
+
4
+ require "base64"
5
+
6
+ require "wss4r/tokenresolver/resolver.rb"
7
+ require "wss4r/security/crypto/certificate"
8
+
9
+ include OpenSSL::PKey
10
+ include OpenSSL::X509
11
+
12
+ module WSS4R
13
+ module Tokenresolver
14
+ class DatabaseResolver < Resolver
15
+ def initialize(database_file)
16
+ @db = SQLite3::Database.new(database_file)
17
+ end
18
+
19
+ def private_key(certificate)
20
+ cert_data = Base64.encode64(certificate.to_der())
21
+ select = "select * from certificates where cert_data = '#{cert_data}'"
22
+ rows = @db.execute(select)
23
+ return nil if (rows == nil || rows.size() == 0)
24
+ private_key_data = rows[0][3]
25
+ private_key_data = Base64.decode64(private_key_data)
26
+ private_key = RSA.new(private_key_data)
27
+ return private_key if private_key
28
+ return nil
29
+ end
30
+
31
+ def certificate_by_subject(subject)
32
+ select = "select * from certificates where subject = '#{subject}'"
33
+ rows = @db.execute(select)
34
+ return nil if (rows == nil || rows.size() == 0)
35
+ cert_data = rows[0][2]
36
+ cert_data = Base64.decode64(cert_data)
37
+ cert = Certificate.new(cert_data)
38
+ return cert if cert
39
+ return nil
40
+ end
41
+ end
42
+ end
43
+ end
44
+
45
+ if __FILE__ == $0
46
+ resolver = WSS4R::Tokenresolver::DatabaseResolver.new(ARGV[0])
47
+ cert = resolver.certificate_by_subject("/C=DE/ST=Rheinland-Pfalz/L=Trier/O=FF/OU=Developement/CN=Client/emailAddress=client@web.de")
48
+ key = resolver.private_key(cert)
49
+ puts("Certificate:----" + cert.to_s())
50
+ puts("Private key:----" + key.to_s())
51
+ end
52
+
53
+
54
+ #cert = c.get_certificate_by_key_identifier("tUYo1KhZtRDiUf1LVNDUopTczmo=")
55
+ #key = c.get_private_key(cert)
56
+ #puts(key.to_s())
@@ -0,0 +1,13 @@
1
+ module WSS4R
2
+ module Tokenresolver
3
+ class Resolver
4
+ def certificate_by_subject(subject)
5
+ end
6
+ def private_key(certificate)
7
+ end
8
+ def authenticate_user(usernametoken)
9
+ return false
10
+ end
11
+ end
12
+ end
13
+ end
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.4
3
+ specification_version: 1
4
+ name: wss4r
5
+ version: !ruby/object:Gem::Version
6
+ version: "0.5"
7
+ date: 2007-10-16 00:00:00 +02:00
8
+ summary: Some description
9
+ require_paths:
10
+ - lib
11
+ email: roland.schmitt@web.de
12
+ homepage: http://rubyforge.org/projects/wss4r
13
+ rubyforge_project:
14
+ description:
15
+ autorequire: wss4r
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: false
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Roland Schmitt
31
+ files:
32
+ - lib/wss4r
33
+ - lib/wss4r/config
34
+ - lib/wss4r/config/config.rb
35
+ - lib/wss4r/soap
36
+ - lib/wss4r/soap/processor.rb
37
+ - lib/wss4r/rpc
38
+ - lib/wss4r/rpc/router.rb
39
+ - lib/wss4r/rpc/proxy.rb
40
+ - lib/wss4r/rpc/wssdriver.rb
41
+ - lib/wss4r/tokenresolver
42
+ - lib/wss4r/tokenresolver/authenticateuserresolver.rb
43
+ - lib/wss4r/tokenresolver/certificateresolver.rb
44
+ - lib/wss4r/tokenresolver/databaseresolver.rb
45
+ - lib/wss4r/tokenresolver/resolver.rb
46
+ - lib/wss4r/server
47
+ - lib/wss4r/server/wssstandaloneserver.rb
48
+ - lib/wss4r/security
49
+ - lib/wss4r/security/xml
50
+ - lib/wss4r/security/xml/encrypted_data.rb
51
+ - lib/wss4r/security/xml/signature.rb
52
+ - lib/wss4r/security/xml/tokentypes.rb
53
+ - lib/wss4r/security/xml/key_info.rb
54
+ - lib/wss4r/security/xml/reference_list.rb
55
+ - lib/wss4r/security/xml/reference.rb
56
+ - lib/wss4r/security/xml/timestamp.rb
57
+ - lib/wss4r/security/xml/security.rb
58
+ - lib/wss4r/security/xml/encrypted_key.rb
59
+ - lib/wss4r/security/xml/signature_value.rb
60
+ - lib/wss4r/security/xml/signed_info.rb
61
+ - lib/wss4r/security/crypto
62
+ - lib/wss4r/security/crypto/cipher.rb
63
+ - lib/wss4r/security/crypto/certificate.rb
64
+ - lib/wss4r/security/crypto/hash.rb
65
+ - lib/wss4r/security/exceptions
66
+ - lib/wss4r/security/exceptions/exceptions.rb
67
+ - lib/wss4r/security/util
68
+ - lib/wss4r/security/util/names.rb
69
+ - lib/wss4r/security/util/namespaces.rb
70
+ - lib/wss4r/security/util/soap_parser.rb
71
+ - lib/wss4r/security/util/xmlutils.rb
72
+ - lib/wss4r/security/util/hash_util.rb
73
+ - lib/wss4r/security/util/transformer_factory.rb
74
+ - lib/wss4r/security/util/xmlcanonicalizer.rb
75
+ - lib/wss4r/security/util/types.rb
76
+ - lib/wss4r/security/util/reference_elements.rb
77
+ - lib/wss4r/security/security.rb
78
+ - lib/wss4r/security/resolver.rb
79
+ - lib/wss4r/aws
80
+ - lib/wss4r/aws/utils.rb
81
+ - README
82
+ test_files: []
83
+
84
+ rdoc_options: []
85
+
86
+ extra_rdoc_files:
87
+ - README
88
+ executables: []
89
+
90
+ extensions: []
91
+
92
+ requirements: []
93
+
94
+ dependencies: []
95
+