com.redhat.rhn.manager.token
Class ActivationKeyManager

java.lang.Object
  extended by com.redhat.rhn.manager.token.ActivationKeyManager

public class ActivationKeyManager
extends java.lang.Object

ActivationKeyManager


Method Summary
 void addChannel(ActivationKey key, Channel channel)
          Add a channel to an activation key.
 void addEntitlements(ActivationKey key, java.util.List<java.lang.String> entitlementLabels)
          Add entitlements to an activation key.
 void addPackageName(ActivationKey key, PackageName packageName)
          Add a PackageName to an activation key.
 void addServerGroup(ActivationKey key, ManagedServerGroup group)
          Add a ServerGroup to an activation key.
 void changeKey(java.lang.String newKey, ActivationKey key)
          Renames a given key to new key.
 ActivationKey createNewActivationKey(User user, java.lang.String note)
          Create a new ActivationKey object for a given user, and note.
 ActivationKey createNewActivationKey(User user, java.lang.String key, java.lang.String note, java.lang.Long usageLimit, Channel baseChannel, boolean universalDefault)
          Create a new ActivationKey object for a given user, and note.
 ActivationKey createNewReActivationKey(User user, Server server, java.lang.String note)
          Create a new Re-ActivationKey object for a given user, server, and note
 ActivationKey createNewReActivationKey(User user, Server server, java.lang.String note, KickstartSession session)
          Create a new Re-ActivationKey object for a given user, server, and note
 ActivationKey createNewReActivationKey(User user, Server server, java.lang.String key, java.lang.String note, java.lang.Long usageLimit, Channel baseChannel, boolean universalDefault)
          Create a new Re-ActivationKey object for a given user, server, and note.
 ActivationKey createNewReActivationKey(User user, Server server, java.lang.String key, java.lang.String note, java.lang.Long usageLimit, Channel baseChannel, boolean universalDefault, KickstartSession session)
          Create a new Re-ActivationKey object for a given user, server, and note.
 java.util.List<ActivationKey> findAll(User requester)
          Finds all activation keys visible to user.
 ActivationKey findByServer(Server server, User user)
          Look up an ActivationKey object by server
static ActivationKeyManager getInstance()
           
 ActivationKey lookupByKey(java.lang.String key, User user)
          Look up an ActivationKey object by it's key.
 void remove(ActivationKey key)
          Removes an activation key.
 void removeChannel(ActivationKey key, Channel channel)
          Remove a channel from an activation key.
 void removeEntitlements(ActivationKey key, java.util.List<java.lang.String> entitlementLabels)
          Remove entitlements from an activation key.
 void removePackageName(ActivationKey key, PackageName packageName)
          Remove a PackageName from an activation key.
 void removeServerGroup(ActivationKey key, ServerGroup group)
          Remove a ServerGroup from an activation key.
 void update(ActivationKey target, java.lang.String description, Channel baseChannel)
          Update the given ActivationKey details.
 void validateAddOnEntitlements(java.util.List<java.lang.String> entitlements, boolean adding)
          Validate the requested entitlements.
 void validateCredentials(User user, java.lang.String keyStr, ActivationKey key)
          validates that the given user can administer the given activation key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static ActivationKeyManager getInstance()
Returns:
the static instance of this class.

findByServer

public ActivationKey findByServer(Server server,
                                  User user)
Look up an ActivationKey object by server

Parameters:
server - The server in question
user - needed for authentication
Returns:
Returns the activation key for the server or null if one isn't found.

lookupByKey

public ActivationKey lookupByKey(java.lang.String key,
                                 User user)
Look up an ActivationKey object by it's key.

Parameters:
key - The activation key we're searching for.
user - needed for authentication..
Returns:
Returns the activation key for the given key.

createNewReActivationKey

public ActivationKey createNewReActivationKey(User user,
                                              Server server,
                                              java.lang.String note,
                                              KickstartSession session)
Create a new Re-ActivationKey object for a given user, server, and note

Parameters:
user - The user creating the activation key
server - The server for the activation key
note - A note about the activation key
session - the kickstart session associated with the key
Returns:
Returns a newly created and filled out Activationkey

createNewReActivationKey

public ActivationKey createNewReActivationKey(User user,
                                              Server server,
                                              java.lang.String note)
Create a new Re-ActivationKey object for a given user, server, and note

Parameters:
user - The user creating the activation key
server - The server for the activation key
note - A note about the activation key
Returns:
Returns a newly created and filled out Activationkey

createNewReActivationKey

public ActivationKey createNewReActivationKey(User user,
                                              Server server,
                                              java.lang.String key,
                                              java.lang.String note,
                                              java.lang.Long usageLimit,
                                              Channel baseChannel,
                                              boolean universalDefault)
Create a new Re-ActivationKey object for a given user, server, and note.

Parameters:
user - The user creating the activation key
server - the server to create the key for
key - Key to use, empty string to have one auto-generated
note - A note about the activation 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 a newly created and filled out Activationkey

createNewReActivationKey

public ActivationKey createNewReActivationKey(User user,
                                              Server server,
                                              java.lang.String key,
                                              java.lang.String note,
                                              java.lang.Long usageLimit,
                                              Channel baseChannel,
                                              boolean universalDefault,
                                              KickstartSession session)
Create a new Re-ActivationKey object for a given user, server, and note.

Parameters:
user - The user creating the activation key
server - the server to create the key for
key - Key to use, empty string to have one auto-generated
note - A note about the activation 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.
session - the kickstart session to associate
Returns:
Returns a newly created and filled out Activationkey

createNewActivationKey

public ActivationKey createNewActivationKey(User user,
                                            java.lang.String note)
Create a new ActivationKey object for a given user, and note. If you are tying the activation key to a system (reactivation key) use createNewReActivationKey

Parameters:
user - The user creating the activation key
note - A note about the activation key
Returns:
Returns a newly created and filled out Activationkey

createNewActivationKey

public ActivationKey createNewActivationKey(User user,
                                            java.lang.String key,
                                            java.lang.String note,
                                            java.lang.Long usageLimit,
                                            Channel baseChannel,
                                            boolean universalDefault)
Create a new ActivationKey object for a given user, and note. If you are tying the activation key to a system (reactivation key) use createNewReActivationKey

Parameters:
user - The user creating the activation key
key - Key to use, empty string to have one auto-generated
note - A note about the activation 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 a newly created and filled out Activationkey

update

public void update(ActivationKey target,
                   java.lang.String description,
                   Channel baseChannel)
Update the given ActivationKey details.

Parameters:
target - Key to update.
description - New key description, null to leave unchanged.
baseChannel - New base channel

addEntitlements

public void addEntitlements(ActivationKey key,
                            java.util.List<java.lang.String> entitlementLabels)
Add entitlements to an activation key.

Parameters:
key - Activation key to be acted upon
entitlementLabels - List of string entitlement labels for the activation key

removeEntitlements

public void removeEntitlements(ActivationKey key,
                               java.util.List<java.lang.String> entitlementLabels)
Remove entitlements from an activation key. Entitlements the key does not actually have will be ignored.

Parameters:
key - Activation key to be acted upon
entitlementLabels - List of string entitlement labels for the activation key

addChannel

public void addChannel(ActivationKey key,
                       Channel channel)
Add a channel to an activation key.

Parameters:
key - Activation key to be acted upon
channel - Channel to add

removeChannel

public void removeChannel(ActivationKey key,
                          Channel channel)
Remove a channel from an activation key.

Parameters:
key - Activation key to be acted upon
channel - Channel to remove

addServerGroup

public void addServerGroup(ActivationKey key,
                           ManagedServerGroup group)
Add a ServerGroup to an activation key.

Parameters:
key - Activation key to be acted upon
group - ServerGroup to add

removeServerGroup

public void removeServerGroup(ActivationKey key,
                              ServerGroup group)
Remove a ServerGroup from an activation key.

Parameters:
key - Activation key to be acted upon
group - ServerGroup to remove

addPackageName

public void addPackageName(ActivationKey key,
                           PackageName packageName)
Add a PackageName to an activation key.

Parameters:
key - Activation key to be acted upon
packageName - PackageName to add

removePackageName

public void removePackageName(ActivationKey key,
                              PackageName packageName)
Remove a PackageName from an activation key.

Parameters:
key - Activation key to be acted upon
packageName - PackageName to remove

findAll

public java.util.List<ActivationKey> findAll(User requester)
Finds all activation keys visible to user.

Parameters:
requester - User requesting the list.
Returns:
All activation keys visible to user.

validateCredentials

public void validateCredentials(User user,
                                java.lang.String keyStr,
                                ActivationKey key)
validates that the given user can administer the given activation key. Raises a permission exception if the combination is invalid..

Parameters:
user - the user to authenticate
keyStr - Key string used for lookup. Null if none was used. (i.e. lookup by server)
key - the key to authenticate

remove

public void remove(ActivationKey key)
Removes an activation key. The fact the an ActivationKey Object was generated implies that the user credentials have been verified...

Parameters:
key - the key to remove

validateAddOnEntitlements

public void validateAddOnEntitlements(java.util.List<java.lang.String> entitlements,
                                      boolean adding)
Validate the requested entitlements. At this juncture only the add-on entitlements are to be set via the API.

Parameters:
entitlements - List of string entitlement labels to be validated.
adding - True if adding entitlements, false if removing.

changeKey

public void changeKey(java.lang.String newKey,
                      ActivationKey key)
Renames a given key to new key. This operation is crucial when we are doing things like renaming and activation key after edit by prepending its org_id to it.

Parameters:
newKey - the key to rename to
key - the key object to be renamed