summaryrefslogtreecommitdiffstats
path: root/base/common/python
diff options
context:
space:
mode:
authorEndi Sukma Dewata <edewata@redhat.com>2013-02-21 19:47:35 -0500
committerEndi Sukma Dewata <edewata@redhat.com>2013-03-07 17:51:32 -0500
commitc87a65024177ed67cd4ec0f7d533d973f8e1f971 (patch)
treedcceb0a14d514c62773ee07a1fcb09e787dae6e4 /base/common/python
parentb18a44db98f19c4d9b9d8d586d2bd1772a5d9f41 (diff)
downloadpki-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')
-rw-r--r--base/common/python/pki/__init__.py0
-rw-r--r--base/common/python/pki/account.py31
-rw-r--r--base/common/python/pki/client.py53
-rw-r--r--base/common/python/pki/system.py38
4 files changed, 122 insertions, 0 deletions
diff --git a/base/common/python/pki/__init__.py b/base/common/python/pki/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/base/common/python/pki/__init__.py
diff --git a/base/common/python/pki/account.py b/base/common/python/pki/account.py
new file mode 100644
index 000000000..84f2d0ef0
--- /dev/null
+++ b/base/common/python/pki/account.py
@@ -0,0 +1,31 @@
+#!/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.
+#
+
+class AccountClient:
+
+ def __init__(self, connection):
+ self.connection = connection
+
+ def login(self):
+ self.connection.get('account/login')
+
+ def logout(self):
+ self.connection.get('account/logout')
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
diff --git a/base/common/python/pki/system.py b/base/common/python/pki/system.py
new file mode 100644
index 000000000..61ffbb9ff
--- /dev/null
+++ b/base/common/python/pki/system.py
@@ -0,0 +1,38 @@
+#!/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.
+#
+
+class SecurityDomainInfo:
+
+ def __init__(self):
+ pass
+
+class SecurityDomainClient:
+
+ def __init__(self, connection):
+ self.connection = connection
+
+ def getSecurityDomainInfo(self):
+ r = self.connection.get('securityDomain/domainInfo')
+
+ info = SecurityDomainInfo()
+ info.name = r.json['DomainInfo']['@id']
+
+ return info