openas2 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/lib/openas2.rb +6 -0
- data/lib/openas2/configuration.rb +45 -0
- data/lib/openas2/remote.rb +7 -0
- data/lib/openas2/remote/command.rb +17 -0
- data/lib/openas2/remote/connection.rb +41 -0
- data/lib/openas2/version.rb +3 -0
- data/openas2.gemspec +25 -0
- metadata +106 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Scott Tesoriere
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# OpenAS2 Remote
|
2
|
+
|
3
|
+
Connect to OpenAS2 via ruby
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'openas2-remote'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install openas2-remote
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/openas2.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
module Openas2
|
2
|
+
class Configuration
|
3
|
+
attr_accessor :command, :username, :password, :host, :port, :connection
|
4
|
+
|
5
|
+
def initialize(username, password, host, port)
|
6
|
+
@command = Openas2::Remote::Command.new(username, password)
|
7
|
+
@host = host
|
8
|
+
@port = port
|
9
|
+
end
|
10
|
+
|
11
|
+
def send(cmd)
|
12
|
+
@connection = Openas2::Remote::Connection.new(@host, @port)
|
13
|
+
@connection.connect
|
14
|
+
cmd = @command.build cmd
|
15
|
+
puts cmd
|
16
|
+
@connection.puts(cmd)
|
17
|
+
# also parse attributes into hash
|
18
|
+
# Hash[*s.gsub(/{|}|\s/, '').split(",").map{|a|a.split('=')}.flatten]
|
19
|
+
"<results>#{@connection.readlines.join}</results>"
|
20
|
+
end
|
21
|
+
|
22
|
+
def partner(name)
|
23
|
+
partner = send("partner view #{name}")
|
24
|
+
xml=Nokogiri::XML(partner)
|
25
|
+
xml.xpath('//result').map &:text
|
26
|
+
end
|
27
|
+
|
28
|
+
def partners
|
29
|
+
list = send("partner list")
|
30
|
+
xml=Nokogiri::XML(list)
|
31
|
+
xml.xpath('//result').map &:text
|
32
|
+
end
|
33
|
+
|
34
|
+
def add_partner(as2_id, email, name, x509_alias)
|
35
|
+
params = "as2_id=#{as2_id} email=#{email} name=#{name} x509_alias=#{x509_alias}"
|
36
|
+
send("partner add #{params}")
|
37
|
+
end
|
38
|
+
|
39
|
+
def remove_partner(name)
|
40
|
+
params = "partner delete #{name}"
|
41
|
+
send("partner delete #{params}")
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Openas2
|
2
|
+
module Remote
|
3
|
+
class Command
|
4
|
+
attr_accessor :username, :password
|
5
|
+
|
6
|
+
def initialize(username, password)
|
7
|
+
@username = username
|
8
|
+
@password = password
|
9
|
+
end
|
10
|
+
|
11
|
+
def build(cmd)
|
12
|
+
%(<command id="#{@username}" password="#{@password}">#{cmd}</command>\n)
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'socket'
|
2
|
+
require 'openssl'
|
3
|
+
|
4
|
+
module Openas2
|
5
|
+
module Remote
|
6
|
+
class Connection
|
7
|
+
|
8
|
+
attr_accessor :socket, :ssl_context, :ssl_socket
|
9
|
+
|
10
|
+
def initialize(host='localhost', port=4321, ciphers=[])
|
11
|
+
ciphers << ["ADH-RC4-MD5", "TLSv1/SSLv3", 128, 128]
|
12
|
+
@socket = TCPSocket.new(host, port)
|
13
|
+
@ssl_context = OpenSSL::SSL::SSLContext.new
|
14
|
+
@ssl_context.ciphers = ciphers
|
15
|
+
end
|
16
|
+
|
17
|
+
def connect
|
18
|
+
@ssl_socket = OpenSSL::SSL::SSLSocket.new(@socket, @ssl_context)
|
19
|
+
@ssl_socket.sync_close = true
|
20
|
+
@ssl_socket.connect
|
21
|
+
end
|
22
|
+
|
23
|
+
def readlines
|
24
|
+
@ssl_socket.readlines
|
25
|
+
end
|
26
|
+
|
27
|
+
def puts(s)
|
28
|
+
@ssl_socket.puts(s)
|
29
|
+
end
|
30
|
+
|
31
|
+
def gets
|
32
|
+
@ssl_socket.gets
|
33
|
+
end
|
34
|
+
|
35
|
+
def close
|
36
|
+
@ssl_socket.close
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/openas2.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'openas2/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "openas2"
|
8
|
+
spec.version = Openas2::VERSION
|
9
|
+
spec.authors = ["Scott Tesoriere"]
|
10
|
+
spec.email = ["scott@tesoriere.com"]
|
11
|
+
spec.summary = %q{Modify openas2 configuration}
|
12
|
+
spec.description = %q{OpenAS2 provides a SSL module to remotely manage it}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency(%q<nokogiri>)
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: openas2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Scott Tesoriere
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-05-09 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: nokogiri
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: bundler
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '1.3'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '1.3'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rake
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
description: OpenAS2 provides a SSL module to remotely manage it
|
63
|
+
email:
|
64
|
+
- scott@tesoriere.com
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- .gitignore
|
70
|
+
- Gemfile
|
71
|
+
- LICENSE.txt
|
72
|
+
- README.md
|
73
|
+
- Rakefile
|
74
|
+
- lib/openas2.rb
|
75
|
+
- lib/openas2/configuration.rb
|
76
|
+
- lib/openas2/remote.rb
|
77
|
+
- lib/openas2/remote/command.rb
|
78
|
+
- lib/openas2/remote/connection.rb
|
79
|
+
- lib/openas2/version.rb
|
80
|
+
- openas2.gemspec
|
81
|
+
homepage: ''
|
82
|
+
licenses:
|
83
|
+
- MIT
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options: []
|
86
|
+
require_paths:
|
87
|
+
- lib
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
|
+
none: false
|
96
|
+
requirements:
|
97
|
+
- - ! '>='
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
requirements: []
|
101
|
+
rubyforge_project:
|
102
|
+
rubygems_version: 1.8.25
|
103
|
+
signing_key:
|
104
|
+
specification_version: 3
|
105
|
+
summary: Modify openas2 configuration
|
106
|
+
test_files: []
|