如何通过 JAVA Security API 来定性 IBM FileNet P8 内容查询和存储的安全
2009-11-05 00:00:00 来源:WEB开发网然后把一个创建好的 security policy 赋值给 class:
清单 4. 将 Security Policy 赋给 class 登录
ClassDefinition cd =
Factory.ClassDefinition.fetchInstance(os, classId, null);
SecurityPolicy sp =
Factory.SecurityPolicy.getInstance(os, ClassNames.SECURITY_POLICY, securityPolicyId);
PropertyDefinition pd =
getPropertyDefinition(cd.get_PropertyDefinitions(), ClassNames.SECURITY_POLICY);
pd.getProperties().get(PropertyNames.PROPERTY_DEFAULT_OBJECT)).setObjectValue(sp);
cd.save(RefreshMode.REFRESH);
下面我们遍历了一个文件夹,过滤出一年时间内从未修改过的 document。然后给该 document 应用了有删除权限的 application security template。
清单 5. 遍历文件夹中的 document
// 获得一个 folder
Folder folder = Factory.Folder.fetchInstance(os, folderId, null);
DocumentSet ds = folder.get_ContainedDocuments();
Calendar cal = newGregorianCalendar();
intcurrYear = cal.get(Calendar.YEAR);
intcurrMonth = cal.get(Calendar.MONTH);
// 遍历文档
Iterator iter = ds.iterator();
while(iter.hasNext())
{
Document doc = (Document) iter.next();
Date docDate = doc.get_DateLastModified();
cal.setTime(docDate);
if(cal.get(Calendar.YEAR) < currYear && cal.get(Calendar.MONTH) < currMonth )
{
doc.applySecurityTemplate(newId("{21a47705-d20a-4b65-938e-2ddcefa45927}") );
doc.save(RefreshMode.REFRESH);
}
}
更多精彩
赞助商链接