Skip to content
Permalink
Browse files

Add new command for changing the user/pswd during a session.

  • Loading branch information...
cyrusdaboo committed Apr 28, 2010
1 parent 4299e96 commit cc913a590b5878b83461918151c538168930c00e
@@ -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",
]
@@ -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."
@@ -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 @@ def setWD(self, newwd):
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]
@@ -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 @@ def __init__(self, server, port=None, ssl=False, user="", pswd="", principal=Non
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)
@@ -89,6 +89,12 @@ def _discoverPrincipal(self):
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))

0 comments on commit cc913a5

Please sign in to comment.
You can’t perform that action at this time.