[CalendarServer-changes] [5541] CalDAVClientLibrary/trunk/src

source_changes at macosforge.org source_changes at macosforge.org
Wed Apr 28 11:52:51 PDT 2010


Revision: 5541
          http://trac.macosforge.org/projects/calendarserver/changeset/5541
Author:   cdaboo at apple.com
Date:     2010-04-28 11:52:45 -0700 (Wed, 28 Apr 2010)
Log Message:
-----------
Add new command for changing the user/pswd during a session.

Modified Paths:
--------------
    CalDAVClientLibrary/trunk/src/browser/commands/__init__.py
    CalDAVClientLibrary/trunk/src/browser/shell.py
    CalDAVClientLibrary/trunk/src/client/account.py
    CalDAVClientLibrary/trunk/src/client/clientsession.py

Added Paths:
-----------
    CalDAVClientLibrary/trunk/src/browser/commands/user.py

Modified: CalDAVClientLibrary/trunk/src/browser/commands/__init__.py
===================================================================
--- CalDAVClientLibrary/trunk/src/browser/commands/__init__.py	2010-04-28 16:24:17 UTC (rev 5540)
+++ CalDAVClientLibrary/trunk/src/browser/commands/__init__.py	2010-04-28 18:52:45 UTC (rev 5541)
@@ -1,5 +1,5 @@
 ##
-# Copyright (c) 2007-2008 Apple Inc. All rights reserved.
+# Copyright (c) 2007-2010 Apple Inc. All rights reserved.
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -32,5 +32,6 @@
     "quit",
     "rm",
     "server",
+    "user",
     "whoami",
 ]

Added: CalDAVClientLibrary/trunk/src/browser/commands/user.py
===================================================================
--- CalDAVClientLibrary/trunk/src/browser/commands/user.py	                        (rev 0)
+++ CalDAVClientLibrary/trunk/src/browser/commands/user.py	2010-04-28 18:52:45 UTC (rev 5541)
@@ -0,0 +1,41 @@
+##
+# Copyright (c) 2007-2010 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##
+
+from browser.command import Command
+from browser.command import WrongOptions
+from getpass import getpass
+
+class Cmd(Command):
+    
+    def __init__(self):
+        super(Command, self).__init__()
+        self.cmds = ("user", )
+        
+    def execute(self, name, options):
+        if options:
+            print self.usage(name)
+            raise WrongOptions()
+        user = raw_input("New User: ")
+        pswd = getpass("New Password: ")
+        self.shell.setUserPswd(user, pswd)
+        return True
+
+    def usage(self, name):
+        return """Usage: %s
+""" % (name,)
+
+    def helpDescription(self):
+        return "Allows chnaging the current server login id and password."

Modified: CalDAVClientLibrary/trunk/src/browser/shell.py
===================================================================
--- CalDAVClientLibrary/trunk/src/browser/shell.py	2010-04-28 16:24:17 UTC (rev 5540)
+++ CalDAVClientLibrary/trunk/src/browser/shell.py	2010-04-28 18:52:45 UTC (rev 5541)
@@ -1,5 +1,5 @@
 ##
-# Copyright (c) 2007-2008 Apple Inc. All rights reserved.
+# Copyright (c) 2007-2010 Apple Inc. All rights reserved.
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -61,6 +61,12 @@
         self.prefix = self.wd = newwd
         return True
 
+    def setUserPswd(self, user, pswd):
+        
+        self.user = user
+        self.pswd = pswd
+        self.account.setUserPswd(user, pswd)
+
 def usage():
     return """Usage: shell [OPTIONS]
 

Modified: CalDAVClientLibrary/trunk/src/client/account.py
===================================================================
--- CalDAVClientLibrary/trunk/src/client/account.py	2010-04-28 16:24:17 UTC (rev 5540)
+++ CalDAVClientLibrary/trunk/src/client/account.py	2010-04-28 18:52:45 UTC (rev 5541)
@@ -1,5 +1,5 @@
 ##
-# Copyright (c) 2006-2007 Apple Inc. All rights reserved.
+# Copyright (c) 2006-2010 Apple Inc. All rights reserved.
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -23,6 +23,10 @@
         self.session = CalDAVSession(server, port, ssl, user, pswd, principal, root, logging)
         self.principal = principalCache.getPrincipal(self.session, self.session.principalPath)
     
+    def setUserPswd(self, user, pswd):
+        
+        self.session.setUserPswd(user, pswd)
+
     def getPrincipal(self, path=None, refresh=False):
         if path:
             return principalCache.getPrincipal(self.session, path, refresh=refresh)

Modified: CalDAVClientLibrary/trunk/src/client/clientsession.py
===================================================================
--- CalDAVClientLibrary/trunk/src/client/clientsession.py	2010-04-28 16:24:17 UTC (rev 5540)
+++ CalDAVClientLibrary/trunk/src/client/clientsession.py	2010-04-28 18:52:45 UTC (rev 5541)
@@ -89,6 +89,12 @@
                     self.log.write("Found principal path: %s" % (self.principalPath.absoluteURL(),))
                 return
     
+    def setUserPswd(self, user, pswd):
+        
+        self.user = user
+        self.pswd = pswd
+        self.authorization = None
+
     def testResource(self, rurl):
 
         assert(isinstance(rurl, URL))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100428/d9822947/attachment-0001.html>


More information about the calendarserver-changes mailing list