创建com.adobe.flashaccess.sdk.policy.Policy对象并指定其属性,包括权限、许可证缓存持续时间和DRM策略结束日期。
// Create a new DRM policy object.
// False indicates the DRM policy does not use license chaining.
Policy policy = new Policy(false);
policy.setName("DemoPolicy");
// Specify that the DRM policy requires authentication to obtain a license.
policy.setLicenseServerInfo(new LicenseServerInfo(AuthenticationType.UsernamePassword));
// A DRM policy must have at least one Right, typically the play right
PlayRight play = new PlayRight();
// Users can only view content for 24 hours.
play.setPlaybackWindow(24L * 60 * 60);
// Add the play right to the DRM policy.
List rightsList = new ArrayList();
rightsList.add(play);
policy.setRights(rightsList);
// Licenses can be stored on the client for 7 days after downloading
policy.setLicenseCachingDuration(7L * 24 * 60 * 60);
try {
// Content will expire December 31, 2010
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
policy.setPolicyEndDate(dateFormat.parse("2010-12-31"));
} catch (ParseException e) {
// Invalid date specified in dateFormat.parse()
e.printStackTrace();
}