|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.adobe.flashaccess.sdk.policy.Policy
public class Policy
This class contains information for a license server to digest before issuing a license.
Policy information is baked into a protected content's header at the time of packaging. During license acquisition, the information in the policy tells the client whether it needs to authenticate and may also contain custom data to be interpreted by the client application. The embedded policy information is also sent to the license server in the license request. The rights specified in the policy indicate the rights that the license will contain (although the license server may modify the rights in the license, if desired).
The parameters contained within this class are:
The following is an example of how to create a serialized policy that allows the Play right.
Policy pol = new Policy(false); // No root license ID
LicenseServerInfo lInfo = new LicenseServerInfo(authRequired, authentication_info);
pol.setLicenseServerInfo(lInfo);
pol.setName("Policy_001");
// Rights
PlayRight pr = new PlayRight();
List<Right> rightsList = new ArrayList<Right>();
rightsList.add(pr);
pol.setRights(rightsList);
// Custom Properties
ApplicationProperties customProps = new ApplicationProperties();
customProps.addUTF8String("customDataName_01", "New customer-specified information");
customProps.addUTF8String("customDataName_02", "Other useful information to include");
pol.setCustomProperties(customProps);
// Marshal policy
byte[] bytes = pol.getBytes();
// Unmarshal policy
Policy newPolicy = new Policy( bytes );
Field Summary | |
---|---|
static long |
LICENSE_CACHING_DISABLED
License caching is not allowed. |
static long |
LICENSE_CACHING_UNLIMITED
Unlimited license caching. |
static long |
MAX_LICENSE_CACHING_DURATION
The maximum license caching period, in seconds. |
static long |
MAX_RELATIVE_DURATION
The maximum policy relative duration, in seconds. |
static long |
RELATIVE_DURATION_UNLIMITED
No relative policy expiration date exists. |
Constructor Summary | |
---|---|
Policy(boolean hasRootLicense)
Creates a new Policy and automatically generates a new policy identifier. |
|
Policy(byte[] policy)
This constructor parses an existing policy from the given byte array. |
Method Summary | |
---|---|
void |
checkValidity()
Determines if this Policy is valid (for example, all required fields are specified and
no parameters conflict). |
byte[] |
getBytes()
Retrieves an encoded byte array representation of the policy. |
ApplicationProperties |
getCustomProperties()
Retrieves the optional customer-defined properties to include in the policy. |
java.lang.String |
getId()
Retrieves the identifier generated for the policy. |
long |
getLicenseCachingDuration()
Retrieves the duration (in seconds) during which a license can be cached by the client. |
java.util.Date |
getLicenseCachingEndDate()
Retrieves the date after which a license may not be cached by the client. |
LicenseServerInfo |
getLicenseServerInfo()
Retrieves the information that the client needs when attempting license acquisition. |
java.lang.String |
getName()
Retrieves the friendly name for the policy (optional). |
java.util.Date |
getPolicyEndDate()
Retrieves the date after which content protected with the policy is not valid. |
long |
getPolicyRelativeDuration()
Retrieves the optional duration (in seconds) during which content protected with the policy is valid, starting from the time it was packaged. |
java.util.Date |
getPolicyStartDate()
Retrieves the date from which content protected with the policy is valid. |
int |
getRevision()
Retrieves the revision number of this Policy . |
java.util.Collection |
getRights()
Retrieves the rights associated with the policy. |
java.lang.String |
getRootLicenseId()
Retrieves the root license identifier associated with this Policy . |
boolean |
hasAbsoluteExpiration()
Indicates whether the absolute end date has been set. |
boolean |
hasRelativeExpiration()
Indicates whether the relative policy duration was set. |
void |
setCustomProperties(ApplicationProperties customProperties)
Sets the optional customer-defined properties to include in the policy. |
void |
setLicenseCachingDuration(long seconds)
Sets the number of seconds the license may be cached by the client, starting from the time the client downloads the license. |
void |
setLicenseCachingEndDate(java.util.Date endDate)
Sets the date after which a license may not be cached by the client. |
void |
setLicenseServerInfo(LicenseServerInfo licenseServerInfo)
Sets the information that the client needs when attempting license acquisition. |
void |
setName(java.lang.String policyName)
Sets the friendly name for the policy (optional). |
void |
setPolicyEndDate(java.util.Date endDate)
Sets the date after which content protected with the policy is not valid. |
void |
setPolicyRelativeDuration(long seconds)
Sets the relative policy duration, which is the duration (in seconds) the content protected with this Policy is
valid (optional). |
void |
setPolicyStartDate(java.util.Date startDate)
Sets the date from which content protected with the policy is valid. |
void |
setRights(java.util.Collection rights)
Sets the rights allowed by this policy. |
boolean |
wasModified()
Indicates whether the policy has changed since the Policy object was created. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final long MAX_RELATIVE_DURATION
public static final long RELATIVE_DURATION_UNLIMITED
public static final long MAX_LICENSE_CACHING_DURATION
public static final long LICENSE_CACHING_DISABLED
public static final long LICENSE_CACHING_UNLIMITED
Constructor Detail |
---|
public Policy(boolean hasRootLicense)
Policy
and automatically generates a new policy identifier.
If hasRootLicense
is true
, this constructor also generates a root license identifier (there is a one-to-one
mapping between a root license and a policy). The revision number is 0
until Policy.getBytes()
is called.
hasRootLicense
- true
the policy has a root license, false
otherwise.public Policy(byte[] policy) throws PolicyException, EncodingException
policy
- The policy from which to construct this Policy
.
EncodingException
- Unable to parse the byte array into a Policy
.
PolicyException
- The Policy
is missing required fields or contains conflicting entries.Method Detail |
---|
public byte[] getBytes() throws PolicyException, EncodingException
If this Policy
was created from an empty constructor, the revision number
will be 1
. If this was an existing policy and changes were made to the policy,
the revision number will be incremented by one. Otherwise, the revision number will not change.
The validity of the policy is first checked before encoding into a byte array. Encoding will fail
if Policy.checkValidity()
throws an exception.
PolicyException
- The Policy
is missing required fields or contains conflicting entries.
EncodingException
- Unable to encode the Policy
to a byte array.public int getRevision()
Policy
. The revision number is incremented
by Policy.getBytes()
, but only when the policy has been modified. If two policies have
the same revision number and Policy.wasModified()
returns false
, the policies are equal.
Policy
public boolean wasModified()
Policy
object was created.
If a policy is created using the Policy.Policy(byte[])
constructor, Policy.wasModified()
will return
false
unless some attributes of the policy have been changed. Policy.wasModified()
will always
return true
immediately after Policy.getBytes()
has been called successfully. If two policies have
the same revision number and Policy.wasModified()
returns false
, the policies are equal.
true
if the policy has been modified since it was last serialized, false
otherwise.public java.lang.String getId()
public java.lang.String getName()
null
if no name was provided.public void setName(java.lang.String policyName)
policyName
- The friendly name for the policy.public java.lang.String getRootLicenseId()
Policy
. The root
license identifier is generated when the policy is created, and cannot be changed.
Policy
, or null
if there is no root license.public ApplicationProperties getCustomProperties()
public void setCustomProperties(ApplicationProperties customProperties)
customProperties
- The customer-defined properties to include in the policy.public LicenseServerInfo getLicenseServerInfo()
public void setLicenseServerInfo(LicenseServerInfo licenseServerInfo)
This information may only be set the first time the policy is created (it cannot be updated).
licenseServerInfo
- The information that the client needs when attempting license acquisition.public java.util.Date getPolicyStartDate()
When the policy is serialized and deserialized, dates are stored with second-precision (milliseconds are lost).
null
if the content is valid immediately.public void setPolicyStartDate(java.util.Date startDate)
All dates must be between January 1, 1970 and December 31, 9999 (GMT)
If the end date has been set, it must be after the start date.
When the policy is serialized and deserialized, dates are stored with second-precision (milliseconds are lost).
startDate
- The date from which content protected with the policy is valid, or null
if the content is valid immediately.public java.util.Date getPolicyEndDate()
When the policy is serialized and deserialized, dates are stored with second-precision (milliseconds are lost).
The policy expiration also controls the deletion of client state associated with a license. For example, to enforce the Playback Window restriction, the client stores the time the user first plays the content. This information is deleted when the policy expires. Therefore, if the user obtains a new license, the playback window would start again.
null
if there is no
policy expiration date.public void setPolicyEndDate(java.util.Date endDate)
All dates must be between January 1, 1970 and December 31, 9999 (GMT)
Either the end date or relative duration may be set, but not both (setting the end date will remove the relative policy duration). If the start date has been set, it must be before the end date.
When the policy is serialized and deserialized, dates are stored with second-precision (milliseconds are lost).
The policy expiration also controls the deletion of client state associated with a license. For example, to enforce the Playback Window restriction, the client stores the time the user first plays the content. This information is deleted when the policy expires. Therefore, if the user obtains a new license, the playback window would start again.
endDate
- The date after which content protected with the policy is not valid, or null
if there is no
policy expiration date.public long getPolicyRelativeDuration()
The policy expiration also controls the deletion of client state associated with a license. For example, to enforce the Playback Window restriction, the client stores the time the user first plays the content. This information is deleted when the policy expires. Therefore, if the user obtains a new license, the playback window would start again.
Policy.RELATIVE_DURATION_UNLIMITED
if no relative expiration is set.public void setPolicyRelativeDuration(long seconds)
Policy
is
valid (optional). When the relative policy duration is set, the validity period for each piece of
content begins at the moment it is packaged.
Either the end date or relative duration may be set, but not both. Setting the relative policy expiration will remove the policy end date, if it is set.
The policy expiration also controls the deletion of client state associated with a license. For example, to enforce the Playback Window restriction, the client stores the time the user first plays the content. This information is deleted when the policy expires. Therefore, if the user obtains a new license, the playback window would start again.
seconds
- The policy's relative expiration, or Policy.RELATIVE_DURATION_UNLIMITED
if there is no relative expiration.public boolean hasAbsoluteExpiration()
true
if the policy has an absolute expiration, false
otherwise.public boolean hasRelativeExpiration()
true
if the policy has a relative expiration, false
otherwise.public long getLicenseCachingDuration()
Policy.LICENSE_CACHING_DISABLED
,
Policy.LICENSE_CACHING_UNLIMITED
public void setLicenseCachingDuration(long seconds)
To limit the cache time, set the value greater than 0. The value Policy.LICENSE_CACHING_DISABLED
indicates licenses should not be cached. The value
Policy.LICENSE_CACHING_UNLIMITED
indicates licenses should be cached as long as the
policy is valid.
seconds
- The license caching period in seconds.public java.util.Date getLicenseCachingEndDate()
When the policy is serialized and deserialized, dates are stored with second-precision (milliseconds are lost).
null
if there is no
license caching end date (an license caching duration may still be specified to control caching behavior when the
end date is null
).public void setLicenseCachingEndDate(java.util.Date endDate)
Alternatively, a relative cache duration may be set using Policy.setLicenseCachingDuration(long)
. If the license
caching end date is set to a non-null
value, this takes precedence over the license caching duration.
All dates must be between January 1, 1970 and December 31, 9999 (GMT)
When the policy is serialized and deserialized, dates are stored with second-precision (milliseconds are lost).
endDate
- The date after which licenses may not be cached.public java.util.Collection getRights()
Right
>, or an empty list if no rights have been set.public void setRights(java.util.Collection rights)
rights
- Collection<Right
> containing containing rights to grant.public void checkValidity() throws PolicyException
Policy
is valid (for example, all required fields are specified and
no parameters conflict).
Required fields:
PolicyException
- if there is a problem with the policy.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |