org.apache.cxf.common.util.StringUtils Java Examples
The following examples show how to use
org.apache.cxf.common.util.StringUtils.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PolicyEngineBPDefinitionParser.java From cxf with Apache License 2.0 | 6 votes |
public Metadata parse(Element element, ParserContext context) { MutableBeanMetadata policyEngineConfig = context.createMetadata(MutableBeanMetadata.class); policyEngineConfig.setRuntimeClass(PolicyEngineConfig.class); String bus = element.getAttribute("bus"); if (StringUtils.isEmpty(bus)) { bus = "cxf"; } policyEngineConfig.addArgument(getBusRef(context, bus), Bus.class.getName(), 0); parseAttributes(element, context, policyEngineConfig); parseChildElements(element, context, policyEngineConfig); policyEngineConfig.setId(PolicyEngineConfig.class.getName() + context.generateId()); return policyEngineConfig; }
Example #2
Source File: HttpUtils.java From cxf with Apache License 2.0 | 6 votes |
public static String getHeaderString(List<String> values) { if (values == null) { return null; } StringBuilder sb = new StringBuilder(); for (int i = 0; i < values.size(); i++) { String value = values.get(i); if (StringUtils.isEmpty(value)) { continue; } sb.append(value); if (i + 1 < values.size()) { sb.append(','); } } return sb.toString(); }
Example #3
Source File: JaxWsServiceConfiguration.java From cxf with Apache License 2.0 | 6 votes |
public Boolean isWrapperPartQualified(MessagePartInfo mpi) { Annotation[] annotations = (Annotation[])mpi.getProperty("parameter.annotations"); if (annotations != null) { for (Annotation an : annotations) { String tns = null; if (an instanceof WebParam) { tns = ((WebParam)an).targetNamespace(); } else if (an instanceof WebResult) { tns = ((WebResult)an).targetNamespace(); } if (tns != null && !StringUtils.isEmpty(tns)) { return Boolean.TRUE; } } } return null; }
Example #4
Source File: MAPAggregatorImpl.java From cxf with Apache License 2.0 | 6 votes |
private String getActionFromFaultMessage(final OperationInfo operation, final String faultName) { if (operation.getFaults() != null) { for (FaultInfo faultInfo : operation.getFaults()) { if (isSameFault(faultInfo, faultName)) { if (faultInfo.getExtensionAttributes() != null) { String faultAction = InternalContextUtils.getAction(faultInfo); if (!StringUtils.isEmpty(faultAction)) { return faultAction; } } return addPath(addPath(addPath(getActionBaseUri(operation), operation.getName().getLocalPart()), "Fault"), faultInfo.getFaultName().getLocalPart()); } } } return addPath(addPath(addPath(getActionBaseUri(operation), operation.getName().getLocalPart()), "Fault"), faultName); }
Example #5
Source File: AbstractTokenService.java From cxf with Apache License 2.0 | 6 votes |
protected Client getClientFromTLSCertificates(SecurityContext sc, TLSSessionInfo tlsSessionInfo, MultivaluedMap<String, String> params) { Client client = null; if (OAuthUtils.isMutualTls(sc, tlsSessionInfo)) { X509Certificate cert = OAuthUtils.getRootTLSCertificate(tlsSessionInfo); String subjectDn = OAuthUtils.getSubjectDnFromTLSCertificates(cert); if (!StringUtils.isEmpty(subjectDn)) { client = getClient(subjectDn, params); validateClientAuthenticationMethod(client, OAuthConstants.TOKEN_ENDPOINT_AUTH_TLS); // The certificates must be registered with the client and match TLS certificates // in case of the binding where Client's clientId is a subject distinguished name compareTlsCertificates(tlsSessionInfo, client.getApplicationCertificates()); OAuthUtils.setCertificateThumbprintConfirmation(getMessageContext(), cert); } } return client; }
Example #6
Source File: OSGIBusListener.java From cxf with Apache License 2.0 | 6 votes |
public OSGIBusListener(Bus b, Object[] args) { bus = b; if (args != null && args.length > 0 && args[0] instanceof BundleContext) { defaultContext = (BundleContext)args[0]; } String extExcludes = (String)bus.getProperty(BUS_EXTENSION_BUNDLES_EXCLUDES); if (!StringUtils.isEmpty(extExcludes)) { try { extensionBundlesExcludesPattern = Pattern.compile(extExcludes); } catch (IllegalArgumentException e) { // ignore } } BusLifeCycleManager manager = bus.getExtension(BusLifeCycleManager.class); manager.registerLifeCycleListener(this); registerConfiguredBeanLocator(); registerClientLifeCycleListeners(); registerServerLifecycleListeners(); registerBusFeatures(); sendBusCreatedToBusCreationListeners(); }
Example #7
Source File: CircuitBreakerTargetSelector.java From cxf with Apache License 2.0 | 6 votes |
private synchronized CircuitBreaker getCircuitBreaker(final String alternateAddress) { CircuitBreaker circuitBreaker = null; if (!StringUtils.isEmpty(alternateAddress)) { for (Map.Entry<String, CircuitBreaker> entry: circuits.entrySet()) { if (alternateAddress.startsWith(entry.getKey())) { circuitBreaker = entry.getValue(); break; } } if (circuitBreaker == null) { circuitBreaker = new ZestCircuitBreaker(threshold, timeout); circuits.put(alternateAddress, circuitBreaker); } } if (circuitBreaker == null) { circuitBreaker = NOOP_CIRCUIT_BREAKER; } return circuitBreaker; }
Example #8
Source File: AbstractBeanDefinitionParser.java From cxf with Apache License 2.0 | 6 votes |
protected void addBusWiringAttribute(BeanDefinitionBuilder bean, BusWiringType type, String busName, ParserContext ctx) { LOG.fine("Adding " + WIRE_BUS_ATTRIBUTE + " attribute " + type + " to bean " + bean); bean.getRawBeanDefinition().setAttribute(WIRE_BUS_ATTRIBUTE, type); if (!StringUtils.isEmpty(busName)) { bean.getRawBeanDefinition().setAttribute(WIRE_BUS_NAME, busName.charAt(0) == '#' ? busName.substring(1) : busName); } if (ctx != null && !ctx.getRegistry().containsBeanDefinition(WIRE_BUS_HANDLER)) { BeanDefinitionBuilder b = BeanDefinitionBuilder.rootBeanDefinition(WIRE_BUS_HANDLER); ctx.getRegistry().registerBeanDefinition(WIRE_BUS_HANDLER, b.getBeanDefinition()); } }
Example #9
Source File: JaxWsServiceConfiguration.java From cxf with Apache License 2.0 | 6 votes |
@Override public QName getRequestWrapperName(OperationInfo op, Method method) { Method m = getDeclaredMethod(method); RequestWrapper rw = m.getAnnotation(RequestWrapper.class); String nm = null; String lp = null; if (rw != null) { nm = rw.targetNamespace(); lp = rw.localName(); } WebMethod meth = m.getAnnotation(WebMethod.class); if (meth != null && StringUtils.isEmpty(lp)) { lp = meth.operationName(); } if (StringUtils.isEmpty(nm)) { nm = op.getName().getNamespaceURI(); } if (!StringUtils.isEmpty(nm) && !StringUtils.isEmpty(lp)) { return new QName(nm, lp); } return null; }
Example #10
Source File: WSDLToCorbaHelper.java From cxf with Apache License 2.0 | 6 votes |
protected QName checkPrefix(QName schematypeName) { QName name = schematypeName; if ((name != null) && (name.getPrefix() == null || name.getPrefix().isEmpty())) { if (StringUtils.isEmpty(name.getNamespaceURI())) { return name; } String prefix = def.getPrefix(name.getNamespaceURI()); if (prefix == null) { prefix = xmlSchemaList.getSchemaByTargetNamespace(name.getNamespaceURI()) .getNamespaceContext().getPrefix(name.getNamespaceURI()); } if (prefix != null) { return new QName(name.getNamespaceURI(), name.getLocalPart(), prefix); } return null; } return name; }
Example #11
Source File: OldLoggingFactoryBeanListener.java From cxf with Apache License 2.0 | 6 votes |
private LogEventSender createEventSender(String location) { if (StringUtils.isEmpty(location)) { return null; } if ("<stdout>".equals(location)) { return new PrintWriterEventSender(System.out); } else if ("<stderr>".equals(location)) { return new PrintWriterEventSender(System.err); } else if (location.startsWith("file:")) { try { URI uri = new URI(location); File file = new File(uri); PrintWriter writer = new PrintWriter(new FileWriter(file, true), true); return new PrintWriterEventSender(writer); } catch (Exception ex) { //stick with default } } return null; }
Example #12
Source File: OAuthRequestFilter.java From cxf with Apache License 2.0 | 6 votes |
protected String validateAudiences(List<String> audiences) { if (StringUtils.isEmpty(audiences) && audience == null) { return null; } if (audience != null) { if (audiences.contains(audience)) { return audience; } AuthorizationUtils.throwAuthorizationFailure(supportedSchemes, realm); } if (!audienceIsEndpointAddress) { return null; } String requestPath = (String)PhaseInterceptorChain.getCurrentMessage().get(Message.REQUEST_URL); for (String s : audiences) { boolean matched = completeAudienceMatch ? requestPath.equals(s) : requestPath.startsWith(s); if (matched) { return s; } } AuthorizationUtils.throwAuthorizationFailure(supportedSchemes, realm); return null; }
Example #13
Source File: Wrapper.java From cxf with Apache License 2.0 | 6 votes |
private WrapperBeanClass merge(final WrapperBeanClass c1, final WrapperBeanClass c2) { if (c1.getElementName() == null) { c1.setElementName(c2.getElementName()); } if (StringUtils.isEmpty(c1.getNamespace())) { c1.setNamespace(c2.getNamespace()); } if (StringUtils.isEmpty(c1.getPackageName())) { c1.setPackageName(c2.getPackageName()); } else { this.isSamePackage = c1.getPackageName().equals(c2.getPackageName()); } if (StringUtils.isEmpty(c1.getName())) { c1.setName(c2.getName()); } return c1; }
Example #14
Source File: KerberosAuthenticationFilter.java From cxf with Apache License 2.0 | 6 votes |
protected Subject loginAndGetSubject() throws LoginException { // The login without a callback can work if // - Kerberos keytabs are used with a principal name set in the JAAS config // - Kerberos is integrated into the OS logon process // meaning that a process which runs this code has the // user identity LoginContext lc = null; if (!StringUtils.isEmpty(loginContextName) || loginConfig != null) { lc = new LoginContext(loginContextName, null, callbackHandler, loginConfig); } else { LOG.fine("LoginContext can not be initialized"); throw new LoginException(); } lc.login(); return lc.getSubject(); }
Example #15
Source File: OAuthUtils.java From cxf with Apache License 2.0 | 6 votes |
public static boolean checkRequestURI(String servletPath, String uri) { boolean wildcard = uri.endsWith("*"); String theURI = wildcard ? uri.substring(0, uri.length() - 1) : uri; try { URITemplate template = new URITemplate(theURI); MultivaluedMap<String, String> map = new MetadataMap<>(); if (template.match(servletPath, map)) { String finalGroup = map.getFirst(URITemplate.FINAL_MATCH_GROUP); if (wildcard || StringUtils.isEmpty(finalGroup) || "/".equals(finalGroup)) { return true; } } } catch (Exception ex) { // ignore } return false; }
Example #16
Source File: MemoryTokenStore.java From steady with Apache License 2.0 | 5 votes |
public void add(String identifier, SecurityToken token) { if (token != null && !StringUtils.isEmpty(identifier)) { CacheEntry cacheEntry = createCacheEntry(token); if (cacheEntry != null) { tokens.put(identifier, cacheEntry); } } }
Example #17
Source File: PluginLoader.java From cxf with Apache License 2.0 | 5 votes |
private String getGeneratorClass(FrontEnd frontend, Generator generator) { String fullPackage = generator.getPackage(); if (StringUtils.isEmpty(fullPackage)) { fullPackage = frontend.getGenerators().getPackage(); } if (StringUtils.isEmpty(fullPackage)) { fullPackage = frontend.getPackage(); } return fullPackage + "." + generator.getName(); }
Example #18
Source File: WadlGenerator.java From cxf with Apache License 2.0 | 5 votes |
public boolean addSchemaDocument(SchemaCollection col, List<String> tnsList, Document d, String systemId, boolean hackAroundEmptyNamespaceIssue) { String ns = d.getDocumentElement().getAttribute("targetNamespace"); if (StringUtils.isEmpty(ns)) { if (DOMUtils.getFirstElement(d.getDocumentElement()) == null) { hackAroundEmptyNamespaceIssue = true; return hackAroundEmptyNamespaceIssue; } // create a copy of the dom so we // can modify it. d = copy(d); ns = tnsList.isEmpty() ? "" : tnsList.get(0); d.getDocumentElement().setAttribute("targetNamespace", ns); } if (hackAroundEmptyNamespaceIssue) { d = doEmptyNamespaceHack(d); } Node n = d.getDocumentElement().getFirstChild(); while (n != null) { if (n instanceof Element) { Element e = (Element)n; if ("import".equals(e.getLocalName())) { e.removeAttribute("schemaLocation"); } } n = n.getNextSibling(); } synchronized (d) { col.read(d, systemId); } return hackAroundEmptyNamespaceIssue; }
Example #19
Source File: JoseSessionTokenProvider.java From cxf with Apache License 2.0 | 5 votes |
private String protectStateString(String stateString) { JwsSignatureProvider jws = getInitializedSigProvider(); JweEncryptionProvider jwe = getInitializedEncryptionProvider(); if (jws == null && jwe == null) { throw new OAuthServiceException("Session token can not be created"); } if (jws != null) { stateString = JwsUtils.sign(jws, stateString, null); } if (jwe != null) { stateString = jwe.encrypt(StringUtils.toBytesUTF8(stateString), null); } return stateString; }
Example #20
Source File: ClientRegistrationService.java From cxf-fediz with Apache License 2.0 | 5 votes |
private void checkCSRFToken(String csrfToken) { // CSRF HttpServletRequest httpRequest = mc.getHttpServletRequest(); String savedToken = CSRFUtils.getCSRFToken(httpRequest, false); if (StringUtils.isEmpty(csrfToken) || StringUtils.isEmpty(savedToken) || !savedToken.equals(csrfToken)) { throw new InvalidRegistrationException("Invalid CSRF Token"); } }
Example #21
Source File: WSDLCorbaWriterImpl.java From cxf with Apache License 2.0 | 5 votes |
private void fixTypes(Definition wsdlDef) throws ParserConfigurationException { Types t = wsdlDef.getTypes(); if (t == null) { return; } List<ExtensibilityElement> l = CastUtils.cast(t.getExtensibilityElements()); if (l == null) { return; } for (ExtensibilityElement e : l) { if (e instanceof Schema) { Schema sc = (Schema)e; String pfx = wsdlDef.getPrefix(sc.getElementType().getNamespaceURI()); if (StringUtils.isEmpty(pfx)) { pfx = "xsd"; String ns = wsdlDef.getNamespace(pfx); int count = 1; while (!StringUtils.isEmpty(ns)) { pfx = "xsd" + count++; ns = wsdlDef.getNamespace(pfx); } wsdlDef.addNamespace(pfx, sc.getElementType().getNamespaceURI()); } if (sc.getElement() == null) { fixSchema(sc, pfx); } } } }
Example #22
Source File: Soap12FaultSoapPayloadConverter.java From syndesis with Apache License 2.0 | 5 votes |
private static String getCodeString(String prefix, String defaultPrefix, QName code) { String codePrefix; if (StringUtils.isEmpty(prefix)) { codePrefix = code.getPrefix(); if (StringUtils.isEmpty(codePrefix)) { codePrefix = defaultPrefix; } } else { codePrefix = prefix; } return codePrefix + ":" + code.getLocalPart(); }
Example #23
Source File: FaultBean.java From cxf with Apache License 2.0 | 5 votes |
public boolean faultBeanExists(final Class<?> exceptionClass) { String fb = getWebFaultBean(exceptionClass); if (!StringUtils.isEmpty(fb)) { try { return AnnotationUtil.loadClass(fb, exceptionClass.getClassLoader()) != null; } catch (Exception e) { return false; } } return false; }
Example #24
Source File: ResourceUtils.java From cxf with Apache License 2.0 | 5 votes |
private static UserOperation getOperationFromElement(Element e) { UserOperation op = new UserOperation(); op.setName(e.getAttribute("name")); op.setVerb(e.getAttribute("verb")); op.setPath(e.getAttribute("path")); op.setOneway(Boolean.parseBoolean(e.getAttribute("oneway"))); op.setConsumes(e.getAttribute("consumes")); op.setProduces(e.getAttribute("produces")); List<Element> paramEls = DOMUtils.findAllElementsByTagNameNS(e, "http://cxf.apache.org/jaxrs", "param"); List<Parameter> params = new ArrayList<>(paramEls.size()); for (int i = 0; i < paramEls.size(); i++) { Element paramEl = paramEls.get(i); Parameter p = new Parameter(paramEl.getAttribute("type"), i, paramEl.getAttribute("name")); p.setEncoded(Boolean.valueOf(paramEl.getAttribute("encoded"))); p.setDefaultValue(paramEl.getAttribute("defaultValue")); String pClass = paramEl.getAttribute("class"); if (!StringUtils.isEmpty(pClass)) { try { p.setJavaType(ClassLoaderUtils.loadClass(pClass, ResourceUtils.class)); } catch (Exception ex) { throw new RuntimeException(ex); } } params.add(p); } op.setParameters(params); return op; }
Example #25
Source File: JwsCompactProducer.java From cxf with Apache License 2.0 | 5 votes |
public String getSignedEncodedJws() { checkAlgorithm(); boolean noSignature = StringUtils.isEmpty(signature); if (noSignature && !isPlainText()) { throw new IllegalStateException("Signature is not available"); } return getUnsignedEncodedJws() + '.' + (noSignature ? "" : signature); }
Example #26
Source File: OutTransformWriter.java From cxf with Apache License 2.0 | 5 votes |
@Override public void writeNamespace(String prefix, String uri) throws XMLStreamException { if (StringUtils.isEmpty(prefix) || "xmlns".equals(prefix)) { writeDefaultNamespace(uri); return; } if (matchesDropped(true)) { return; } String value = nsMap.get(uri); if ((value != null && value.isEmpty()) || uri.equals(replaceNamespace)) { return; } uri = value != null ? value : uri; if (writtenUris.get(0).contains(uri) && (prefix.isEmpty() || prefix.equals(namespaceContext.getPrefix(uri)))) { return; } if (defaultNamespace != null && defaultNamespace.equals(uri)) { super.writeDefaultNamespace(uri); namespaceContext.addPrefix("", uri); } else { if (prefix.isEmpty()) { prefix = namespaceContext.findUniquePrefix(uri); } super.writeNamespace(prefix, uri); namespaceContext.addPrefix(prefix, uri); } writtenUris.get(0).add(uri); }
Example #27
Source File: SOAPBindingUtil.java From cxf with Apache License 2.0 | 5 votes |
public static String getCanonicalBindingStyle(Binding binding) { String bindingStyle = getBindingStyle(binding); if (!StringUtils.isEmpty(bindingStyle)) { return bindingStyle; } for (Object bobj : binding.getBindingOperations()) { BindingOperation bindingOp = (BindingOperation)bobj; String bopStyle = getSOAPOperationStyle(bindingOp); if (!StringUtils.isEmpty(bopStyle)) { return bopStyle; } } return ""; }
Example #28
Source File: JAXBEncoderDecoder.java From cxf with Apache License 2.0 | 5 votes |
private static Object updateSourceWithXSIType(Object source, final QName typeQName) { if (source instanceof XMLStreamReader && typeQName != null) { XMLStreamReader reader = (XMLStreamReader)source; String type = reader.getAttributeValue(Constants.URI_2001_SCHEMA_XSI, "type"); if (StringUtils.isEmpty(type)) { source = new AddXSITypeStreamReader(reader, typeQName); } } return source; }
Example #29
Source File: CustomizationParser.java From cxf with Apache License 2.0 | 5 votes |
private String resolveByCatalog(String url) { if (StringUtils.isEmpty(url)) { return null; } OASISCatalogManager catalogResolver = OASISCatalogManager.getCatalogManager(bus); try { return new OASISCatalogManagerHelper().resolve(catalogResolver, url, null); } catch (Exception e1) { Message msg = new Message("FAILED_RESOLVE_CATALOG", LOG, url); throw new ToolException(msg, e1); } }
Example #30
Source File: JAXBSchemaInitializer.java From cxf with Apache License 2.0 | 5 votes |
protected void addElement(XmlSchema schema, XmlSchemaSequence seq, JAXBBeanInfo beanInfo, QName name, boolean isArray, XmlElement xmlElementAnno) { XmlSchemaElement el = new XmlSchemaElement(schema, false); if (isArray) { el.setMinOccurs(0); el.setMaxOccurs(Long.MAX_VALUE); } else { if (xmlElementAnno == null) { el.setMinOccurs(0); el.setNillable(false); } else { el.setNillable(xmlElementAnno.nillable()); int minOccurs = xmlElementAnno.required() ? 1 : 0; el.setMinOccurs(minOccurs); } } if (beanInfo.isElement()) { QName ename = new QName(beanInfo.getElementNamespaceURI(null), beanInfo.getElementLocalName(null)); XmlSchemaElement el2 = schemas.getElementByQName(ename); el.setNillable(false); el.getRef().setTargetQName(el2.getQName()); } else { if (xmlElementAnno != null && !StringUtils.isEmpty(xmlElementAnno.name())) { el.setName(xmlElementAnno.name()); } else { el.setName(name.getLocalPart()); } Iterator<QName> itr = beanInfo.getTypeNames().iterator(); if (!itr.hasNext()) { return; } QName typeName = itr.next(); el.setSchemaTypeName(typeName); } seq.getItems().add(el); }