Search in sources :

Example 1 with ParsedPermission

use of net.sourceforge.prograde.policyparser.ParsedPermission in project ddf by codice.

the class PermissionActivator method buildConditionalPermissionInfo.

/**
 * This method will allow policy entries with no permissions for the case where there are
 * pre-defined policy entries for administrators to add configuration specific permissions.
 */
private void buildConditionalPermissionInfo(List<ParsedPolicyEntry> entries, List<ConditionalPermissionInfo> infos, String type) {
    for (ParsedPolicyEntry parsedPolicyEntry : entries) {
        List<ParsedPermission> permissions = parsedPolicyEntry.getPermissions();
        if (permissions.isEmpty()) {
            // Allow policy entries with no permissions.
            continue;
        }
        PermissionInfo[] permissionInfos = new PermissionInfo[permissions.size()];
        int index = 0;
        for (ParsedPermission parsedPermission : permissions) {
            permissionInfos[index++] = new PermissionInfo(parsedPermission.getPermissionType(), replaceSystemProperties(parsedPermission.getPermissionName()), parsedPermission.getActions());
        }
        List<ConditionInfo> conditionInfos = new ArrayList<>();
        addCodebase(parsedPolicyEntry, conditionInfos);
        addSignedBy(parsedPolicyEntry, conditionInfos);
        addPrincipals(parsedPolicyEntry, conditionInfos);
        infos.add(conditionalPermissionAdmin.newConditionalPermissionInfo(null, (conditionInfos.isEmpty()) ? null : conditionInfos.toArray(new ConditionInfo[conditionInfos.size()]), permissionInfos, type));
    }
}
Also used : ConditionInfo(org.osgi.service.condpermadmin.ConditionInfo) ConditionalPermissionInfo(org.osgi.service.condpermadmin.ConditionalPermissionInfo) PermissionInfo(org.osgi.service.permissionadmin.PermissionInfo) ArrayList(java.util.ArrayList) ParsedPolicyEntry(net.sourceforge.prograde.policyparser.ParsedPolicyEntry) ParsedPermission(net.sourceforge.prograde.policyparser.ParsedPermission)

Aggregations

ArrayList (java.util.ArrayList)1 ParsedPermission (net.sourceforge.prograde.policyparser.ParsedPermission)1 ParsedPolicyEntry (net.sourceforge.prograde.policyparser.ParsedPolicyEntry)1 ConditionInfo (org.osgi.service.condpermadmin.ConditionInfo)1 ConditionalPermissionInfo (org.osgi.service.condpermadmin.ConditionalPermissionInfo)1 PermissionInfo (org.osgi.service.permissionadmin.PermissionInfo)1