// Next, verify the policy
try
{
// Get the file
PolicyReader policy = new PolicyReader( policyFile );
m_session.addMessage( INFO_POLICY, "The security policy '" + policy.getFile() + "' exists." );
// See if there is a keystore that's valid
KeyStore ks = policy.getKeyStore();
if ( ks == null )
{
m_session.addMessage( WARNING_POLICY,
"Policy file does not have a keystore... at least not one that we can locate. If your policy file " +
"does not contain any 'signedBy' blocks, this is probably ok." );
}
else
{
m_session.addMessage( INFO_POLICY,
"The security policy specifies a keystore, and we were able to locate it in the filesystem." );
}
// Verify the file
policy.read();
List<Exception> errors = policy.getMessages();
if ( errors.size() > 0 )
{
for( Exception e : errors )
{
m_session.addMessage( ERROR_POLICY, e.getMessage() );
}
}
else
{
m_session.addMessage( INFO_POLICY, "The security policy looks fine." );
m_isSecurityPolicyConfigured = true;
}
// Stash the unique principals mentioned in the file,
// plus our standard roles.
Set<Principal> principals = new LinkedHashSet<Principal>();
principals.add( Role.ALL );
principals.add( Role.ANONYMOUS );
principals.add( Role.ASSERTED );
principals.add( Role.AUTHENTICATED );
ProtectionDomain[] domains = policy.getProtectionDomains();
for ( ProtectionDomain domain : domains )
{
for( Principal principal : domain.getPrincipals() )
{
principals.add( principal );