Search in sources :

Example 1 with ValveMetaData

use of org.jboss.metadata.web.jboss.ValveMetaData in project keycloak by keycloak.

the class KeycloakAdapterConfigDeploymentProcessor method addValve.

private void addValve(JBossWebMetaData webMetaData) {
    List<ValveMetaData> valves = webMetaData.getValves();
    if (valves == null) {
        valves = new ArrayList<>(1);
        webMetaData.setValves(valves);
    }
    ValveMetaData valve = new ValveMetaData();
    valve.setValveClass(KeycloakAuthenticatorValve.class.getName());
    valve.setModule("org.keycloak.keycloak-as7-adapter");
    // log.info("******* adding Keycloak valve to: " + deploymentName);
    valves.add(valve);
}
Also used : KeycloakAuthenticatorValve(org.keycloak.adapters.jbossweb.KeycloakAuthenticatorValve) ValveMetaData(org.jboss.metadata.web.jboss.ValveMetaData)

Example 2 with ValveMetaData

use of org.jboss.metadata.web.jboss.ValveMetaData in project wildfly by wildfly.

the class JBossWebParsingDeploymentProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (!DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
        // Skip non web deployments
        return;
    }
    final VirtualFile deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT).getRoot();
    final VirtualFile jbossWebXml = deploymentRoot.getChild(JBOSS_WEB_XML);
    WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
    assert warMetaData != null;
    if (jbossWebXml.exists()) {
        InputStream is = null;
        try {
            is = jbossWebXml.openStream();
            final XMLInputFactory inputFactory = XMLInputFactory.newInstance();
            inputFactory.setXMLResolver(NoopXMLResolver.create());
            XMLStreamReader xmlReader = inputFactory.createXMLStreamReader(is);
            final JBossWebMetaData jBossWebMetaData = JBossWebMetaDataParser.parse(xmlReader, JBossDescriptorPropertyReplacement.propertyReplacer(deploymentUnit));
            warMetaData.setJBossWebMetaData(jBossWebMetaData);
            // deployment unit
            if (jBossWebMetaData.getValves() != null) {
                for (ValveMetaData valve : jBossWebMetaData.getValves()) {
                    UndertowLogger.ROOT_LOGGER.unsupportedValveFeature(valve.getValveClass());
                }
            }
            if (jBossWebMetaData.getDistinctName() != null) {
                deploymentUnit.putAttachment(org.jboss.as.ee.structure.Attachments.DISTINCT_NAME, jBossWebMetaData.getDistinctName());
            }
        } catch (XMLStreamException e) {
            throw new DeploymentUnitProcessingException(UndertowLogger.ROOT_LOGGER.failToParseXMLDescriptor(jbossWebXml.toString(), e.getLocation().getLineNumber(), e.getLocation().getColumnNumber()), e);
        } catch (IOException e) {
            throw new DeploymentUnitProcessingException(UndertowLogger.ROOT_LOGGER.failToParseXMLDescriptor(jbossWebXml.toString()), e);
        } finally {
            try {
                if (is != null) {
                    is.close();
                }
            } catch (IOException e) {
            // Ignore
            }
        }
    } else {
        // jboss web embedded inside jboss-all.xml
        final JBossWebMetaData jbMeta = deploymentUnit.getAttachment(WebJBossAllParser.ATTACHMENT_KEY);
        if (jbMeta != null) {
            warMetaData.setJBossWebMetaData(jbMeta);
        }
    }
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) JBossWebMetaData(org.jboss.metadata.web.jboss.JBossWebMetaData) XMLStreamReader(javax.xml.stream.XMLStreamReader) XMLStreamException(javax.xml.stream.XMLStreamException) InputStream(java.io.InputStream) WarMetaData(org.jboss.as.web.common.WarMetaData) IOException(java.io.IOException) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) ValveMetaData(org.jboss.metadata.web.jboss.ValveMetaData) XMLInputFactory(javax.xml.stream.XMLInputFactory)

Example 3 with ValveMetaData

use of org.jboss.metadata.web.jboss.ValveMetaData in project keycloak by keycloak.

the class KeycloakAdapterConfigDeploymentProcessor method addValve.

private void addValve(JBossWebMetaData webMetaData) {
    List<ValveMetaData> valves = webMetaData.getValves();
    if (valves == null) {
        valves = new ArrayList<ValveMetaData>(1);
        webMetaData.setValves(valves);
    }
    ValveMetaData valve = new ValveMetaData();
    valve.setValveClass(SamlAuthenticatorValve.class.getName());
    valve.setModule("org.keycloak.keycloak-saml-as7-adapter");
    // log.info("******* adding Keycloak valve to: " + deploymentName);
    valves.add(valve);
}
Also used : SamlAuthenticatorValve(org.keycloak.adapters.saml.jbossweb.SamlAuthenticatorValve) ValveMetaData(org.jboss.metadata.web.jboss.ValveMetaData)

Aggregations

ValveMetaData (org.jboss.metadata.web.jboss.ValveMetaData)3 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 XMLInputFactory (javax.xml.stream.XMLInputFactory)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 XMLStreamReader (javax.xml.stream.XMLStreamReader)1 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)1 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)1 WarMetaData (org.jboss.as.web.common.WarMetaData)1 JBossWebMetaData (org.jboss.metadata.web.jboss.JBossWebMetaData)1 VirtualFile (org.jboss.vfs.VirtualFile)1 KeycloakAuthenticatorValve (org.keycloak.adapters.jbossweb.KeycloakAuthenticatorValve)1 SamlAuthenticatorValve (org.keycloak.adapters.saml.jbossweb.SamlAuthenticatorValve)1