private boolean matchesPrincipal(Set<String> userRoles, DataPolicy policy) { if (policy.isAnyAuthenticated() && this.getSubject() != null) { return true; } return !Collections.disjoint(policy.getMappedRoleNames(), userRoles); }
/** * This method is required by the Management framework to write the mappings to the persistent form. The actual assignment is done * in the VDBMetaDataClassInstancefactory * @param policies */ public void setDataPolicies(List<DataPolicy> policies){ this.dataPolicies.clear(); for (DataPolicy policy:policies) { this.dataPolicies.put(policy.getName(), (DataPolicyMetadata)policy); } }
private void writeDataPolicy(XMLStreamWriter writer, DataPolicy dp) throws XMLStreamException { writer.writeStartElement(Element.DATA_ROLE.getLocalName()); writeAttribute(writer, Element.NAME.getLocalName(), dp.getName()); writeAttribute(writer, Element.DATA_ROLE_ANY_ATHENTICATED_ATTR.getLocalName(), String.valueOf(dp.isAnyAuthenticated())); writeAttribute(writer, Element.DATA_ROLE_GRANT_ALL_ATTR.getLocalName(), String.valueOf(dp.isGrantAll())); if(dp.isAllowCreateTemporaryTables() !=null) { writeAttribute(writer, Element.DATA_ROLE_ALLOW_TEMP_TABLES_ATTR.getLocalName(), String.valueOf(dp.isAllowCreateTemporaryTables())); if (dp.getDescription() != null) { writeElement(writer, Element.DESCRIPTION, dp.getDescription()); for (DataPolicy.DataPermission permission: dp.getPermissions()) { writer.writeStartElement(Element.PERMISSION.getLocalName()); writeElement(writer, Element.RESOURCE_NAME, permission.getResourceName()); for (String roleName:dp.getMappedRoleNames()) { writeElement(writer, Element.MAPPED_ROLE_NAME, roleName);
private void writeDataPolicy(XMLStreamWriter writer, DataPolicy dp) throws XMLStreamException { writer.writeStartElement(Element.DATA_ROLE.getLocalName()); writeAttribute(writer, Element.NAME.getLocalName(), dp.getName()); writeAttribute(writer, Element.DATA_ROLE_ANY_ATHENTICATED_ATTR.getLocalName(), String.valueOf(dp.isAnyAuthenticated())); writeAttribute(writer, Element.DATA_ROLE_GRANT_ALL_ATTR.getLocalName(), String.valueOf(dp.isGrantAll())); if(dp.isAllowCreateTemporaryTables() !=null) { writeAttribute(writer, Element.DATA_ROLE_ALLOW_TEMP_TABLES_ATTR.getLocalName(), String.valueOf(dp.isAllowCreateTemporaryTables())); if (dp.getDescription() != null) { writeElement(writer, Element.DESCRIPTION, dp.getDescription()); for (DataPolicy.DataPermission permission: dp.getPermissions()) { writer.writeStartElement(Element.PERMISSION.getLocalName()); writeElement(writer, Element.RESOURCE_NAME, permission.getResourceName()); for (String roleName:dp.getMappedRoleNames()) { writeElement(writer, Element.MAPPED_ROLE_NAME, roleName);
private boolean matchesPrincipal(Set<String> userRoles, DataPolicy policy) { if (policy.isAnyAuthenticated() && this.getSubject() != null) { return true; } return !Collections.disjoint(policy.getMappedRoleNames(), userRoles); }
/** * This method is required by the Management framework to write the mappings to the persistent form. The actual assignment is done * in the VDBMetaDataClassInstancefactory * @param policies */ public void setDataPolicies(List<DataPolicy> policies){ this.dataPolicies.clear(); for (DataPolicy policy:policies) { this.dataPolicies.put(policy.getName(), (DataPolicyMetadata)policy); } }
private boolean matchesPrincipal(Set<String> userRoles, DataPolicy policy) { if (policy.isAnyAuthenticated() && this.getSubject() != null) { return true; } return !Collections.disjoint(policy.getMappedRoleNames(), userRoles); }
public HashMap<String, DataPolicy> getAllowedDataPolicies() { if (this.policies == null) { this.policies = new HashMap<String, DataPolicy>(); Set<String> userRoles = getUserRoles(); // get data roles from the VDB VDBMetaData vdb = getVDB(); TransformationMetadata metadata = vdb.getAttachment(TransformationMetadata.class); Collection<? extends DataPolicy> allPolicies = null; if (metadata == null) { allPolicies = vdb.getDataPolicies(); } else { allPolicies = metadata.getPolicies().values(); } for (DataPolicy policy : allPolicies) { if (matchesPrincipal(userRoles, policy)) { this.policies.put(policy.getName(), policy); } } } return this.policies; }
public HashMap<String, DataPolicy> getAllowedDataPolicies() { if (this.policies == null) { this.policies = new HashMap<String, DataPolicy>(); Set<String> userRoles = getUserRoles(); // get data roles from the VDB VDBMetaData vdb = getVDB(); TransformationMetadata metadata = vdb.getAttachment(TransformationMetadata.class); Collection<? extends DataPolicy> allPolicies = null; if (metadata == null) { allPolicies = vdb.getDataPolicies(); } else { allPolicies = metadata.getPolicies().values(); } for (DataPolicy policy : allPolicies) { if (matchesPrincipal(userRoles, policy)) { this.policies.put(policy.getName(), policy); } } } return this.policies; }
public HashMap<String, DataPolicy> getAllowedDataPolicies() { if (this.policies == null) { this.policies = new HashMap<String, DataPolicy>(); Set<String> userRoles = getUserRoles(); // get data roles from the VDB VDBMetaData vdb = getVDB(); TransformationMetadata metadata = vdb.getAttachment(TransformationMetadata.class); Collection<? extends DataPolicy> allPolicies = null; if (metadata == null) { allPolicies = vdb.getDataPolicies(); } else { allPolicies = metadata.getPolicies().values(); } for (DataPolicy policy : allPolicies) { if (matchesPrincipal(userRoles, policy)) { this.policies.put(policy.getName(), policy); } } } return this.policies; }