diff options
author | Endi Sukma Dewata <edewata@redhat.com> | 2013-02-21 19:47:35 -0500 |
---|---|---|
committer | Endi Sukma Dewata <edewata@redhat.com> | 2013-03-07 17:51:32 -0500 |
commit | c87a65024177ed67cd4ec0f7d533d973f8e1f971 (patch) | |
tree | dcceb0a14d514c62773ee07a1fcb09e787dae6e4 /base/common/python/pki/client.py | |
parent | b18a44db98f19c4d9b9d8d586d2bd1772a5d9f41 (diff) | |
download | pki-c87a65024177ed67cd4ec0f7d533d973f8e1f971.tar.gz pki-c87a65024177ed67cd4ec0f7d533d973f8e1f971.tar.xz pki-c87a65024177ed67cd4ec0f7d533d973f8e1f971.zip |
Added security domain info validation.
The installer script has been modified to validate security domain
info in both interactive and silent installation.
A basic Python API has been added to access the REST interface.
Ticket #473
Diffstat (limited to 'base/common/python/pki/client.py')
-rw-r--r-- | base/common/python/pki/client.py | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/base/common/python/pki/client.py b/base/common/python/pki/client.py new file mode 100644 index 000000000..7635fe879 --- /dev/null +++ b/base/common/python/pki/client.py @@ -0,0 +1,53 @@ +#!/usr/bin/python +# Authors: +# Endi S. Dewata <edewata@redhat.com> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Copyright (C) 2013 Red Hat, Inc. +# All rights reserved. +# + +import requests + +class PKIConnection: + + def __init__(self, + protocol='http', + hostname='localhost', + port=80, + subsystem='ca'): + + self.protocol = protocol + self.hostname = hostname + self.port = port + self.subsystem = subsystem + + self.serverURI = self.protocol + '://' +\ + self.hostname + ':' + self.port + '/' + \ + self.subsystem + + self.session = requests.Session() + self.session.headers.update({'Accept': 'application/json'}) + + def authenticate(self, username=None, password=None): + if username is not None and password is not None: + self.session.auth = (username, password) + + def get(self, path): + r = self.session.get( + self.serverURI + '/rest/' + path, + verify=False) + r.raise_for_status() + return r
\ No newline at end of file |