org.apache.shindig.auth
Class BlobCrypterSecurityTokenCodec

java.lang.Object
  extended by org.apache.shindig.auth.BlobCrypterSecurityTokenCodec
All Implemented Interfaces:
SecurityTokenCodec

public class BlobCrypterSecurityTokenCodec
extends Object
implements SecurityTokenCodec

Provides security token decoding services. Configuration is via containers.js. Each container should specify (or inherit) securityTokenKeyFile: path to file containing a key to use for verifying tokens. signedFetchDomain: oauth_consumer_key value to use for signed fetch using default key. Creating a key is best done with a command line like this:

     dd if=/dev/random bs=32 count=1  | openssl base64 > /tmp/key.txt
 
Wire format is "<container>:<encrypted-and-signed-token>"

Since:
2.0.0

Field Summary
protected  Map<String,BlobCrypter> crypters
          Keys are container ids, values are crypters
protected  Map<String,String> domains
          Keys are container ids, values are domains used for signed fetch.
static String SECURITY_TOKEN_KEY_FILE
           
static String SIGNED_FETCH_DOMAIN
           
 
Fields inherited from interface org.apache.shindig.auth.SecurityTokenCodec
ACTIVE_URL_NAME, SECURITY_TOKEN_NAME
 
Constructor Summary
BlobCrypterSecurityTokenCodec(ContainerConfig config)
           
 
Method Summary
 SecurityToken createToken(Map<String,String> tokenParameters)
          Decrypt and verify the provided security token.
 String encodeToken(SecurityToken token)
           
protected  BlobCrypter loadCrypterFromFile(File file)
          Load a BlobCrypter from the specified file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SECURITY_TOKEN_KEY_FILE

public static final String SECURITY_TOKEN_KEY_FILE
See Also:
Constant Field Values

SIGNED_FETCH_DOMAIN

public static final String SIGNED_FETCH_DOMAIN
See Also:
Constant Field Values

crypters

protected final Map<String,BlobCrypter> crypters
Keys are container ids, values are crypters


domains

protected final Map<String,String> domains
Keys are container ids, values are domains used for signed fetch.

Constructor Detail

BlobCrypterSecurityTokenCodec

@Inject
public BlobCrypterSecurityTokenCodec(ContainerConfig config)
Method Detail

loadCrypterFromFile

protected BlobCrypter loadCrypterFromFile(File file)
                                   throws IOException
Load a BlobCrypter from the specified file. Override this if you have your own BlobCrypter implementation.

Throws:
IOException

createToken

public SecurityToken createToken(Map<String,String> tokenParameters)
                          throws SecurityTokenException
Decrypt and verify the provided security token.

Specified by:
createToken in interface SecurityTokenCodec
Parameters:
tokenParameters - Map containing a entry 'token' in wire format (probably encrypted.)
Returns:
the decrypted and verified token.
Throws:
SecurityTokenException - If tokenString is not a valid token

encodeToken

public String encodeToken(SecurityToken token)
                   throws SecurityTokenException
Specified by:
encodeToken in interface SecurityTokenCodec
Throws:
SecurityTokenException


Copyright © 2007-2012. All Rights Reserved.