private RequestPatternMatcher<ProtocolProcessorDesc> createProtocolProcessorsMatcher( List<ProtocolProcessorConfig> processorConfigs, Map<String, ProtocolProcessorDesc> protocols) throws ServiceException { RequestPatternMatcher<ProtocolProcessorDesc> result = new RequestPatternMatcher<ProtocolProcessorDesc>(true); for (int i = 0; i < processorConfigs.size(); i++) { ProtocolProcessorConfig config = processorConfigs.get(i); String name = config.getName(); name = name.toUpperCase(); ProtocolProcessorDesc processor = protocols.get(name); FeatureIndicatorConfig indicator = config.getIndicator(); String uriPattern = indicator.getURLPattern(); if (uriPattern != null) { result.addUriPattern(uriPattern, processor); } NameValue headerValue = indicator.getTransportHeader(); if (headerValue != null) { String headerName = headerValue.getName(); headerName = SOAHeaders.normalizeName(headerName, true); String value = headerValue.getValue(); value = SOAHeaders.normalizeValue(headerName, value); result.addHeaderPattern(headerName, value, processor); } } return result; }
private void loadSecurityPolicy( String adminName, SecurityPolicyConfigHolder securityPolicy, Map<String, ServiceOperationDesc> operations, Map<String, Map<String, String>> authentOperationsMap) throws ServiceCreationException { if (securityPolicy != null) { Map<String, OperationSecurityConfig> authentOperationsConfig = securityPolicy.getAuthenticationOperations(); for (Map.Entry<String, OperationSecurityConfig> entry : authentOperationsConfig.entrySet()) { String opName = entry.getKey(); if (!opName.equals("*") && !operations.containsKey(opName)) { throw new ServiceCreationException( ErrorDataFactory.createErrorData( ErrorConstants.SVC_FACTORY_INVALID_OPERATION, ErrorConstants.ERRORDOMAIN, new Object[] {adminName, opName})); } Map<String, String> opConfigMap = new HashMap<String, String>(); OperationSecurityConfig opConfig = entry.getValue(); List<NameValue> nvList = opConfig.getOption(); for (NameValue nv : nvList) { String name = nv.getName(); String value = nv.getValue(); opConfigMap.put(name, value); } authentOperationsMap.put(opName, opConfigMap); } } }
private UrlMappingsDesc loadUrlMappings(String adminName, ServiceConfigHolder config) throws ServiceCreationException { OptionList options = config.getHeaderMappingOptions(); if (options == null) { return UrlMappingsDesc.EMPTY_MAPPINGS; } List<NameValue> nameValueList = options.getOption(); Map<Integer, String> pathMap = new HashMap<Integer, String>(); Map<String, String> queryMap = new HashMap<String, String>(); Set<String> rejectSet = new HashSet<String>(); Set<String> nameSet = new HashSet<String>(); String queryOpMapping = null; for (NameValue nv : nameValueList) { String rawname = nv.getName(); String name = SOAHeaders.normalizeName(rawname, true); if (!SOAHeaders.isSOAHeader(name)) { throw new ServiceCreationException( ErrorDataFactory.createErrorData( ErrorConstants.SVC_FACTORY_INVALID_HEADER_NAME, ErrorConstants.ERRORDOMAIN, new Object[] {adminName, name})); } if (nameSet.contains(name)) { throw new ServiceCreationException( ErrorDataFactory.createErrorData( ErrorConstants.SVC_FACTORY_DUPLICATE_HEADER_KEY, ErrorConstants.ERRORDOMAIN, new Object[] {adminName, name})); } nameSet.add(name); String value = nv.getValue(); if (value.startsWith("query[")) { if (!value.endsWith("]")) { throw new ServiceCreationException( ErrorDataFactory.createErrorData( ErrorConstants.SVC_FACTORY_INVALID_MAPPING_VALUE, ErrorConstants.ERRORDOMAIN, new Object[] {adminName, value})); } String indexval = value.substring(6, value.length() - 1); queryMap.put(indexval, name); } else if (value.equals("queryop")) { queryOpMapping = name; } else if (value.startsWith("path[")) { if (!value.endsWith("]")) { throw new ServiceCreationException( ErrorDataFactory.createErrorData( ErrorConstants.SVC_FACTORY_INVALID_MAPPING_VALUE, ErrorConstants.ERRORDOMAIN, new Object[] {adminName, value})); } String indexval = value.substring(5, value.length() - 1); Integer indexnum = null; try { if (indexval.startsWith("+")) { indexval = indexval.replace("+", "-"); } indexnum = Integer.valueOf(indexval); } catch (NumberFormatException e) { throw new ServiceCreationException( ErrorDataFactory.createErrorData( ErrorConstants.SVC_FACTORY_INVALID_MAPPING_VALUE, ErrorConstants.ERRORDOMAIN, new Object[] {adminName, value}), e); } pathMap.put(indexnum, name); } else if (value.trim().equalsIgnoreCase("reject")) { rejectSet.add(name); } else { throw new ServiceCreationException( ErrorDataFactory.createErrorData( ErrorConstants.SVC_FACTORY_INVALID_MAPPING_VALUE, ErrorConstants.ERRORDOMAIN, new Object[] {adminName, value})); } } UrlMappingsDesc result = new UrlMappingsDesc(pathMap, queryMap, queryOpMapping, rejectSet); return result; }