Package org.apache.xml.security.stax.ext.stax

Examples of org.apache.xml.security.stax.ext.stax.XMLSecEvent


        return xmlSecEvent.asStartElement().getOnElementDeclaredAttributes().size();
    }

    @Override
    public QName getAttributeName(int index) {
        XMLSecEvent xmlSecEvent = getCurrentEvent();
        if (xmlSecEvent.getEventType() != START_ELEMENT) {
            throw new IllegalStateException(ERR_STATE_NOT_STELEM);
        }
        return xmlSecEvent.asStartElement().getOnElementDeclaredAttributes().get(index).getName();
    }
View Full Code Here


        return xmlSecEvent.asStartElement().getOnElementDeclaredAttributes().get(index).getName();
    }

    @Override
    public String getAttributeNamespace(int index) {
        XMLSecEvent xmlSecEvent = getCurrentEvent();
        if (xmlSecEvent.getEventType() != START_ELEMENT) {
            throw new IllegalStateException(ERR_STATE_NOT_STELEM);
        }
        return xmlSecEvent.asStartElement().getOnElementDeclaredAttributes().get(index).getAttributeNamespace().getNamespaceURI();
    }
View Full Code Here

        return xmlSecEvent.asStartElement().getOnElementDeclaredAttributes().get(index).getAttributeNamespace().getNamespaceURI();
    }

    @Override
    public String getAttributeLocalName(int index) {
        XMLSecEvent xmlSecEvent = getCurrentEvent();
        if (xmlSecEvent.getEventType() != START_ELEMENT) {
            throw new IllegalStateException(ERR_STATE_NOT_STELEM);
        }
        return xmlSecEvent.asStartElement().getOnElementDeclaredAttributes().get(index).getName().getLocalPart();
    }
View Full Code Here

        return xmlSecEvent.asStartElement().getOnElementDeclaredAttributes().get(index).getName().getLocalPart();
    }

    @Override
    public String getAttributePrefix(int index) {
        XMLSecEvent xmlSecEvent = getCurrentEvent();
        if (xmlSecEvent.getEventType() != START_ELEMENT) {
            throw new IllegalStateException(ERR_STATE_NOT_STELEM);
        }
        return xmlSecEvent.asStartElement().getOnElementDeclaredAttributes().get(index).getName().getPrefix();
    }
View Full Code Here

        return xmlSecEvent.asStartElement().getOnElementDeclaredAttributes().get(index).getName().getPrefix();
    }

    @Override
    public String getAttributeType(int index) {
        XMLSecEvent xmlSecEvent = getCurrentEvent();
        if (xmlSecEvent.getEventType() != START_ELEMENT) {
            throw new IllegalStateException(ERR_STATE_NOT_STELEM);
        }
        return xmlSecEvent.asStartElement().getOnElementDeclaredAttributes().get(index).getDTDType();
    }
View Full Code Here

        this.policyEnforcer = policyEnforcer;
    }

    @Override
    public XMLSecEvent processNextHeaderEvent(InputProcessorChain inputProcessorChain) throws XMLStreamException, XMLSecurityException {
        XMLSecEvent xmlSecEvent = inputProcessorChain.processHeaderEvent();
        //test if non encrypted element have to be encrypted per policy
        init(inputProcessorChain);
        //if transport security is active, every element is encrypted/signed
        //WSP1.3, 4.2.1 EncryptedParts Assertion
        List<QName> elementPath = null;
        if (!transportSecurityActive) {
            elementPath = xmlSecEvent.getElementPath();
            if (!inputProcessorChain.getDocumentContext().isInEncryptedContent()
                    && WSSUtils.isInSecurityHeader(xmlSecEvent, elementPath,
                    ((WSSSecurityProperties) getSecurityProperties()).getActor())) {
                testEncryptionPolicy(xmlSecEvent, elementPath);
            }
        }
        if (xmlSecEvent.getEventType() == XMLStreamConstants.START_ELEMENT) {
            XMLSecStartElement xmlSecStartElement = xmlSecEvent.asStartElement();
            if (elementPath == null) {
                elementPath = xmlSecStartElement.getElementPath();
            }
            final int documentLevel = elementPath.size();
            if (documentLevel == 3 && WSSUtils.isInSOAPHeader(elementPath)) {
View Full Code Here

        return xmlSecEvent;
    }

    @Override
    public XMLSecEvent processNextEvent(InputProcessorChain inputProcessorChain) throws XMLStreamException, XMLSecurityException {
        XMLSecEvent xmlSecEvent = inputProcessorChain.processEvent();

        List<QName> elementPath = null;
        switch (xmlSecEvent.getEventType()) {
            case XMLStreamConstants.START_ELEMENT:
                XMLSecStartElement xmlSecStartElement = xmlSecEvent.asStartElement();
                int documentLevel = xmlSecStartElement.getDocumentLevel();
                //test for required elements
                if (documentLevel > 3) {
                    RequiredElementSecurityEvent requiredElementSecurityEvent = new RequiredElementSecurityEvent();
                    elementPath = xmlSecStartElement.getElementPath();
                    requiredElementSecurityEvent.setElementPath(elementPath);
                    policyEnforcer.registerSecurityEvent(requiredElementSecurityEvent);
                }
                break;
        }

        //if transport security is active, every element is encrypted/signed
        //WSP1.3, 4.2.1 EncryptedParts Assertion
        //test if non encrypted element have to be encrypted per policy
        if (!transportSecurityActive) {
            final DocumentContext documentContext = inputProcessorChain.getDocumentContext();
            final boolean inEncryptedContent = documentContext.isInEncryptedContent();
            final boolean inSignedContent = documentContext.isInSignedContent();
            if (!inEncryptedContent || !inSignedContent) {
                if (elementPath == null) {
                    elementPath = xmlSecEvent.getElementPath();
                }
                if (!inEncryptedContent
                        && !WSSUtils.isInSecurityHeader(xmlSecEvent, elementPath,
                        ((WSSSecurityProperties) getSecurityProperties()).getActor())) {
                    testEncryptionPolicy(xmlSecEvent, elementPath);
View Full Code Here

        }

        int createdIndex = -1;
        int expiresIndex = -1;
        for (int i = 0; i < xmlSecEvents.size(); i++) {
            XMLSecEvent xmlSecEvent = xmlSecEvents.get(i);
            if (xmlSecEvent.getEventType() == XMLStreamConstants.START_ELEMENT) {
                QName name = xmlSecEvent.asStartElement().getName();

                if (name.equals(WSSConstants.TAG_wsu_Timestamp)) {
                    continue;
                } else if (name.equals(WSSConstants.TAG_wsu_Created)) {
                    if (createdIndex != -1) {
View Full Code Here

    }

    @Override
    public XMLSecEvent processNextEvent(InputProcessorChain inputProcessorChain)
            throws XMLStreamException, XMLSecurityException {
        XMLSecEvent xmlSecEvent = inputProcessorChain.processEvent();
        if (xmlSecEvent.getEventType() == XMLStreamConstants.START_ELEMENT) {
            XMLSecStartElement xmlSecStartElement = xmlSecEvent.asStartElement();
            List<QName> elementPath = xmlSecStartElement.getElementPath();
            if (elementPath.size() == 3 && WSSUtils.isInSOAPBody(elementPath)) {
                OperationSecurityEvent operationSecurityEvent = new OperationSecurityEvent();
                operationSecurityEvent.setOperation(xmlSecEvent.asStartElement().getName());
                operationSecurityEvent.setCorrelationID(IDGenerator.generateID(null));
                inputProcessorChain.getSecurityContext().registerSecurityEvent(operationSecurityEvent);
                inputProcessorChain.removeProcessor(this);
            }
        }
View Full Code Here

        }

        @Override
        public XMLSecEvent processNextEvent(final InputProcessorChain inputProcessorChain)
                throws XMLStreamException, XMLSecurityException {
            XMLSecEvent xmlSecEvent = inputProcessorChain.processEvent();
            switch (xmlSecEvent.getEventType()) {
                case XMLStreamConstants.START_ELEMENT:
                    XMLSecStartElement xmlSecStartElement = xmlSecEvent.asStartElement();
                    Attribute attribute = xmlSecStartElement.getAttributeByName(this.attribute);
                    if (attribute != null && this.attributeValue.equals(attribute.getValue())) {
                        if (refFound) {
                            throw new WSSecurityException(WSSecurityException.ErrorCode.INVALID_SECURITY, "duplicateId");
                        }
                        refFound = true;
                        startElementName = xmlSecStartElement.getName();
                        List<QName> elementPath = xmlSecStartElement.getElementPath();
                        startElementLevel = elementPath.size();
                    }
                    break;
                case XMLStreamConstants.END_ELEMENT:
                    XMLSecEndElement xmlSecEndElement = xmlSecEvent.asEndElement();
                    if (xmlSecEndElement.getName().equals(startElementName)
                            && xmlSecEndElement.getDocumentLevel() == startElementLevel) {
                        end = true;
                        xmlSecEventList.push(xmlSecEvent);
View Full Code Here

TOP

Related Classes of org.apache.xml.security.stax.ext.stax.XMLSecEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.