use of javax.xml.stream.events.Attribute in project teiid by teiid.
the class XMLEventStreamReader method initAttributes.
private void initAttributes() {
if (!event.isStartElement()) {
throw new IllegalStateException();
}
if (event != attributesEvent) {
attributesEvent = event;
attributesList = new ArrayList<>();
Iterator attributes = event.asStartElement().getAttributes();
while (attributes.hasNext()) {
Attribute attribute = (Attribute) attributes.next();
attributesList.add(attribute);
}
}
}
use of javax.xml.stream.events.Attribute in project santuario-java by apache.
the class XMLSignatureOutputProcessor method processEvent.
@Override
public void processEvent(XMLSecEvent xmlSecEvent, OutputProcessorChain outputProcessorChain) throws XMLStreamException, XMLSecurityException {
if (xmlSecEvent.getEventType() == XMLStreamConstants.START_ELEMENT) {
XMLSecStartElement xmlSecStartElement = xmlSecEvent.asStartElement();
// avoid double signature when child elements matches too
if (getActiveInternalSignatureOutputProcessor() == null) {
SecurePart securePart = securePartMatches(xmlSecStartElement, outputProcessorChain, XMLSecurityConstants.SIGNATURE_PARTS);
if (securePart != null) {
LOG.debug("Matched securePart for signature");
InternalSignatureOutputProcessor internalSignatureOutputProcessor = null;
SignaturePartDef signaturePartDef = new SignaturePartDef();
signaturePartDef.setSecurePart(securePart);
signaturePartDef.setTransforms(securePart.getTransforms());
if (signaturePartDef.getTransforms() == null) {
signaturePartDef.setTransforms(new String[] { XMLSecurityConstants.NS_C14N_EXCL_OMIT_COMMENTS });
}
signaturePartDef.setExcludeVisibleC14Nprefixes(true);
signaturePartDef.setDigestAlgo(securePart.getDigestMethod());
if (signaturePartDef.getDigestAlgo() == null) {
signaturePartDef.setDigestAlgo(getSecurityProperties().getSignatureDigestAlgorithm());
}
if (securityProperties.isSignatureGenerateIds()) {
if (securePart.getIdToSign() == null) {
signaturePartDef.setGenerateXPointer(securePart.isGenerateXPointer());
signaturePartDef.setSigRefId(IDGenerator.generateID(null));
Attribute attribute = xmlSecStartElement.getAttributeByName(securityProperties.getIdAttributeNS());
if (attribute != null) {
signaturePartDef.setSigRefId(attribute.getValue());
} else {
List<XMLSecAttribute> attributeList = new ArrayList<>(1);
attributeList.add(createAttribute(securityProperties.getIdAttributeNS(), signaturePartDef.getSigRefId()));
xmlSecEvent = addAttributes(xmlSecStartElement, attributeList);
}
} else {
signaturePartDef.setSigRefId(securePart.getIdToSign());
}
}
getSignaturePartDefList().add(signaturePartDef);
internalSignatureOutputProcessor = new InternalSignatureOutputProcessor(signaturePartDef, xmlSecStartElement);
internalSignatureOutputProcessor.setXMLSecurityProperties(getSecurityProperties());
internalSignatureOutputProcessor.setAction(getAction());
internalSignatureOutputProcessor.addAfterProcessor(XMLSignatureOutputProcessor.class.getName());
internalSignatureOutputProcessor.addBeforeProcessor(XMLSignatureEndingOutputProcessor.class.getName());
internalSignatureOutputProcessor.init(outputProcessorChain);
setActiveInternalSignatureOutputProcessor(internalSignatureOutputProcessor);
}
}
}
outputProcessorChain.processEvent(xmlSecEvent);
}
use of javax.xml.stream.events.Attribute in project santuario-java by apache.
the class XMLSecurityStreamReader method getAttributeValue.
@Override
public String getAttributeValue(String namespaceURI, String localName) {
XMLSecEvent xmlSecEvent = getCurrentEvent();
if (xmlSecEvent.getEventType() != START_ELEMENT) {
throw new IllegalStateException(ERR_STATE_NOT_STELEM);
}
Attribute attribute = xmlSecEvent.asStartElement().getAttributeByName(new QName(namespaceURI, localName));
if (attribute != null) {
return attribute.getValue();
}
return null;
}
use of javax.xml.stream.events.Attribute in project contribution by checkstyle.
the class CheckstyleConfigurationsParser method processModuleTag.
/**
* Parses single "module" tag.
*
* @param reader
* StAX parser interface.
* @param startElement
* start element of the tag.
* @param parent
* parent module instance.
* @throws XMLStreamException
* on internal StAX failure.
*/
private static void processModuleTag(XMLEventReader reader, StartElement startElement, ConfigurationModule parent) throws XMLStreamException {
String childModuleName = null;
final Iterator<Attribute> attributes = startElement.getAttributes();
while (attributes.hasNext()) {
final Attribute attribute = attributes.next();
if (attribute.getName().toString().equals(NAME_ATTR)) {
childModuleName = attribute.getValue();
}
}
final ConfigurationModule childModule = new ConfigurationModule(childModuleName);
parseModule(reader, childModule);
parent.addChild(childModule);
}
use of javax.xml.stream.events.Attribute in project contribution by checkstyle.
the class CheckstyleConfigurationsParser method processMessageTag.
/**
* Parses single "message" tag.
*
* @param startElement
* start element of the tag.
* @param parent
* parent module instance.
*/
private static void processMessageTag(StartElement startElement, ConfigurationModule parent) {
String propertyName = null;
String propertyValue = null;
final Iterator<Attribute> attributes = startElement.getAttributes();
while (attributes.hasNext()) {
final Attribute attribute = attributes.next();
final String attributeName = attribute.getName().toString();
if (attributeName.equals(KEY_ATTR)) {
propertyName = attribute.getValue();
} else if (attributeName.equals(VALUE_ATTR)) {
propertyValue = attribute.getValue();
}
}
parent.addProperty(propertyName, propertyValue);
}
Aggregations