com.redhat.rhn.domain.token
Class ActivationKeyFactory

java.lang.Object
  extended by com.redhat.rhn.common.hibernate.HibernateFactory
      extended by com.redhat.rhn.domain.token.ActivationKeyFactory

public class ActivationKeyFactory
extends HibernateFactory

ActivationKeyFactory


Field Summary
static java.lang.String DEFAULT_DESCRIPTION
           
 
Constructor Summary
ActivationKeyFactory()
           
 
Method Summary
static void assertKeyAbsence(java.lang.String key)
          Basically asserts that the key passed in has not been previously accounted for.
static ActivationKey createNewKey(User user, Server server, java.lang.String key, java.lang.String note, java.lang.Long usageLimit, Channel baseChannel, boolean universalDefault)
          Creates and fills out a new Activation Key (Including generating a key/token).
static ActivationKey createNewKey(User user, java.lang.String note)
          Creates and fills out a new Activation Key (Including generating a key/token).
static java.lang.String generateKey()
          Generate a random activation key string.
protected  Logger getLogger()
          Get the Logger for the derived class so log messages show up on the correct class
static ActivationKey lookupByKey(java.lang.String key)
          Lookup an ActivationKey by it's key string.
static ActivationKey lookupByKickstartSession(KickstartSession sess)
          Lookup an ActivationKey by its associated KickstartSession.
static ActivationKey lookupByServer(Server server)
          Lookup an ActivationKey by its associated Server.
static ActivationKey lookupByToken(Token tokenIn)
          Lookup the root ActivationKey based on the token.
static void removeKey(ActivationKey key)
          Remove an ActivationKey
static void save(ActivationKey keyIn)
          Saves an ActivationKey to the database
 
Methods inherited from class com.redhat.rhn.common.hibernate.HibernateFactory
addConfigurator, blobToByteArray, blobToString, byteArrayToBlob, closeSession, closeSessionFactory, commitTransaction, createSessionFactory, executeSelectMode, getByteArrayContents, getObject, getSession, initialize, inTransaction, isClosed, isInitialized, listObjectsByNamedQuery, listObjectsByNamedQuery, lookupObjectByNamedQuery, lookupObjectByNamedQuery, reload, removeObject, rollbackTransaction, saveObject, saveObject, stringToBlob
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_DESCRIPTION

public static final java.lang.String DEFAULT_DESCRIPTION
See Also:
Constant Field Values
Constructor Detail

ActivationKeyFactory

public ActivationKeyFactory()
Method Detail

lookupByKey

public static ActivationKey lookupByKey(java.lang.String key)
Lookup an ActivationKey by it's key string.

Parameters:
key - The key for the ActivationKey
Returns:
Returns the corresponding ActivationKey or null if not found.

lookupByToken

public static ActivationKey lookupByToken(Token tokenIn)
Lookup the root ActivationKey based on the token. Looks up by the token and where the KickstartSession is null.

Parameters:
tokenIn - token coming in
Returns:
activation key for this token

createNewKey

public static ActivationKey createNewKey(User user,
                                         java.lang.String note)
Creates and fills out a new Activation Key (Including generating a key/token). Sets deployConfigs to false, disabled to 0, and usage limit to null.

Parameters:
user - The user for the key
note - The note to attach to the key
Returns:
Returns the newly created ActivationKey.

createNewKey

public static ActivationKey createNewKey(User user,
                                         Server server,
                                         java.lang.String key,
                                         java.lang.String note,
                                         java.lang.Long usageLimit,
                                         Channel baseChannel,
                                         boolean universalDefault)
Creates and fills out a new Activation Key (Including generating a key/token). Sets deployConfigs to false, disabled to 0, and usage limit to null. Sets the 'server' to the server param, and the groups to the system groups the server is subscribed to.

Parameters:
user - The user for the key
server - The server for the key
key - Key to use, blank to have one auto-generated
note - The note to attach to the key
usageLimit - Usage limit for the activation key
baseChannel - Base channel for the activation key
universalDefault - Whether or not this key should be set as the universal default.
Returns:
Returns the newly created ActivationKey.

assertKeyAbsence

public static void assertKeyAbsence(java.lang.String key)
Basically asserts that the key passed in has not been previously accounted for. This is mainly useful for validating activation key creation. Basically raises an assertion exception if this key is taken before.

Parameters:
key - the name of the key.

generateKey

public static java.lang.String generateKey()
Generate a random activation key string.

Returns:
random string

save

public static void save(ActivationKey keyIn)
Saves an ActivationKey to the database

Parameters:
keyIn - The ActivationKey to save.

getLogger

protected Logger getLogger()
Get the Logger for the derived class so log messages show up on the correct class

Specified by:
getLogger in class HibernateFactory
Returns:
Logger for this class.

lookupByKickstartSession

public static ActivationKey lookupByKickstartSession(KickstartSession sess)
Lookup an ActivationKey by its associated KickstartSession.

Parameters:
sess - that is associated with ActivationKey
Returns:
ActivationKey associated with session

lookupByServer

public static ActivationKey lookupByServer(Server server)
Lookup an ActivationKey by its associated Server.

Parameters:
server - that is associated with ActivationKey
Returns:
ActivationKey assocaited with session

removeKey

public static void removeKey(ActivationKey key)
Remove an ActivationKey

Parameters:
key - to remove