/** * Create XACML policy using the data received from basic policy wizard * * @param basicPolicyDTO BasicPolicyDTO * @return String object of the XACML policy * @throws PolicyEditorException throws */ public String createBasicPolicy(BasicPolicyDTO basicPolicyDTO) throws PolicyEditorException { if (basicPolicyDTO == null) { throw new PolicyEditorException("Policy object can not be null"); } try { return PolicyBuilder.getInstance().build(basicPolicyDTO); } catch (PolicyBuilderException e) { log.error(e); throw new PolicyEditorException("Error while building policy"); } }
/** * Create XACML policy using the data received from basic policy wizard * * @param basicPolicyDTO BasicPolicyDTO * @return String object of the XACML policy * @throws PolicyEditorException throws */ public String createBasicPolicy(BasicPolicyDTO basicPolicyDTO) throws PolicyEditorException { if (basicPolicyDTO == null) { throw new PolicyEditorException("Policy object can not be null"); } try { return PolicyBuilder.getInstance().build(basicPolicyDTO); } catch (PolicyBuilderException e) { log.error(e); throw new PolicyEditorException("Error while building policy"); } }
/** * Create XACML policy using the data received from basic policy wizard * * @param basicPolicyDTO BasicPolicyDTO * @return String object of the XACML policy * @throws PolicyEditorException throws */ public String createBasicPolicy(BasicPolicyDTO basicPolicyDTO) throws PolicyEditorException { if (basicPolicyDTO == null) { throw new PolicyEditorException("Policy object can not be null"); } try { return PolicyBuilder.getInstance().build(basicPolicyDTO); } catch (PolicyBuilderException e) { log.error(e); throw new PolicyEditorException("Error while building policy"); } }
private void parsePreFunctions(Node root, PolicyEditorDataHolder holder) throws PolicyEditorException { NodeList nodeList = root.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); if ("preFunction".equals(node.getNodeName())) { String name = null; String uri = null; NodeList childList = node.getChildNodes(); for (int j = 0; j < childList.getLength(); j++) { Node child = childList.item(j); if ("name".equals(child.getNodeName())) { name = child.getTextContent(); } else if ("uri".equals(child.getNodeName())) { uri = child.getTextContent(); } } if (name != null && uri != null) { if (!Utils.isValidPreFunction(uri)) { throw new PolicyEditorException("Invalid PreFunction : " + uri); } holder.getPreFunctionMap().put(name, uri); } } } }
private void parsePreFunctions(Node root, PolicyEditorDataHolder holder) throws PolicyEditorException { NodeList nodeList = root.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); if ("preFunction".equals(node.getNodeName())) { String name = null; String uri = null; NodeList childList = node.getChildNodes(); for (int j = 0; j < childList.getLength(); j++) { Node child = childList.item(j); if ("name".equals(child.getNodeName())) { name = child.getTextContent(); } else if ("uri".equals(child.getNodeName())) { uri = child.getTextContent(); } } if (name != null && uri != null) { if (!Utils.isValidPreFunction(uri)) { throw new PolicyEditorException("Invalid PreFunction : " + uri); } holder.getPreFunctionMap().put(name, uri); } } } }
private void parsePreFunctions(Node root, PolicyEditorDataHolder holder) throws PolicyEditorException { NodeList nodeList = root.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); if ("preFunction".equals(node.getNodeName())) { String name = null; String uri = null; NodeList childList = node.getChildNodes(); for (int j = 0; j < childList.getLength(); j++) { Node child = childList.item(j); if ("name".equals(child.getNodeName())) { name = child.getTextContent(); } else if ("uri".equals(child.getNodeName())) { uri = child.getTextContent(); } } if (name != null && uri != null) { if (!Utils.isValidPreFunction(uri)) { throw new PolicyEditorException("Invalid PreFunction : " + uri); } holder.getPreFunctionMap().put(name, uri); } } } }
private void parseDataTypes(Node root, PolicyEditorDataHolder holder) throws PolicyEditorException { NodeList nodeList = root.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); if ("dataType".equals(node.getNodeName())) { String name = null; String uri = null; NodeList childList = node.getChildNodes(); for (int j = 0; j < childList.getLength(); j++) { Node child = childList.item(j); if ("name".equals(child.getNodeName())) { name = child.getTextContent(); } else if ("uri".equals(child.getNodeName())) { uri = child.getTextContent(); } } if (name != null && uri != null) { if (!Utils.isValidDataType(uri)) { throw new PolicyEditorException("Invalid DataType : " + uri); } holder.getDataTypeMap().put(name, uri); } } if ("defaultDataTypes".equals(node.getNodeName())) { holder.setDefaultDataType(node.getTextContent()); } } }
private void parseDataTypes(Node root, PolicyEditorDataHolder holder) throws PolicyEditorException { NodeList nodeList = root.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); if ("dataType".equals(node.getNodeName())) { String name = null; String uri = null; NodeList childList = node.getChildNodes(); for (int j = 0; j < childList.getLength(); j++) { Node child = childList.item(j); if ("name".equals(child.getNodeName())) { name = child.getTextContent(); } else if ("uri".equals(child.getNodeName())) { uri = child.getTextContent(); } } if (name != null && uri != null) { if (!Utils.isValidDataType(uri)) { throw new PolicyEditorException("Invalid DataType : " + uri); } holder.getDataTypeMap().put(name, uri); } } if ("defaultDataTypes".equals(node.getNodeName())) { holder.setDefaultDataType(node.getTextContent()); } } }
private void parseDataTypes(Node root, PolicyEditorDataHolder holder) throws PolicyEditorException { NodeList nodeList = root.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); if ("dataType".equals(node.getNodeName())) { String name = null; String uri = null; NodeList childList = node.getChildNodes(); for (int j = 0; j < childList.getLength(); j++) { Node child = childList.item(j); if ("name".equals(child.getNodeName())) { name = child.getTextContent(); } else if ("uri".equals(child.getNodeName())) { uri = child.getTextContent(); } } if (name != null && uri != null) { if (!Utils.isValidDataType(uri)) { throw new PolicyEditorException("Invalid DataType : " + uri); } holder.getDataTypeMap().put(name, uri); } } if ("defaultDataTypes".equals(node.getNodeName())) { holder.setDefaultDataType(node.getTextContent()); } } }
throw new PolicyEditorException("Invalid Function : " + uri);
throw new PolicyEditorException("Invalid Function : " + uri);
throw new PolicyEditorException("Invalid Function : " + uri);
/** * Create basic XACML request * * @param requestDTO request element * @return String object of the XACML request * @throws EntitlementPolicyCreationException throws */ public String createBasicRequest(RequestDTO requestDTO) throws EntitlementPolicyCreationException, PolicyEditorException { try { RequestElementDTO requestElementDTO = PolicyCreatorUtil.createRequestElementDTO(requestDTO); return PolicyBuilder.getInstance().buildRequest(requestElementDTO); } catch (PolicyBuilderException e) { throw new PolicyEditorException("Error while building XACML Request"); } } }
/** * Create basic XACML request * * @param requestDTO request element * @return String object of the XACML request * @throws EntitlementPolicyCreationException throws */ public String createBasicRequest(RequestDTO requestDTO) throws EntitlementPolicyCreationException, PolicyEditorException { try { RequestElementDTO requestElementDTO = PolicyCreatorUtil.createRequestElementDTO(requestDTO); return PolicyBuilder.getInstance().buildRequest(requestElementDTO); } catch (PolicyBuilderException e) { throw new PolicyEditorException("Error while building XACML Request"); } } }
/** * Create basic XACML request * * @param requestDTO request element * @return String object of the XACML request * @throws EntitlementPolicyCreationException throws */ public String createBasicRequest(RequestDTO requestDTO) throws EntitlementPolicyCreationException, PolicyEditorException { try { RequestElementDTO requestElementDTO = PolicyCreatorUtil.createRequestElementDTO(requestDTO); return PolicyBuilder.getInstance().buildRequest(requestElementDTO); } catch (PolicyBuilderException e) { throw new PolicyEditorException("Error while building XACML Request"); } } }
@Override public void persistConfig(String policyEditorType, String xmlConfig) throws PolicyEditorException { super.persistConfig(policyEditorType, xmlConfig); Registry registry = CarbonContext.getThreadLocalCarbonContext().getRegistry(RegistryType.SYSTEM_GOVERNANCE); try { Resource resource = registry.newResource(); resource.setContent(xmlConfig); String path = null; if (EntitlementConstants.PolicyEditor.BASIC.equals(policyEditorType)) { path = EntitlementConstants.ENTITLEMENT_POLICY_BASIC_EDITOR_CONFIG_FILE_REGISTRY_PATH; } else if (EntitlementConstants.PolicyEditor.STANDARD.equals(policyEditorType)) { path = EntitlementConstants.ENTITLEMENT_POLICY_STANDARD_EDITOR_CONFIG_FILE_REGISTRY_PATH; } else if (EntitlementConstants.PolicyEditor.RBAC.equals(policyEditorType)) { path = EntitlementConstants.ENTITLEMENT_POLICY_RBAC_EDITOR_CONFIG_FILE_REGISTRY_PATH; } else if (EntitlementConstants.PolicyEditor.SET.equals(policyEditorType)) { path = EntitlementConstants.ENTITLEMENT_POLICY_SET_EDITOR_CONFIG_FILE_REGISTRY_PATH; } else { //default path = EntitlementConstants.ENTITLEMENT_POLICY_BASIC_EDITOR_CONFIG_FILE_REGISTRY_PATH; } registry.put(path, resource); } catch (RegistryException e) { throw new PolicyEditorException("Error while persisting policy editor config"); } }
@Override public void persistConfig(String policyEditorType, String xmlConfig) throws PolicyEditorException { super.persistConfig(policyEditorType, xmlConfig); Registry registry = CarbonContext.getThreadLocalCarbonContext().getRegistry(RegistryType.SYSTEM_GOVERNANCE); try { Resource resource = registry.newResource(); resource.setContent(xmlConfig); String path = null; if (EntitlementConstants.PolicyEditor.BASIC.equals(policyEditorType)) { path = EntitlementConstants.ENTITLEMENT_POLICY_BASIC_EDITOR_CONFIG_FILE_REGISTRY_PATH; } else if (EntitlementConstants.PolicyEditor.STANDARD.equals(policyEditorType)) { path = EntitlementConstants.ENTITLEMENT_POLICY_STANDARD_EDITOR_CONFIG_FILE_REGISTRY_PATH; } else if (EntitlementConstants.PolicyEditor.RBAC.equals(policyEditorType)) { path = EntitlementConstants.ENTITLEMENT_POLICY_RBAC_EDITOR_CONFIG_FILE_REGISTRY_PATH; } else if (EntitlementConstants.PolicyEditor.SET.equals(policyEditorType)) { path = EntitlementConstants.ENTITLEMENT_POLICY_SET_EDITOR_CONFIG_FILE_REGISTRY_PATH; } else { //default path = EntitlementConstants.ENTITLEMENT_POLICY_BASIC_EDITOR_CONFIG_FILE_REGISTRY_PATH; } registry.put(path, resource); } catch (RegistryException e) { throw new PolicyEditorException("Error while persisting policy editor config"); } }
@Override public void persistConfig(String policyEditorType, String xmlConfig) throws PolicyEditorException { super.persistConfig(policyEditorType, xmlConfig); Registry registry = CarbonContext.getThreadLocalCarbonContext().getRegistry(RegistryType.SYSTEM_GOVERNANCE); try { Resource resource = registry.newResource(); resource.setContent(xmlConfig); String path = null; if (EntitlementConstants.PolicyEditor.BASIC.equals(policyEditorType)) { path = EntitlementConstants.ENTITLEMENT_POLICY_BASIC_EDITOR_CONFIG_FILE_REGISTRY_PATH; } else if (EntitlementConstants.PolicyEditor.STANDARD.equals(policyEditorType)) { path = EntitlementConstants.ENTITLEMENT_POLICY_STANDARD_EDITOR_CONFIG_FILE_REGISTRY_PATH; } else if (EntitlementConstants.PolicyEditor.RBAC.equals(policyEditorType)) { path = EntitlementConstants.ENTITLEMENT_POLICY_RBAC_EDITOR_CONFIG_FILE_REGISTRY_PATH; } else if (EntitlementConstants.PolicyEditor.SET.equals(policyEditorType)) { path = EntitlementConstants.ENTITLEMENT_POLICY_SET_EDITOR_CONFIG_FILE_REGISTRY_PATH; } else { //default path = EntitlementConstants.ENTITLEMENT_POLICY_BASIC_EDITOR_CONFIG_FILE_REGISTRY_PATH; } registry.put(path, resource); } catch (RegistryException e) { throw new PolicyEditorException("Error while persisting policy editor config"); } }
throw new PolicyEditorException("Can not create Match element:" + " Required Attributes are missing");
throw new PolicyEditorException("Can not create Match element:" + " Required Attributes are missing");