oauth2client.crypt
index
/usr/local/google/home/jcgregorio/projects/apiclient-release/oauth2client/crypt.py

# -*- coding: utf-8 -*-
#
# Copyright (C) 2011 Google Inc.
#
# 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.

 
Modules
       
base64
OpenSSL.crypto
hashlib
logging
json
time

 
Classes
       
__builtin__.object
Signer
Verifier
exceptions.Exception(exceptions.BaseException)
AppIdentityError

 
class AppIdentityError(exceptions.Exception)
    
Method resolution order:
AppIdentityError
exceptions.Exception
exceptions.BaseException
__builtin__.object

Data descriptors defined here:
__weakref__
list of weak references to the object (if defined)

Methods inherited from exceptions.Exception:
__init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)
__unicode__(...)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message

 
class Signer(__builtin__.object)
    Signs messages with a private key.
 
  Methods defined here:
__init__(self, pkey)
Constructor.
 
Args:
  pkey, OpenSSL.crypto.PKey, The private key to sign with.
sign(self, message)
Signs a message.
 
Args:
  message: string, Message to be signed.
 
Returns:
  string, The signature of the message for the given key.

Static methods defined here:
from_string(key, password='notasecret')
Construct a Signer instance from a string.
 
Args:
  key: string, private key in P12 format.
  password: string, password for the private key file.
 
Returns:
  Signer instance.
 
Raises:
  OpenSSL.crypto.Error if the key can't be parsed.

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class Verifier(__builtin__.object)
    Verifies the signature on a message.
 
  Methods defined here:
__init__(self, pubkey)
Constructor.
 
Args:
  pubkey, OpenSSL.crypto.PKey, The public key to verify with.
verify(self, message, signature)
Verifies a message against a signature.
 
Args:
  message: string, The message to verify.
  signature: string, The signature on the message.
 
Returns:
  True if message was singed by the private key associated with the public
  key that this object was constructed with.

Static methods defined here:
from_string(key_pem, is_x509_cert)
Construct a Verified instance from a string.
 
Args:
  key_pem: string, public key in PEM format.
  is_x509_cert: bool, True if key_pem is an X509 cert, otherwise it is
    expected to be an RSA key in PEM format.
 
Returns:
  Verifier instance.
 
Raises:
  OpenSSL.crypto.Error if the key_pem can't be parsed.

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
Functions
       
make_signed_jwt(signer, payload)
Make a signed JWT.
 
See http://self-issued.info/docs/draft-jones-json-web-token.html.
 
Args:
  signer: crypt.Signer, Cryptographic signer.
  payload: dict, Dictionary of data to convert to JSON and then sign.
 
Returns:
  string, The JWT for the payload.
verify_signed_jwt_with_certs(jwt, certs, audience)
Verify a JWT against public certs.
 
See http://self-issued.info/docs/draft-jones-json-web-token.html.
 
Args:
  jwt: string, A JWT.
  certs: dict, Dictionary where values of public keys in PEM format.
  audience: string, The audience, 'aud', that this JWT should contain. If
    None then the JWT's 'aud' parameter is not verified.
 
Returns:
  dict, The deserialized JSON payload in the JWT.
 
Raises:
  AppIdentityError if any checks are failed.

 
Data
        AUTH_TOKEN_LIFETIME_SECS = 300
CLOCK_SKEW_SECS = 300
MAX_TOKEN_LIFETIME_SECS = 86400