summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-08-07 17:39:13 -0700
committerLuke Kanies <luke@madstop.com>2008-08-07 17:39:13 -0700
commit113d74aaa630f499c8b7989aac6680e22e8e38c8 (patch)
tree250783a4ef765ca37b70f98d6df6782f986d99ba /lib/puppet
parent2cad30a18c5e0e4fb93603ab422c290a62d45131 (diff)
downloadpuppet-113d74aaa630f499c8b7989aac6680e22e8e38c8.tar.gz
puppet-113d74aaa630f499c8b7989aac6680e22e8e38c8.tar.xz
puppet-113d74aaa630f499c8b7989aac6680e22e8e38c8.zip
Certificates now work over REST.
All of the format work is done, they all support plaintext successfully, and I've got integration tests that demonstrate that it actually works. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/network/formats.rb4
-rw-r--r--lib/puppet/ssl/certificate.rb11
-rw-r--r--lib/puppet/ssl/certificate_request.rb11
-rw-r--r--lib/puppet/ssl/certificate_revocation_list.rb10
-rw-r--r--lib/puppet/ssl/key.rb2
5 files changed, 31 insertions, 7 deletions
diff --git a/lib/puppet/network/formats.rb b/lib/puppet/network/formats.rb
index bd171fa7d..e11748ce6 100644
--- a/lib/puppet/network/formats.rb
+++ b/lib/puppet/network/formats.rb
@@ -53,16 +53,14 @@ Puppet::Network::FormatHandler.create(:marshal, :mime => "text/marshal") do
end
end
-Puppet::Network::FormatHandler.create(:str, :mime => "text/plain") do
+Puppet::Network::FormatHandler.create(:s, :mime => "text/plain") do
# For now, use the YAML separator.
SEPARATOR = "\n---\n"
- # Yaml doesn't need the class name; it's serialized.
def intern_multiple(klass, text)
text.split(SEPARATOR).collect { |inst| intern(klass, inst) }
end
- # Yaml monkey-patches Array, so this works.
def render_multiple(instances)
instances.collect { |inst| render(inst) }.join(SEPARATOR)
end
diff --git a/lib/puppet/ssl/certificate.rb b/lib/puppet/ssl/certificate.rb
index 82f251d9c..f9297f380 100644
--- a/lib/puppet/ssl/certificate.rb
+++ b/lib/puppet/ssl/certificate.rb
@@ -12,10 +12,19 @@ class Puppet::SSL::Certificate < Puppet::SSL::Base
extend Puppet::Indirector
indirects :certificate, :terminus_class => :file
+ # Convert a string into an instance.
+ def self.from_s(string)
+ instance = wrapped_class.new(string)
+ name = instance.subject.to_s.sub(/\/CN=/i, '').downcase
+ result = new(name)
+ result.content = instance
+ result
+ end
+
# Because of how the format handler class is included, this
# can't be in the base class.
def self.supported_formats
- [:str]
+ [:s]
end
def expiration
diff --git a/lib/puppet/ssl/certificate_request.rb b/lib/puppet/ssl/certificate_request.rb
index 6a55b2bd1..e345f4bb6 100644
--- a/lib/puppet/ssl/certificate_request.rb
+++ b/lib/puppet/ssl/certificate_request.rb
@@ -7,10 +7,19 @@ class Puppet::SSL::CertificateRequest < Puppet::SSL::Base
extend Puppet::Indirector
indirects :certificate_request, :terminus_class => :file
+ # Convert a string into an instance.
+ def self.from_s(string)
+ instance = wrapped_class.new(string)
+ name = instance.subject.to_s.sub(/\/CN=/i, '').downcase
+ result = new(name)
+ result.content = instance
+ result
+ end
+
# Because of how the format handler class is included, this
# can't be in the base class.
def self.supported_formats
- [:str]
+ [:s]
end
# How to create a certificate request with our system defaults.
diff --git a/lib/puppet/ssl/certificate_revocation_list.rb b/lib/puppet/ssl/certificate_revocation_list.rb
index 3e48ddba3..f3c1a348a 100644
--- a/lib/puppet/ssl/certificate_revocation_list.rb
+++ b/lib/puppet/ssl/certificate_revocation_list.rb
@@ -8,10 +8,18 @@ class Puppet::SSL::CertificateRevocationList < Puppet::SSL::Base
extend Puppet::Indirector
indirects :certificate_revocation_list, :terminus_class => :file
+ # Convert a string into an instance.
+ def self.from_s(string)
+ instance = wrapped_class.new(string)
+ result = new('foo') # The name doesn't matter
+ result.content = instance
+ result
+ end
+
# Because of how the format handler class is included, this
# can't be in the base class.
def self.supported_formats
- [:str]
+ [:s]
end
# Knows how to create a CRL with our system defaults.
diff --git a/lib/puppet/ssl/key.rb b/lib/puppet/ssl/key.rb
index 359455b06..d91df03f6 100644
--- a/lib/puppet/ssl/key.rb
+++ b/lib/puppet/ssl/key.rb
@@ -11,7 +11,7 @@ class Puppet::SSL::Key < Puppet::SSL::Base
# Because of how the format handler class is included, this
# can't be in the base class.
def self.supported_formats
- [:str]
+ [:s]
end
attr_accessor :password_file