use of javax.xml.stream.FactoryConfigurationError in project cloudstack by apache.
the class SAML2LoginAPIAuthenticatorCmd method processSAMLResponse.
public Response processSAMLResponse(String responseMessage) {
Response responseObject = null;
try {
DefaultBootstrap.bootstrap();
responseObject = SAMLUtils.decodeSAMLResponse(responseMessage);
} catch (ConfigurationException | FactoryConfigurationError | ParserConfigurationException | SAXException | IOException | UnmarshallingException e) {
s_logger.error("SAMLResponse processing error: " + e.getMessage());
}
return responseObject;
}
use of javax.xml.stream.FactoryConfigurationError in project cloudstack by apache.
the class SAML2AuthManagerImpl method setup.
private boolean setup() {
if (!initSP()) {
s_logger.error("SAML Plugin failed to initialize, please fix the configuration and restart management server");
return false;
}
_timer = new Timer();
final HttpClient client = new HttpClient();
final String idpMetaDataUrl = getSAMLIdentityProviderMetadataURL();
if (SAMLTimeout.value() != null && SAMLTimeout.value() > SAMLPluginConstants.SAML_REFRESH_INTERVAL) {
_refreshInterval = SAMLTimeout.value();
}
try {
DefaultBootstrap.bootstrap();
if (idpMetaDataUrl.startsWith("http")) {
_idpMetaDataProvider = new HTTPMetadataProvider(_timer, client, idpMetaDataUrl);
} else {
File metadataFile = PropertiesUtil.findConfigFile(idpMetaDataUrl);
if (metadataFile == null) {
s_logger.error("Provided Metadata is not a URL, Unable to locate metadata file from local path: " + idpMetaDataUrl);
return false;
} else {
s_logger.debug("Provided Metadata is not a URL, trying to read metadata file from local path: " + metadataFile.getAbsolutePath());
_idpMetaDataProvider = new FilesystemMetadataProvider(_timer, metadataFile);
}
}
_idpMetaDataProvider.setRequireValidMetadata(true);
_idpMetaDataProvider.setParserPool(new BasicParserPool());
_idpMetaDataProvider.initialize();
_timer.scheduleAtFixedRate(new MetadataRefreshTask(), 0, _refreshInterval * 1000);
} catch (MetadataProviderException e) {
s_logger.error("Unable to read SAML2 IDP MetaData URL, error:" + e.getMessage());
s_logger.error("SAML2 Authentication may be unavailable");
return false;
} catch (ConfigurationException | FactoryConfigurationError e) {
s_logger.error("OpenSAML bootstrapping failed: error: " + e.getMessage());
return false;
} catch (NullPointerException e) {
s_logger.error("Unable to setup SAML Auth Plugin due to NullPointerException" + " please check the SAML global settings: " + e.getMessage());
return false;
}
return true;
}
use of javax.xml.stream.FactoryConfigurationError in project openolat by klemens.
the class CopyAndConvertVisitor method convertXmlFile.
/**
* Convert the XML files, assessmentItem or assessmentTest
*
* @param inputFile
* @param outputFile
*/
public boolean convertXmlFile(Path inputFile, Path outputFile) {
try {
boolean validated = true;
QTI21Infos fileInfos = scanFile(inputFile);
// inherit from test if needed
if (fileInfos.getEditor() == null && infos.getEditor() != null) {
fileInfos.setEditor(infos.getEditor());
fileInfos.setVersion(infos.getVersion());
}
if (onyx38Family(fileInfos)) {
validated = convertXmlFile(inputFile, outputFile, fileInfos.getType(), new HandlerProvider() {
@Override
public DefaultHandler2 create(XMLStreamWriter xtw) {
return new Onyx38ToQtiWorksHandler(xtw);
}
});
} else if (onyxWebFamily(fileInfos)) {
validated = convertXmlFile(inputFile, outputFile, fileInfos.getType(), new HandlerProvider() {
@Override
public DefaultHandler2 create(XMLStreamWriter xtw) {
return new OnyxToQtiWorksHandler(xtw, infos);
}
});
if (validated && fileInfos.getType() == InputType.assessmentItem) {
// check templateVariables
checkAssessmentItem(outputFile);
}
} else {
Files.copy(inputFile, outputFile, StandardCopyOption.REPLACE_EXISTING);
}
return validated;
} catch (IOException | FactoryConfigurationError e) {
log.error("", e);
return false;
}
}
use of javax.xml.stream.FactoryConfigurationError in project OpenOLAT by OpenOLAT.
the class QTI12To21Converter method blockedHtml.
/**
* Make sure the HTML content is in block elements. Simple text
* are returned as is.
*
* @param text
* @return
*/
protected final String blockedHtml(String text) {
if (StringHelper.containsNonWhitespace(text)) {
collectMaterial(text);
if (StringHelper.isHtml(text)) {
String trimmedText = text.trim();
trimmedText = trimmedText.replace("<hr />", "<hr></hr>");
try {
Writer out = new StringWriter();
XMLOutputFactory xof = XMLOutputFactory.newInstance();
XMLStreamWriter xtw = xof.createXMLStreamWriter(out);
SAXParser parser = new SAXParser();
QTI12To21HtmlHandler handler = new QTI12To21HtmlHandler(xtw);
parser.setContentHandler(handler);
parser.parse(new InputSource(new StringReader(trimmedText)));
String blockedHtml = out.toString();
text = blockedHtml.replace("<start>", "").replace("</start>", "");
materialMappings.putAll(handler.getMaterialsMapping());
} catch (FactoryConfigurationError | XMLStreamException | SAXException | IOException e) {
log.error("", e);
}
} else {
text = StringEscapeUtils.unescapeHtml(text);
}
}
return text;
}
use of javax.xml.stream.FactoryConfigurationError in project libSBOLj by SynBioDex.
the class SBOLReader method readRDF.
/**
* @param reader
* @return
* @throws SBOLValidationException if either of the following SBOL validation rules was violated: 10105, 10201.
*/
private static DocumentRoot<QName> readRDF(Reader reader) throws SBOLValidationException {
try {
XMLStreamReader xmlReader = XMLInputFactory.newInstance().createXMLStreamReader(reader);
RdfIo rdfIo = new RdfIo();
return rdfIo.createIoReader(xmlReader).read();
} catch (FactoryConfigurationError e) {
throw new SBOLValidationException("sbol-10105", e);
} catch (XMLStreamException e) {
throw new SBOLValidationException("sbol-10105", e);
} catch (CoreIoException e) {
throw new SBOLValidationException("sbol-10105", e);
} catch (ClassCastException e) {
if (e.getMessage().contains("IdentifiableDocument")) {
throw new SBOLValidationException("sbol-10201", e);
}
throw new SBOLValidationException("sbol-10105", e);
} catch (IllegalArgumentException e) {
if (e.getCause() instanceof URISyntaxException) {
throw new SBOLValidationException("sbol-10201", e);
}
throw new SBOLValidationException("sbol-10105", e);
}
}
Aggregations