Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 29 additions & 6 deletions swat/cas/rest/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,12 +766,35 @@ def setZeroIndexedParameters(self):

def copy(self):
''' Copy the connection object '''
username, password = base64.b64decode(
self._auth.split(b' ', 1)[-1]).split(b':', 1)
return type(self)(self._orig_hostname, self._orig_port,
a2u(username), a2u(password),
self._soptions,
self._error)
scheme, auth_value = self._auth.split(b' ', 1)

if scheme == b'Basic':
logger.debug("Using Basic authentication credentials for the request.")
username, password = base64.b64decode(
self._auth.split(b' ', 1)[-1]).split(b':', 1)

return type(self)(
self._orig_hostname,
self._orig_port,
a2u(username),
a2u(password),
self._soptions,
self._error
)

elif scheme == b'Bearer':
logger.debug("Using Bearer token authentication for the request.")
return type(self)(
self._orig_hostname,
self._orig_port,
None,
a2u(auth_value),
self._soptions,
self._error
)

else:
raise SWATError("Unsupported authentication scheme: %s" % scheme)

def getHostname(self):
''' Get the connection hostname '''
Expand Down
Loading