Pre Authentication decorator added Signed-off-by: Imesh Gunaratne <[email protected]>
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/89abcec9 Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/89abcec9 Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/89abcec9 Branch: refs/heads/stratos-4.1.x Commit: 89abcec942562c69a3552ea7482e539e93914063 Parents: f49bebd Author: Milindu Sanoj Kumarage <[email protected]> Authored: Sun Jun 14 15:11:25 2015 +0530 Committer: Imesh Gunaratne <[email protected]> Committed: Tue Oct 13 16:32:44 2015 +0530 ---------------------------------------------------------------------- .../src/main/python/cli/Utils.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/89abcec9/components/org.apache.stratos.python.cli/src/main/python/cli/Utils.py ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.python.cli/src/main/python/cli/Utils.py b/components/org.apache.stratos.python.cli/src/main/python/cli/Utils.py index 350b1eb..2b67d8b 100644 --- a/components/org.apache.stratos.python.cli/src/main/python/cli/Utils.py +++ b/components/org.apache.stratos.python.cli/src/main/python/cli/Utils.py @@ -1,4 +1,6 @@ from texttable import * +import Configs +from Logging import logging class PrintableTree: @@ -47,3 +49,19 @@ class PrintableTable(Texttable): def print_table(self): print self.draw() +def auth(func): + """Authenticate""" + def auth_inner(self, *args, **kwargs): + + if len(args) > 1 and args[1].username is not None: + Configs.stratos_username = args[1].username + if len(args) > 1 and args[1].password is not None: + Configs.stratos_password = args[1].password + + if Configs.stratos_username is "" and Configs.stratos_password is "": + print("Pre authentication failed. Some authentication details are missing") + logging.warning("Pre authentication failed. Some authentication details are missing") + else: + return func(self, *args, **kwargs) + return auth_inner +
