use of javax.xml.bind.UnmarshalException in project OpenAM by OpenRock.
the class SAXUnmarshallerHandlerImpl method handleEvent.
public void handleEvent(ValidationEvent event, boolean canRecover) throws SAXException {
ValidationEventHandler eventHandler;
try {
eventHandler = parent.getEventHandler();
} catch (JAXBException e) {
// impossible.
throw new JAXBAssertionError();
}
boolean recover = eventHandler.handleEvent(event);
// from the unmarshaller.getResult()
if (!recover)
aborted = true;
if (!canRecover || !recover)
throw new SAXException(new UnmarshalException(event.getMessage(), event.getLinkedException()));
}
use of javax.xml.bind.UnmarshalException in project cxf by apache.
the class ClientServerRPCLitTest method testComplexType.
@Test
public void testComplexType() throws Exception {
SOAPServiceRPCLit service = new SOAPServiceRPCLit();
assertNotNull(service);
GreeterRPCLit greeter = service.getPort(portName, GreeterRPCLit.class);
updateAddressPort(greeter, PORT);
MyComplexStruct in = new MyComplexStruct();
in.setElem1("elem1");
in.setElem2("elem2");
in.setElem3(45);
try {
((BindingProvider) greeter).getRequestContext().put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.TRUE);
MyComplexStruct out = greeter.sendReceiveData(in);
assertNotNull("no response received from service", out);
assertEquals(in.getElem1(), out.getElem1());
assertEquals(in.getElem2(), out.getElem2());
assertEquals(in.getElem3(), out.getElem3());
} catch (UndeclaredThrowableException ex) {
throw (Exception) ex.getCause();
}
try {
in.setElem2("invalid");
greeter.sendReceiveData(in);
} catch (SOAPFaultException f) {
assertTrue(f.getCause() instanceof UnmarshalException);
}
}
use of javax.xml.bind.UnmarshalException in project Payara by payara.
the class PipeHelper method authorize.
public void authorize(Packet request) throws Exception {
// SecurityContext constructor should set initiator to
// unathenticated if Subject is null or empty
Subject s = (Subject) request.invocationProperties.get(PipeConstants.CLIENT_SUBJECT);
if (s == null || (s.getPrincipals().isEmpty() && s.getPublicCredentials().isEmpty())) {
SecurityContext.setUnauthenticatedContext();
} else {
SecurityContext sC = new SecurityContext(s);
SecurityContext.setCurrent(sC);
}
if (isEjbEndpoint) {
if (invManager == null) {
throw new RuntimeException(localStrings.getLocalString("enterprise.webservice.noEjbInvocationManager", "Cannot validate request : invocation manager null for EJB WebService"));
}
ComponentInvocation inv = (ComponentInvocation) invManager.getCurrentInvocation();
// consumed
if (ejbDelegate != null) {
ejbDelegate.setSOAPMessage(request.getMessage(), inv);
}
Exception ie;
Method m = null;
if (seiModel != null) {
JavaMethod jm = request.getMessage().getMethod(seiModel);
m = (jm != null) ? jm.getMethod() : null;
} else {
// WebServiceProvider
WebServiceEndpoint endpoint = (WebServiceEndpoint) map.get(PipeConstants.SERVICE_ENDPOINT);
EjbDescriptor ejbDescriptor = endpoint.getEjbComponentImpl();
if (ejbDescriptor != null) {
final String ejbImplClassName = ejbDescriptor.getEjbImplClassName();
if (ejbImplClassName != null) {
try {
m = (Method) AppservAccessController.doPrivileged(new PrivilegedExceptionAction() {
@Override
public Object run() throws Exception {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
Class clazz = Class.forName(ejbImplClassName, true, loader);
return clazz.getMethod("invoke", new Class[] { Object.class });
}
});
} catch (PrivilegedActionException pae) {
throw new RuntimeException(pae.getException());
}
}
}
}
if (m != null) {
if (ejbDelegate != null) {
try {
if (!ejbDelegate.authorize(inv, m)) {
throw new Exception(localStrings.getLocalString("enterprise.webservice.methodNotAuth", "Client not authorized for invocation of {0}", new Object[] { m }));
}
} catch (UnmarshalException e) {
String errorMsg = localStrings.getLocalString("enterprise.webservice.errorUnMarshalMethod", "Error unmarshalling method for ejb {0}", new Object[] { ejbName() });
ie = new UnmarshalException(errorMsg);
ie.initCause(e);
throw ie;
} catch (Exception e) {
ie = new Exception(localStrings.getLocalString("enterprise.webservice.methodNotAuth", "Client not authorized for invocation of {0}", new Object[] { m }));
ie.initCause(e);
throw ie;
}
}
}
}
}
use of javax.xml.bind.UnmarshalException in project BIMserver by opensourceBIM.
the class VersionChecker method getOnlineVersion.
public synchronized SVersion getOnlineVersion() {
if (lastCheck == null || lastCheck.before(getReferenceDate())) {
LOGGER.info("Fetching online version info");
try {
URL url = new URL("http://www.bimserver.org/version/versionv2.xml");
JAXBContext jaxbContext = JAXBContext.newInstance(SVersion.class);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
onlineVersion = (SVersion) unmarshaller.unmarshal(url);
lastCheck = new GregorianCalendar();
return onlineVersion;
} catch (UnmarshalException e) {
LOGGER.error("", e);
} catch (MalformedURLException e) {
LOGGER.error("", e);
} catch (JAXBException e) {
LOGGER.error("", e);
}
if (onlineVersion == null) {
onlineVersion = new SVersion();
onlineVersion.setDownloadUrl("unknown");
onlineVersion.setMajor(-1);
onlineVersion.setMinor(-1);
onlineVersion.setRevision(-1);
onlineVersion.setSupportEmail("unknown");
onlineVersion.setSupportUrl("unknown");
onlineVersion.setDate(new Date(0));
lastCheck = new GregorianCalendar();
}
}
return onlineVersion;
}
use of javax.xml.bind.UnmarshalException in project phoenix by apache.
the class XMLConfigParserTest method testDTDInScenario.
@Test
public void testDTDInScenario() throws Exception {
URL scenarioUrl = XMLConfigParserTest.class.getResource("/scenario/malicious_scenario_with_dtd.xml");
assertNotNull(scenarioUrl);
Path p = Paths.get(scenarioUrl.toURI());
try {
XMLConfigParser.readDataModel(p);
fail("The scenario should have failed to parse because it contains a DTD");
} catch (UnmarshalException e) {
// If we don't parse the DTD, the variable 'name' won't be defined in the XML
LOG.warn("Caught expected exception", e);
Throwable cause = e.getLinkedException();
assertTrue("Cause was a " + cause.getClass(), cause instanceof XMLStreamException);
}
}
Aggregations