use of java.util.ArrayList in project camel by apache.
the class PGPDataFormatUtil method findPublicKeys.
public static List<PGPPublicKey> findPublicKeys(List<String> useridParts, boolean forEncryption, PGPPublicKeyRingCollection pgpPublicKeyringCollection) {
List<PGPPublicKey> result = new ArrayList<PGPPublicKey>(useridParts.size());
for (Iterator<PGPPublicKeyRing> keyRingIter = pgpPublicKeyringCollection.getKeyRings(); keyRingIter.hasNext(); ) {
PGPPublicKeyRing keyRing = keyRingIter.next();
PGPPublicKey primaryKey = keyRing.getPublicKey();
String[] foundKeyUserIdForUserIdPart = findFirstKeyUserIdContainingOneOfTheParts(useridParts, primaryKey);
if (foundKeyUserIdForUserIdPart == null) {
LOG.debug("No User ID found in primary key with key ID {} containing one of the parts {}", primaryKey.getKeyID(), useridParts);
continue;
}
LOG.debug("User ID {} found in primary key with key ID {} containing one of the parts {}", new Object[] { foundKeyUserIdForUserIdPart[0], primaryKey.getKeyID(), useridParts });
// add adequate keys to the result
for (Iterator<PGPPublicKey> keyIter = keyRing.getPublicKeys(); keyIter.hasNext(); ) {
PGPPublicKey key = keyIter.next();
if (forEncryption) {
if (isEncryptionKey(key)) {
LOG.debug("Public encryption key with key user ID {} and key ID {} added to the encryption keys", foundKeyUserIdForUserIdPart[0], Long.toString(key.getKeyID()));
result.add(key);
}
} else if (!forEncryption && isSignatureKey(key)) {
// not used!
result.add(key);
LOG.debug("Public key with key user ID {} and key ID {} added to the signing keys", foundKeyUserIdForUserIdPart[0], Long.toString(key.getKeyID()));
}
}
}
return result;
}
use of java.util.ArrayList in project camel by apache.
the class CxfEndpoint method setupHandlers.
protected void setupHandlers(ClientFactoryBean factoryBean, Client client) throws Exception {
if (factoryBean instanceof JaxWsClientFactoryBean && handlers != null) {
AnnotationHandlerChainBuilder builder = new AnnotationHandlerChainBuilder();
Method m = factoryBean.getClass().getMethod("getServiceFactory");
JaxWsServiceFactoryBean sf = (JaxWsServiceFactoryBean) m.invoke(factoryBean);
@SuppressWarnings("rawtypes") List<Handler> chain = new ArrayList<Handler>(handlers);
chain.addAll(builder.buildHandlerChainFromClass(sf.getServiceClass(), sf.getEndpointInfo().getName(), sf.getServiceQName(), factoryBean.getBindingId()));
if (!chain.isEmpty()) {
ResourceManager resourceManager = getBus().getExtension(ResourceManager.class);
List<ResourceResolver> resolvers = resourceManager.getResourceResolvers();
resourceManager = new DefaultResourceManager(resolvers);
resourceManager.addResourceResolver(new WebServiceContextResourceResolver());
ResourceInjector injector = new ResourceInjector(resourceManager);
for (Handler<?> h : chain) {
if (Proxy.isProxyClass(h.getClass()) && getServiceClass() != null) {
injector.inject(h, getServiceClass());
injector.construct(h, getServiceClass());
} else {
injector.inject(h);
injector.construct(h);
}
}
}
((JaxWsEndpointImpl) client.getEndpoint()).getJaxwsBinding().setHandlerChain(chain);
}
}
use of java.util.ArrayList in project camel by apache.
the class DefaultCxfBinding method getPayloadBodyElements.
protected static List<Source> getPayloadBodyElements(Message message, Map<String, String> nsMap) {
// take the namespace attribute from soap envelop
Map<String, String> bodyNC = CastUtils.cast((Map<?, ?>) message.get("soap.body.ns.context"));
if (bodyNC != null) {
// if there is no Node and the addNamespaceContext option is enabled, this map is available
nsMap.putAll(bodyNC);
} else {
Document soapEnv = (Document) message.getContent(Node.class);
if (soapEnv != null) {
NamedNodeMap attrs = soapEnv.getFirstChild().getAttributes();
for (int i = 0; i < attrs.getLength(); i++) {
Node node = attrs.item(i);
if (!node.getNodeValue().equals(Soap11.SOAP_NAMESPACE) && !node.getNodeValue().equals(Soap12.SOAP_NAMESPACE)) {
nsMap.put(node.getLocalName(), node.getNodeValue());
}
}
}
}
MessageContentsList inObjects = MessageContentsList.getContentsList(message);
if (inObjects == null) {
return new ArrayList<Source>(0);
}
org.apache.cxf.message.Exchange exchange = message.getExchange();
BindingOperationInfo boi = exchange.getBindingOperationInfo();
OperationInfo op = boi.getOperationInfo();
if (boi.isUnwrapped()) {
op = boi.getWrappedOperation().getOperationInfo();
}
List<MessagePartInfo> partInfos = null;
boolean client = Boolean.TRUE.equals(message.get(Message.REQUESTOR_ROLE));
if (client) {
// it is a response
partInfos = op.getOutput().getMessageParts();
} else {
// it is a request
partInfos = op.getInput().getMessageParts();
}
List<Source> answer = new ArrayList<Source>();
for (MessagePartInfo partInfo : partInfos) {
if (!inObjects.hasValue(partInfo)) {
continue;
}
Object part = inObjects.get(partInfo);
if (part instanceof Holder) {
part = ((Holder<?>) part).value;
}
if (part instanceof Source) {
Element element = null;
if (part instanceof DOMSource) {
element = getFirstElement(((DOMSource) part).getNode());
}
if (element != null) {
addNamespace(element, nsMap);
answer.add(new DOMSource(element));
} else {
answer.add((Source) part);
}
if (LOG.isTraceEnabled()) {
LOG.trace("Extract body element {}", element == null ? "null" : getXMLString(element));
}
} else if (part instanceof Element) {
addNamespace((Element) part, nsMap);
answer.add(new DOMSource((Element) part));
} else {
if (LOG.isDebugEnabled()) {
LOG.debug("Unhandled part type '{}'", part.getClass());
}
}
}
return answer;
}
use of java.util.ArrayList in project camel by apache.
the class ConverterTest method testFallbackConverter.
@Test
public void testFallbackConverter() throws Exception {
CamelContext context = new DefaultCamelContext();
Exchange exchange = new DefaultExchange(context);
MessageContentsList list = new MessageContentsList();
NodeListWrapper nl = new NodeListWrapper(new ArrayList<Element>());
list.add(nl);
exchange.getIn().setBody(list);
Node node = exchange.getIn().getBody(Node.class);
assertNull(node);
File file = new File("src/test/resources/org/apache/camel/component/cxf/converter/test.xml");
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document document = documentBuilder.parse(file);
document.getDocumentElement().normalize();
List<Element> elements = new ArrayList<Element>();
elements.add(document.getDocumentElement());
nl = new NodeListWrapper(elements);
list.clear();
list.add(nl);
exchange.getIn().setBody(list);
node = exchange.getIn().getBody(Node.class);
assertNotNull(node);
}
use of java.util.ArrayList in project camel by apache.
the class CxfPayloadConverterTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
File file = new File("src/test/resources/org/apache/camel/component/cxf/converter/test.xml");
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
document = documentBuilder.parse(file);
document.getDocumentElement().normalize();
List<Source> body = new ArrayList<Source>();
body.add(new DOMSource(document.getDocumentElement()));
List<Source> staxbody = new ArrayList<Source>();
staxbody.add(new StAXSource(StaxUtils.createXMLStreamReader(new FileInputStream(file), "utf-8")));
payload = new CxfPayload<String[]>(new ArrayList<String[]>(), body, null);
emptyPayload = new CxfPayload<String[]>(new ArrayList<String[]>(), new ArrayList<Source>(), null);
staxpayload = new CxfPayload<String[]>(new ArrayList<String[]>(), staxbody, null);
inputStream = new FileInputStream(file);
}
Aggregations