List of usage examples for javax.xml.namespace QName QName
public QName(String localPart)
QName
constructor specifying the local part.
If the local part is null
an IllegalArgumentException
is thrown.
From source file:gov.nih.nci.cdmsconnector.test.EnrollPatientTest.java
public void testEnrollPatientAPI() throws IOException, Exception { RegisterSubjectRequest request = getPopulatedEnrollPatientRequest(); String beansFilePath = System.getProperty("catalina.home") + "/conf/c3d/applicationContext.xml"; ApplicationContext ctx = new FileSystemXmlApplicationContext(beansFilePath); ClinicalConnectorImpl impl = (ClinicalConnectorImpl) ctx.getBean("c3DGridService"); RegisterSubjectResponse response = impl.registerSubject(request); StringWriter writer = new StringWriter(); Utils.serializeObject(response, new QName("EnrollPatientResponse"), writer); responseStr = writer.getBuffer().toString(); log.debug(responseStr);/* ww w . ja v a2s .co m*/ }
From source file:org.apache.servicemix.jms.JmsProviderEndpointTest.java
public void testSendSimple() throws Exception { container.activateComponent(createEndpoint(), "servicemix-jms"); InOnly me = client.createInOnlyExchange(); NormalizedMessage inMessage = me.getInMessage(); inMessage.setProperty(MSG_PROPERTY, "Test-Value"); inMessage.setProperty(MSG_PROPERTY_BLACKLISTED, "Unwanted value"); inMessage.setContent(new StringSource("<hello>world</hello>")); me.setService(new QName("jms")); client.sendSync(me);//ww w.j a v a 2s .co m assertEquals(ExchangeStatus.DONE, me.getStatus()); Message msg = jmsTemplate.receive("destination"); assertNotNull("Expected property not found", msg.getStringProperty(MSG_PROPERTY)); assertNull("Found blacklisted property", msg.getStringProperty(MSG_PROPERTY_BLACKLISTED)); assertNotNull(msg); }
From source file:integration.report.ReportIT.java
@PostConstruct public void initTests() throws Exception { /* Check and/or add the default Identify response */ if (!defaultIdentityResponseExists()) { IdentifyType id = oaiFactory.createIdentifyType(); id.setRepositoryName("Fedora 4 Test Instance"); id.setBaseURL(serverAddress);// w ww .ja v a 2 s . c om HttpPost post = new HttpPost(serverAddress); StringWriter data = new StringWriter(); marshaller.marshal(new JAXBElement<IdentifyType>(new QName("Identify"), IdentifyType.class, id), data); post.setEntity(new StringEntity(data.toString())); post.addHeader("Content-Type", "application/octet-stream"); post.addHeader("Slug", "oai_identify"); try { HttpResponse resp = this.client.execute(post); assertEquals(201, resp.getStatusLine().getStatusCode()); } finally { post.releaseConnection(); } } }
From source file:org.apache.axis2.transport.nhttp.HttpCoreNIOSSLListener.java
/** * Create the SSLContext to be used by this listener * @param transportIn the Axis2 transport description * @return the SSLContext to be used/*from w w w.j a v a 2 s. c o m*/ */ protected SSLContext getSSLContext(TransportInDescription transportIn) throws AxisFault { KeyManager[] keymanagers = null; TrustManager[] trustManagers = null; Parameter keyParam = transportIn.getParameter("keystore"); Parameter trustParam = transportIn.getParameter("truststore"); if (keyParam != null) { OMElement ksEle = keyParam.getParameterElement().getFirstElement(); String location = ksEle.getFirstChildWithName(new QName("Location")).getText(); String type = ksEle.getFirstChildWithName(new QName("Type")).getText(); String storePassword = ksEle.getFirstChildWithName(new QName("Password")).getText(); String keyPassword = ksEle.getFirstChildWithName(new QName("KeyPassword")).getText(); try { KeyStore keyStore = KeyStore.getInstance(type); URL url = getClass().getClassLoader().getResource(location); log.debug("Loading Key Store from URL : " + url); keyStore.load(url.openStream(), storePassword.toCharArray()); KeyManagerFactory kmfactory = KeyManagerFactory .getInstance(KeyManagerFactory.getDefaultAlgorithm()); kmfactory.init(keyStore, keyPassword.toCharArray()); keymanagers = kmfactory.getKeyManagers(); } catch (GeneralSecurityException gse) { log.error("Error loading Key store : " + location, gse); throw new AxisFault("Error loading Key store : " + location, gse); } catch (IOException ioe) { log.error("Error opening Key store : " + location, ioe); throw new AxisFault("Error opening Key store : " + location, ioe); } } if (trustParam != null) { OMElement tsEle = trustParam.getParameterElement().getFirstElement(); String location = tsEle.getFirstChildWithName(new QName("Location")).getText(); String type = tsEle.getFirstChildWithName(new QName("Type")).getText(); String storePassword = tsEle.getFirstChildWithName(new QName("Password")).getText(); try { KeyStore trustStore = KeyStore.getInstance(type); URL url = getClass().getClassLoader().getResource(location); log.debug("Loading Trust Key Store from URL : " + url); trustStore.load(url.openStream(), storePassword.toCharArray()); TrustManagerFactory trustManagerfactory = TrustManagerFactory .getInstance(TrustManagerFactory.getDefaultAlgorithm()); trustManagerfactory.init(trustStore); trustManagers = trustManagerfactory.getTrustManagers(); } catch (GeneralSecurityException gse) { log.error("Error loading Key store : " + location, gse); throw new AxisFault("Error loading Key store : " + location, gse); } catch (IOException ioe) { log.error("Error opening Key store : " + location, ioe); throw new AxisFault("Error opening Key store : " + location, ioe); } } try { SSLContext sslcontext = SSLContext.getInstance("TLS"); sslcontext.init(keymanagers, trustManagers, null); return sslcontext; } catch (GeneralSecurityException gse) { log.error("Unable to create SSL context with the given configuration", gse); throw new AxisFault("Unable to create SSL context with the given configuration", gse); } }
From source file:org.jasig.portlet.blackboardvcportlet.dao.ws.impl.MultimediaWSDaoTest.java
@Override @Test//from w w w. j ava2 s . c o m public void getRepositoryMultimediasTest() throws Exception { //return empty set like it is expecting when(sasWebServiceOperations.marshalSendAndReceiveToSAS(any(String.class), any(Object.class))).thenReturn( new JAXBElement<BlackboardMultimediaResponseCollection>(new QName("http://sas.elluminate.com"), BlackboardMultimediaResponseCollection.class, new BlackboardMultimediaResponseCollection())); super.getRepositoryMultimediasTest(); }
From source file:com.xiongyingqi.util.xml.XMLEventStreamWriter.java
@Override public void writeStartElement(String localName) throws XMLStreamException { writeStartElement(eventFactory.createStartElement(new QName(localName), null, null)); }
From source file:com.evolveum.midpoint.prism.path.ItemPath.java
private QName stringToQName(String name) { Validate.notNull(name, "name"); if ("..".equals(name)) { return PrismConstants.T_PARENT; } else if ("@".equals(name)) { return PrismConstants.T_OBJECT_REFERENCE; } else if ("#".equals(name)) { return PrismConstants.T_ID; } else {// ww w. j a v a2s . c o m return new QName(name); } }
From source file:org.wso2.carbon.registry.notes.test.PublisherNotesTestCase.java
@Test(groups = { "wso2.greg" }, description = "create SOAP Service using GenericArtifact") public void createSOAPService() throws GovernanceException { GenericArtifact artifact = artifactManager.newGovernanceArtifact(new QName("SOAPService1")); artifact.setAttribute("overview_name", "SOAPService1"); artifact.setAttribute("overview_version", "4.5.0"); artifact.setAttribute("overview_description", "Description"); artifactManager.addGenericArtifact(artifact); GenericArtifact receivedArtifact = artifactManager.getGenericArtifact(artifact.getId()); assertEquals(artifact.getAttribute("overview_name"), receivedArtifact.getAttribute("overview_name"), " Service name must be equal"); artifactManager.removeGenericArtifact(artifact.getId()); }
From source file:ch.simuonline.idh.attribute.resolver.spring.dc.aq.impl.AttributeQueryDataConnectorParser.java
/** {@inheritDoc} */ @Override//ww w. ja va 2 s . c o m protected void doV2Parse(@Nonnull final Element config, @Nonnull final ParserContext parserContext, @Nonnull final BeanDefinitionBuilder builder) { log.debug("{} Parsing v2 configuration {}", getLogPrefix(), config); final String targetResolvingStrategy = AttributeSupport.getAttributeValue(config, new QName("targetDeterminationStrategy")); Constraint.isNotNull(StringSupport.trimOrNull(targetResolvingStrategy), "The targetDeterminationStrategy can not be null or empty, please adjust entityID from the AQ DataConnector"); if (targetResolvingStrategy.equals("mysql")) { // Constructor is MySQLTargetResolvingStrategy(String url, String username, String password), adding arguments in this order: final BeanDefinitionBuilder mysqlTargetResolvingStrategy = BeanDefinitionBuilder .genericBeanDefinition(MySQLTargetDeterminationStrategy.class); final String dbURL = AttributeSupport.getAttributeValue(config, new QName("dbURL")); Constraint.isNotNull(StringSupport.trimOrNull(dbURL), "The dbURL attribute is required if the targetResolvingStrategy is mysql, please adjust entityID from the AQ DataConnector"); mysqlTargetResolvingStrategy.addConstructorArgValue(dbURL); final String dbUsername = AttributeSupport.getAttributeValue(config, new QName("dbUsername")); Constraint.isNotNull(StringSupport.trimOrNull(dbUsername), "The dbUsername attribute is required if the targetResolvingStrategy is mysql, please adjust entityID from the AQ DataConnector"); mysqlTargetResolvingStrategy.addConstructorArgValue(dbUsername); final String dbPassword = AttributeSupport.getAttributeValue(config, new QName("dbPassword")); Constraint.isNotNull(StringSupport.trimOrNull(dbPassword), "The dbPassword attribute is required if the targetResolvingStrategy is mysql, please adjust entityID from the AQ DataConnector"); mysqlTargetResolvingStrategy.addConstructorArgValue(dbPassword); builder.addPropertyValue("targetResolvingStrategy", mysqlTargetResolvingStrategy.getBeanDefinition()); } else if (targetResolvingStrategy.equals("ldap")) { final BeanDefinitionBuilder ldapTargetResolvingStrategy = BeanDefinitionBuilder .genericBeanDefinition(LDAPTargetDeterminationStrategy.class); final String sourceAttributeID = AttributeSupport.getAttributeValue(config, new QName("sourceAttributeID")); Constraint.isNotNull(StringSupport.trimOrNull(sourceAttributeID), "The sourceAttributeID attribute is required if the targetResolvingStrategy is ldap, please adjust entityID from the AQ DataConnector"); ldapTargetResolvingStrategy.addConstructorArgValue(sourceAttributeID); final List<Element> dependencyElements = ElementSupport.getChildElements(config, ResolverPluginDependencyParser.ELEMENT_NAME); ldapTargetResolvingStrategy.addPropertyValue("dependencies", SpringSupport.parseCustomElements(dependencyElements, parserContext)); final String connectorID = AttributeSupport.getAttributeValue(config, new QName("id")); Constraint.isNotNull(StringSupport.trimOrNull(sourceAttributeID), "The connectorID can not be empty, please adjust it for the AQ DataConnector"); ldapTargetResolvingStrategy.addConstructorArgValue(connectorID); builder.addPropertyValue("targetResolvingStrategy", ldapTargetResolvingStrategy.getBeanDefinition()); } else { log.error("{} Unsupported targetResolvingStrategy: {}. Change it to mysql or ldap! ", getLogPrefix(), targetResolvingStrategy); } final BeanDefinitionBuilder attributeQueryBuilder = BeanDefinitionBuilder .genericBeanDefinition(AttributeQueryBuilder.class); // Parse value of the entityID attribute final String issuer = AttributeSupport.getAttributeValue(config, new QName("entityID")); Constraint.isNotNull(StringSupport.trimOrNull(issuer), "The entityID of the Issuer can not be empty, please adjust entityID from the AQ DataConnector"); attributeQueryBuilder.addConstructorArgValue(issuer); // parsing of the defined AQAttributes for the attribute query final List<Element> children = ElementSupport.getChildElements(config, ATTRIBUTE_ELEMENT_NAME); final List<BeanDefinition> attributes = new ManagedList<>(children.size()); for (final Element child : children) { final String name = AttributeSupport.getAttributeValue(child, new QName("name")); final String friendlyName = AttributeSupport.getAttributeValue(child, new QName("friendlyName")); final BeanDefinitionBuilder attribute = BeanDefinitionBuilder.genericBeanDefinition(AQAttribute.class); attribute.addConstructorArgValue(name); attribute.addConstructorArgValue(friendlyName); log.debug("{} Added one AQAttribute to the resolving List. Friendly Name {}, Name {}", getLogPrefix(), friendlyName, name); attributes.add(attribute.getBeanDefinition()); } attributeQueryBuilder.addConstructorArgValue(attributes); builder.addPropertyValue("attributeQueryBuilder", attributeQueryBuilder.getBeanDefinition()); final BeanDefinitionBuilder keyManager = BeanDefinitionBuilder .genericBeanDefinition(AttributeQueryKeyManager.class); // parse the keyLocaton attribute from the AQ DataCOnnector final String keyLocation = AttributeSupport.getAttributeValue(config, new QName("keyLocation")); Constraint.isNotNull(StringSupport.trimOrNull(keyLocation), "Key location can not be empty, please adjust keyLocation from the AQ DataConnector"); // parse the certLocaton attribute from the AQ DataCOnnector final String certLocation = AttributeSupport.getAttributeValue(config, new QName("certLocation")); Constraint.isNotNull(StringSupport.trimOrNull(certLocation), "Certificate location can not be empty, please adjust certLocation from the AQ DataConnector"); keyManager.addConstructorArgValue(getPrivateKey(keyLocation)); keyManager.addConstructorArgValue(getCertificate(certLocation)); builder.addPropertyValue("attributeQueryKeyManager", keyManager.getBeanDefinition()); // if the asertionSigned attribute is true, set the value to true final String signatureRequired = AttributeSupport.getAttributeValue(config, new QName("assertionSigned")); if (signatureRequired != null && signatureRequired.equals("true")) { builder.addPropertyValue("signatureRequired", Boolean.TRUE); } // if the requestedAttributesRequired attribute is true, set the value to true final String requireMetadataAttributes = AttributeSupport.getAttributeValue(config, new QName("requestedAttributesRequired")); if (requireMetadataAttributes != null && requireMetadataAttributes.equals("true")) { builder.addPropertyValue("requireMetadataAttributes", Boolean.TRUE); } builder.setInitMethodName("initialize"); builder.setDestroyMethodName("destroy"); }
From source file:de.drv.dsrv.spoc.web.webservice.spring.SpocEndpointExceptionResolver.java
@Override protected boolean resolveExceptionInternal(final MessageContext ctx, final Object endpoint, final Exception exception) { LOG.error("Behandlung von Exception: ", exception); if (!(ctx.getResponse() instanceof SoapMessage)) { LOG.error("Aufruf mit anderer Response als SoapMessage: " + ctx.getResponse()); throw new IllegalArgumentException("SpocEndpointExceptionResolver benoetigt eine SoapMessage"); }/*from w w w . j ava 2 s. com*/ final SoapBody body = ((SoapMessage) ctx.getResponse()).getSoapBody(); final SoapFault fault = generateSoapFault(exception, body); final SoapFaultDetail faultDetail = fault.addFaultDetail(); try { final ExtraErrorType extraErrorType = this.extraExceptionHelper .generateExtraErrorFromException(exception); this.extraJaxbMarshaller.marshalExtraError(extraErrorType, faultDetail.getResult()); } catch (final Exception e) { LOG.error("Exception beim Marshalling von ExtraError.", e); faultDetail .addFaultDetailElement(new QName( this.messages.getMessage(Messages.ERROR_NON_EXTRA_ELEMENT_NAME, null, DEFAULT_LOCALE))) .addText(this.messages.getMessage(Messages.ERROR_NON_EXTRA_TEXT, null, DEFAULT_LOCALE)); } return true; }