DrmRightspublic class DrmRights extends Object An entity class that wraps the license information retrieved from the online DRM server.
A caller can instantiate a {@link DrmRights} object by first invoking the
{@link DrmManagerClient#processDrmInfo(DrmInfo)} method and then using the resulting
{@link ProcessedData} object to invoke the {@link DrmRights#DrmRights(ProcessedData, String)}
constructor.
A caller can also instantiate a {@link DrmRights} object by using the
{@link DrmRights#DrmRights(String, String)} constructor, which takes a path to a file
containing rights information instead of a ProcessedData .
Please note that the account id and subscription id is not mandatory by all DRM agents
or plugins. When account id or subscription id is not required by the specific DRM
agent or plugin, they can be either null, or an empty string, or any other don't-care
string value. |
Fields Summary |
---|
private byte[] | mData | private String | mMimeType | private String | mAccountId | private String | mSubscriptionId |
Constructors Summary |
---|
public DrmRights(String rightsFilePath, String mimeType)Creates a DrmRights object with the given parameters.
File file = new File(rightsFilePath);
instantiate(file, mimeType);
| public DrmRights(String rightsFilePath, String mimeType, String accountId)Creates a DrmRights object with the given parameters.
this(rightsFilePath, mimeType);
mAccountId = accountId;
| public DrmRights(String rightsFilePath, String mimeType, String accountId, String subscriptionId)Creates a DrmRights object with the given parameters.
this(rightsFilePath, mimeType);
mAccountId = accountId;
mSubscriptionId = subscriptionId;
| public DrmRights(File rightsFile, String mimeType)Creates a DrmRights object with the given parameters.
instantiate(rightsFile, mimeType);
| public DrmRights(ProcessedData data, String mimeType)Creates a DrmRights object with the given parameters.
if (data == null) {
throw new IllegalArgumentException("data is null");
}
mData = data.getData();
mAccountId = data.getAccountId();
mSubscriptionId = data.getSubscriptionId();
mMimeType = mimeType;
if (!isValid()) {
final String msg = "mimeType: " + mMimeType + "," +
"data: " + mData;
throw new IllegalArgumentException(msg);
}
|
Methods Summary |
---|
public java.lang.String | getAccountId()Retrieves the account ID associated with this DrmRights object.
return mAccountId;
| public byte[] | getData()Retrieves the rights data associated with this DrmRights object.
return mData;
| public java.lang.String | getMimeType()Retrieves the MIME type associated with this DrmRights object.
return mMimeType;
| public java.lang.String | getSubscriptionId()Retrieves the subscription ID associated with this DrmRights object.
return mSubscriptionId;
| private void | instantiate(java.io.File rightsFile, java.lang.String mimeType)
try {
mData = DrmUtils.readBytes(rightsFile);
} catch (IOException e) {
e.printStackTrace();
}
mMimeType = mimeType;
if (!isValid()) {
final String msg = "mimeType: " + mMimeType + "," +
"data: " + mData;
throw new IllegalArgumentException(msg);
}
| boolean | isValid()Determines whether this instance is valid or not.
return (null != mMimeType && !mMimeType.equals("")
&& null != mData && mData.length > 0);
|
|