org.jboss.as.server.deployment.DeploymentUnitProcessingException Java Examples

The following examples show how to use org.jboss.as.server.deployment.DeploymentUnitProcessingException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KeycloakServerDeploymentProcessor.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    KeycloakAdapterConfigService configService = KeycloakAdapterConfigService.INSTANCE;
    String deploymentName = deploymentUnit.getName();

    if (!configService.isKeycloakServerDeployment(deploymentName)) {
        return;
    }

    final EEModuleDescription description = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
    String webContext = configService.getWebContext();
    if (webContext == null) {
        throw new DeploymentUnitProcessingException("Can't determine web context/module for Keycloak Server");
    }
    description.setModuleName(webContext);

    addInfinispanCaches(phaseContext);
    addConfiguration(deploymentUnit, configService);
}
 
Example #2
Source File: VirtualSecurityDomainProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (deploymentUnit.getParent() != null || !isVirtualDomainRequired(deploymentUnit)) {
        return;  // Only interested in installation if this is really the root deployment.
    }

    ServiceName virtualDomainName = virtualDomainName(deploymentUnit);
    ServiceTarget serviceTarget = phaseContext.getServiceTarget();

    ServiceBuilder<?> serviceBuilder = serviceTarget.addService(virtualDomainName);

    final SecurityDomain virtualDomain = SecurityDomain.builder().build();
    final Consumer<SecurityDomain> consumer = serviceBuilder.provides(virtualDomainName);

    serviceBuilder.setInstance(Service.newInstance(consumer, virtualDomain));
    serviceBuilder.setInitialMode(Mode.ON_DEMAND);
    serviceBuilder.install();
}
 
Example #3
Source File: KeycloakAdapterConfigDeploymentProcessor.java    From keycloak with Apache License 2.0 6 votes vote down vote up
private void addKeycloakAuthData(DeploymentPhaseContext phaseContext, KeycloakAdapterConfigService service) throws DeploymentUnitProcessingException {
    DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
    if (warMetaData == null) {
        throw new DeploymentUnitProcessingException("WarMetaData not found for " + deploymentUnit.getName() + ".  Make sure you have specified a WAR as your secure-deployment in the Keycloak subsystem.");
    }

    addJSONData(service.getJSON(deploymentUnit), warMetaData);
    JBossWebMetaData webMetaData = warMetaData.getMergedJBossWebMetaData();
    if (webMetaData == null) {
        webMetaData = new JBossWebMetaData();
        warMetaData.setMergedJBossWebMetaData(webMetaData);
    }

    LoginConfigMetaData loginConfig = webMetaData.getLoginConfig();
    if (loginConfig == null) {
        loginConfig = new LoginConfigMetaData();
        webMetaData.setLoginConfig(loginConfig);
    }
    loginConfig.setAuthMethod("KEYCLOAK");
    loginConfig.setRealmName(service.getRealmName(deploymentUnit));
    KeycloakLogger.ROOT_LOGGER.deploymentSecured(deploymentUnit.getName());
}
 
Example #4
Source File: KeycloakProviderDependencyProcessor.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    KeycloakAdapterConfigService config = KeycloakAdapterConfigService.INSTANCE;
    String deploymentName = deploymentUnit.getName();

    if (config.isKeycloakServerDeployment(deploymentName)) {
        return;
    }

    KeycloakDeploymentInfo info = getKeycloakProviderDeploymentInfo(deploymentUnit);
    if (info.hasServices()) {
        final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
        final ModuleLoader moduleLoader = Module.getBootModuleLoader();
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_COMMON, false, false, false, false));
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_CORE, false, false, false, false));
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_SERVER_SPI, false, false, false, false));
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_SERVER_SPI_PRIVATE, false, false, false, false));
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, JAXRS, false, false, false, false));
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, RESTEASY, false, false, false, false));
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, APACHE, false, false, false, false));
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_JPA, false, false, false, false));
    }
}
 
Example #5
Source File: KeycloakDependencyProcessor.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();

    if (Configuration.INSTANCE.getSecureDeployment(deploymentUnit) == null) {
        WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
        if (warMetaData == null) {
            return;
        }
        JBossWebMetaData webMetaData = warMetaData.getMergedJBossWebMetaData();
        if (webMetaData == null) {
            return;
        }
        LoginConfigMetaData loginConfig = webMetaData.getLoginConfig();
        if (loginConfig == null) return;
        if (loginConfig.getAuthMethod() == null) return;
        if (!loginConfig.getAuthMethod().equals("KEYCLOAK-SAML")) return;
    }

    final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
    final ModuleLoader moduleLoader = Module.getBootModuleLoader();
    addCommonModules(moduleSpecification, moduleLoader);
    addPlatformSpecificModules(moduleSpecification, moduleLoader);
}
 
Example #6
Source File: PermissionsValidationProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final List<PermissionFactory> permissionFactories = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION).getPermissionFactories();
    final StringBuilder failedPermissions = new StringBuilder();
    for (PermissionFactory factory : permissionFactories) {
        // all permissions granted internally by the container are of type ImmediatePermissionFactory - they should
        // not be considered when validating the permissions granted to deployments via subsystem or deployment
        // descriptors.
        if (!(factory instanceof ImmediatePermissionFactory)) {
            Permission permission = factory.construct();
            boolean implied = this.maxPermissions.implies(permission);
            if (!implied) {
                failedPermissions.append("\n\t\t" + permission);

            }
        }
    }
    if (failedPermissions.length() > 0) {
        throw SecurityManagerLogger.ROOT_LOGGER.invalidDeploymentConfiguration(failedPermissions);
    }
}
 
Example #7
Source File: LoggingConfigDeploymentProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Finds the configuration file to be used and returns the first one found.
 * <p/>
 * Preference is for {@literal logging.properties} or {@literal jboss-logging.properties}.
 *
 * @param file the file to check
 *
 * @return the configuration file if found, otherwise {@code null}
 *
 * @throws DeploymentUnitProcessingException if an error occurs.
 */
private VirtualFile findConfigFile(final VirtualFile file) throws DeploymentUnitProcessingException {
    VirtualFile result = null;
    try {
        final List<VirtualFile> configFiles = file.getChildren(ConfigFilter.INSTANCE);
        for (final VirtualFile configFile : configFiles) {
            final String fileName = configFile.getName();
            if (DEFAULT_PROPERTIES.equals(fileName) || JBOSS_PROPERTIES.equals(fileName)) {
                if (result != null) {
                    LoggingLogger.ROOT_LOGGER.debugf("The previously found configuration file '%s' is being ignored in favour of '%s'", result, configFile);
                }
                return configFile;
            } else if (LOG4J_PROPERTIES.equals(fileName) || LOG4J_XML.equals(fileName) || JBOSS_LOG4J_XML.equals(fileName)) {
                result = configFile;
            }
        }
    } catch (IOException e) {
        throw LoggingLogger.ROOT_LOGGER.errorProcessingLoggingConfiguration(e);
    }
    return result;
}
 
Example #8
Source File: ProcessEngineStartProcessor.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
  
  final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
  
  if(!ProcessApplicationAttachments.isProcessApplication(deploymentUnit)) {
    return;
  }
  
  List<ProcessesXmlWrapper> processesXmls = ProcessApplicationAttachments.getProcessesXmls(deploymentUnit);
  for (ProcessesXmlWrapper wrapper : processesXmls) {            
    for (ProcessEngineXml processEngineXml : wrapper.getProcessesXml().getProcessEngines()) {
      startProcessEngine(processEngineXml, phaseContext);      
    }
  }
  
}
 
Example #9
Source File: KeycloakDependencyProcessor.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();

    if (!KeycloakAdapterConfigService.getInstance().isSecureDeployment(deploymentUnit)) {
        WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
        if (warMetaData == null) {
            return;
        }
        JBossWebMetaData webMetaData = warMetaData.getMergedJBossWebMetaData();
        if (webMetaData == null) {
            return;
        }
        LoginConfigMetaData loginConfig = webMetaData.getLoginConfig();
        if (loginConfig == null) return;
        if (loginConfig.getAuthMethod() == null) return;
        if (!loginConfig.getAuthMethod().equals("KEYCLOAK")) return;
    }

    final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
    final ModuleLoader moduleLoader = Module.getBootModuleLoader();
    addCommonModules(moduleSpecification, moduleLoader);
    addPlatformSpecificModules(moduleSpecification, moduleLoader);
}
 
Example #10
Source File: KeycloakAdapterConfigDeploymentProcessor.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();

    KeycloakAdapterConfigService service = KeycloakAdapterConfigService.getInstance();
    if (service.isSecureDeployment(deploymentUnit) && service.isDeploymentConfigured(deploymentUnit)) {
        addKeycloakAuthData(phaseContext, service);
    }

    addConfigurationListener(phaseContext);

    // FYI, Undertow Extension will find deployments that have auth-method set to KEYCLOAK

    // todo notsure if we need this
    // addSecurityDomain(deploymentUnit, service);
}
 
Example #11
Source File: KeycloakDependencyProcessor.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (!KeycloakAdapterConfigService.getInstance().isSecureDeployment(deploymentUnit)) {
        WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
        if (warMetaData == null) {
            return;
        }
        JBossWebMetaData webMetaData = warMetaData.getMergedJBossWebMetaData();
        if (webMetaData == null) {
            return;
        }
        LoginConfigMetaData loginConfig = webMetaData.getLoginConfig();
        if (loginConfig == null) return;
        if (loginConfig.getAuthMethod() == null) return;
        if (!loginConfig.getAuthMethod().equals("KEYCLOAK")) return;
    }

    final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
    final ModuleLoader moduleLoader = Module.getBootModuleLoader();
    addCommonModules(moduleSpecification, moduleLoader);
    addPlatformSpecificModules(phaseContext, moduleSpecification, moduleLoader);
}
 
Example #12
Source File: CamelDeploymentSettingsProcessor.java    From wildfly-camel with Apache License 2.0 6 votes vote down vote up
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {

        final DeploymentUnit depUnit = phaseContext.getDeploymentUnit();

        CamelDeploymentSettings.Builder depSettingsBuilder = depUnit
                .removeAttachment(CamelDeploymentSettings.BUILDER_ATTACHMENT_KEY);
        if (depSettingsBuilder != null && depUnit.getParent() == null) {
            /*
             * We do this only for parentless deployments because for ones that have a parent the build and attachment
             * is done by CamelDeploymentSettings.Builder.build() if the parent
             */
            final CamelDeploymentSettings depSettings = depSettingsBuilder.build();
            depUnit.putAttachment(CamelDeploymentSettings.ATTACHMENT_KEY, depSettings);
        }

    }
 
Example #13
Source File: CamelContextBootstrapProcessor.java    From wildfly-camel with Apache License 2.0 6 votes vote down vote up
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {

    final DeploymentUnit depUnit = phaseContext.getDeploymentUnit();

    final Module module = depUnit.getAttachment(Attachments.MODULE);
    final String runtimeName = depUnit.getName();

    // Add the camel context bootstraps to the deployment
    CamelDeploymentSettings depSettings = depUnit.getAttachment(CamelDeploymentSettings.ATTACHMENT_KEY);
    for (URL contextURL : depSettings.getCamelContextUrls()) {
        ClassLoader tccl = SecurityActions.getContextClassLoader();
        try {
            SecurityActions.setContextClassLoader(module.getClassLoader());
            SpringCamelContextBootstrap bootstrap = new SpringCamelContextBootstrap(contextURL, module.getClassLoader());
            depUnit.addToAttachmentList(CamelConstants.CAMEL_CONTEXT_BOOTSTRAP_KEY, bootstrap);
        } catch (Exception ex) {
            throw new IllegalStateException("Cannot create camel context: " + runtimeName, ex);
        } finally {
            SecurityActions.setContextClassLoader(tccl);
        }
    }
}
 
Example #14
Source File: ManifestClassPathProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void handlingExistingClassPathEntry(final ArrayDeque<RootEntry> resourceRoots, final DeploymentUnit topLevelDeployment, final VirtualFile topLevelRoot, final Map<VirtualFile, ResourceRoot> subDeployments, final Map<VirtualFile, AdditionalModuleSpecification> additionalModules, final Set<VirtualFile> existingAccessibleRoots, final ResourceRoot resourceRoot, final Attachable target, final VirtualFile classPathFile) throws DeploymentUnitProcessingException {
    if (existingAccessibleRoots.contains(classPathFile)) {
        ServerLogger.DEPLOYMENT_LOGGER.debugf("Class-Path entry %s in %s ignored, as target is already accessible", classPathFile, resourceRoot.getRoot());
    } else if (additionalModules.containsKey(classPathFile)) {
        final AdditionalModuleSpecification moduleSpecification = additionalModules.get(classPathFile);
        //as class path entries are exported, transitive dependencies will also be available
        target.addToAttachmentList(Attachments.CLASS_PATH_ENTRIES, moduleSpecification.getModuleIdentifier());
    } else if (subDeployments.containsKey(classPathFile)) {
        //now we need to calculate the sub deployment module identifier
        //unfortunately the sub deployment has not been setup yet, so we cannot just
        //get it from the sub deployment directly
        final ResourceRoot otherRoot = subDeployments.get(classPathFile);
        target.addToAttachmentList(Attachments.CLASS_PATH_ENTRIES, ModuleIdentifierProcessor.createModuleIdentifier(otherRoot.getRootName(), otherRoot, topLevelDeployment, topLevelRoot, false));
    } else {
        ModuleIdentifier identifier = createAdditionalModule(resourceRoot, topLevelDeployment, topLevelRoot, additionalModules, classPathFile, resourceRoots);
        target.addToAttachmentList(Attachments.CLASS_PATH_ENTRIES, identifier);
    }
}
 
Example #15
Source File: CamelEndpointDeploymentSchedulerProcessor.java    From wildfly-camel with Apache License 2.0 6 votes vote down vote up
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    CamelDeploymentSettings depSettings = deploymentUnit.getAttachment(CamelDeploymentSettings.ATTACHMENT_KEY);

    if (!depSettings.isEnabled()) {
        return;
    }
    List<DeploymentUnit> subDeployments = deploymentUnit
            .getAttachmentList(org.jboss.as.server.deployment.Attachments.SUB_DEPLOYMENTS);
    if (subDeployments != null && !subDeployments.isEmpty()) {
        /* do not install CamelEndpointDeploymentSchedulerService for ears */
        return;
    }

    final ServiceTarget serviceTarget = phaseContext.getServiceTarget();
    final ServiceController<CamelEndpointDeploymentSchedulerService> serviceController = CamelEndpointDeploymentSchedulerService
            .addService(deploymentUnit.getServiceName(), deploymentUnit.getName(), serviceTarget);
    phaseContext.addDeploymentDependency(serviceController.getName(),
            CamelConstants.CAMEL_ENDPOINT_DEPLOYMENT_SCHEDULER_REGISTRY_KEY);
}
 
Example #16
Source File: ClassFileTransformerProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final DelegatingClassFileTransformer transformer = deploymentUnit.getAttachment(DelegatingClassFileTransformer.ATTACHMENT_KEY);
    final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
    final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
    if (module == null || transformer == null) {
        return;
    }
    try {
        for (String transformerClassName : moduleSpecification.getClassFileTransformers()) {
            transformer.addTransformer((ClassFileTransformer) module.getClassLoader().loadClass(transformerClassName).newInstance());
        }
        // activate transformer only after all delegate transformers have been added
        // so that transformers themselves are not instrumented
        transformer.setActive(true);
    } catch (Exception e) {
        throw ServerLogger.ROOT_LOGGER.failedToInstantiateClassFileTransformer(ClassFileTransformer.class.getSimpleName(), e);
    }
}
 
Example #17
Source File: ModuleSpecProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void addResourceRoot(final ModuleSpec.Builder specBuilder, final ResourceRoot resource, final List<PermissionFactory> permFactories)
        throws DeploymentUnitProcessingException {
    try {
        final VirtualFile root = resource.getRoot();
        if (resource.getExportFilters().isEmpty()) {
            specBuilder.addResourceRoot(ResourceLoaderSpec.createResourceLoaderSpec(new VFSResourceLoader(resource
                    .getRootName(), root, resource.isUsePhysicalCodeSource())));
        } else {
            final MultiplePathFilterBuilder filterBuilder = PathFilters.multiplePathFilterBuilder(true);
            for (final FilterSpecification filter : resource.getExportFilters()) {
                filterBuilder.addFilter(filter.getPathFilter(), filter.isInclude());
            }
            specBuilder.addResourceRoot(ResourceLoaderSpec.createResourceLoaderSpec(new VFSResourceLoader(resource
                    .getRootName(), root, resource.isUsePhysicalCodeSource()), filterBuilder.create()));
        }
        // start with the root
        permFactories.add(new ImmediatePermissionFactory(
                new VirtualFilePermission(root.getPathName(), VirtualFilePermission.FLAG_READ)));
        // also include all children, recursively
        permFactories.add(new ImmediatePermissionFactory(
                new VirtualFilePermission(root.getChild("-").getPathName(), VirtualFilePermission.FLAG_READ)));
    } catch (IOException e) {
        throw ServerLogger.ROOT_LOGGER.failedToCreateVFSResourceLoader(resource.getRootName(), e);
    }
}
 
Example #18
Source File: DeploymentStructureDescriptorParser.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private ParseResult parse(final InputStream source, final File file, final DeploymentUnit deploymentUnit, final ModuleLoader moduleLoader)
        throws DeploymentUnitProcessingException {
    try {

        final XMLInputFactory inputFactory = INPUT_FACTORY;
        setIfSupported(inputFactory, XMLInputFactory.IS_VALIDATING, Boolean.FALSE);
        setIfSupported(inputFactory, XMLInputFactory.SUPPORT_DTD, Boolean.FALSE);
        final XMLStreamReader streamReader = inputFactory.createXMLStreamReader(source);
        try {
            final ParseResult result = new ParseResult(moduleLoader, deploymentUnit);
            mapper.parseDocument(result, streamReader);
            return result;
        } finally {
            safeClose(streamReader);
        }
    } catch (XMLStreamException e) {
        throw ServerLogger.ROOT_LOGGER.errorLoadingDeploymentStructureFile(file.getPath(), e);
    }
}
 
Example #19
Source File: ProcessEngineStartProcessor.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
  
  final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
  
  if(!ProcessApplicationAttachments.isProcessApplication(deploymentUnit)) {
    return;
  }
  
  List<ProcessesXmlWrapper> processesXmls = ProcessApplicationAttachments.getProcessesXmls(deploymentUnit);
  for (ProcessesXmlWrapper wrapper : processesXmls) {            
    for (ProcessEngineXml processEngineXml : wrapper.getProcessesXml().getProcessEngines()) {
      startProcessEngine(processEngineXml, phaseContext);      
    }
  }
  
}
 
Example #20
Source File: JBossAllXMLParsingProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void parse(final InputStream source, final File file,final XMLMapper mapper, final JBossAllXmlParseContext context) throws DeploymentUnitProcessingException {
    try {

        final XMLInputFactory inputFactory = INPUT_FACTORY;
        setIfSupported(inputFactory, XMLInputFactory.IS_VALIDATING, Boolean.FALSE);
        setIfSupported(inputFactory, XMLInputFactory.SUPPORT_DTD, Boolean.FALSE);
        final XMLStreamReader streamReader = inputFactory.createXMLStreamReader(source);
        try {
            mapper.parseDocument(context, streamReader);
        } finally {
            safeClose(streamReader);
        }
    } catch (XMLStreamException e) {
        throw ServerLogger.ROOT_LOGGER.errorLoadingJBossXmlFile(file.getPath(), e);
    }
}
 
Example #21
Source File: ProcessApplicationProcessor.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
  final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();    
  final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
  
  // must be EE Module
  if(eeModuleDescription == null) {
    return;
  }

  // discover user-provided component
  ComponentDescription paComponent = detectExistingComponent(deploymentUnit); 

  if(paComponent != null) {      
    log.log(Level.INFO, "Detected user-provided @"+ProcessApplication.class.getSimpleName()+" component with name '"+paComponent.getComponentName()+"'.");
    
    // mark this to be a process application
    ProcessApplicationAttachments.attachProcessApplicationComponent(deploymentUnit, paComponent);
    ProcessApplicationAttachments.mark(deploymentUnit);
    ProcessApplicationAttachments.markPartOfProcessApplication(deploymentUnit);
  }
}
 
Example #22
Source File: DeploymentDependenciesProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (deploymentUnit.hasAttachment(DeploymentDependencies.ATTACHMENT_KEY)) {
        if (deploymentUnit.getParent() != null) {
            ServerLogger.DEPLOYMENT_LOGGER.deploymentDependenciesAreATopLevelElement(deploymentUnit.getName());
        } else {
            processDependencies(phaseContext, deploymentUnit);
        }
    }

    if (deploymentUnit.getParent() != null) {
        DeploymentUnit parent = deploymentUnit.getParent();
        if (parent.hasAttachment(DeploymentDependencies.ATTACHMENT_KEY)) {
            processDependencies(phaseContext, parent);
        }
    }
}
 
Example #23
Source File: KeycloakProviderDeploymentProcessor.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    KeycloakAdapterConfigService config = KeycloakAdapterConfigService.INSTANCE;
    String deploymentName = deploymentUnit.getName();

    if (config.isKeycloakServerDeployment(deploymentName)) {
        return;
    }

    KeycloakDeploymentInfo info = KeycloakProviderDependencyProcessor.getKeycloakProviderDeploymentInfo(deploymentUnit);
    
    ScriptProviderDeploymentProcessor.deploy(deploymentUnit, info);
    
    if (info.isProvider()) {
        logger.infov("Deploying Keycloak provider: {0}", deploymentUnit.getName());
        final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
        ProviderManager pm = new ProviderManager(info, module.getClassLoader());
        ProviderManagerRegistry.SINGLETON.deploy(pm);
        deploymentUnit.putAttachment(ATTACHMENT_KEY, pm);
    }
}
 
Example #24
Source File: DriverDependenciesProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
    final ModuleLoader moduleLoader = Module.getBootModuleLoader();
    if (deploymentUnit.hasAttachment(Attachments.RESOURCE_ROOTS)) {
        final List<ResourceRoot> resourceRoots = deploymentUnit.getAttachmentList(Attachments.RESOURCE_ROOTS);
        for (ResourceRoot root : resourceRoots) {
            VirtualFile child = root.getRoot().getChild(SERVICE_FILE_NAME);
            if (child.exists()) {
                moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, JTA, false, false, false, false));
                break;
            }
        }
    }
}
 
Example #25
Source File: ManifestClassPathProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Creates a {@link ResourceRoot} for the passed {@link VirtualFile file} and adds it to the list of {@link ResourceRoot}s
 * in the {@link DeploymentUnit deploymentUnit}
 *
 *
 * @param file           The file for which the resource root will be created
 * @return Returns the created {@link ResourceRoot}
 * @throws java.io.IOException
 */
private synchronized ResourceRoot createResourceRoot(final VirtualFile file, final DeploymentUnit deploymentUnit, final VirtualFile deploymentRoot) throws DeploymentUnitProcessingException {
    try {
        Map<String, MountedDeploymentOverlay> overlays = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_OVERLAY_LOCATIONS);

        String relativeName = file.getPathNameRelativeTo(deploymentRoot);
        MountedDeploymentOverlay overlay = overlays.get(relativeName);
        Closeable closable = null;
        if(overlay != null) {
            overlay.remountAsZip(false);
        } else if(file.isFile()) {
            closable = VFS.mountZip(file, file, TempFileProviderService.provider());
        }
        final MountHandle mountHandle = MountHandle.create(closable);
        final ResourceRoot resourceRoot = new ResourceRoot(file, mountHandle);
        ModuleRootMarker.mark(resourceRoot);
        ResourceRootIndexer.indexResourceRoot(resourceRoot);
        return resourceRoot;
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
Example #26
Source File: CamelDependenciesProcessor.java    From wildfly-camel with Apache License 2.0 6 votes vote down vote up
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    DeploymentUnit depUnit = phaseContext.getDeploymentUnit();

    // Only operate on top level deployments
    if (depUnit.getParent() != null) {
        return;
    }

    List<DeploymentUnit> deployments = new ArrayList<>();
    List<DeploymentUnit> subDeployments = depUnit.getAttachmentList(Attachments.SUB_DEPLOYMENTS);
    deployments.add(depUnit);
    deployments.addAll(subDeployments);

    for (DeploymentUnit deployment : deployments) {
        CamelDeploymentSettings depSettings = deployment.getAttachment(CamelDeploymentSettings.ATTACHMENT_KEY);
        if (depSettings.isEnabled()) {
            addDeploymentDependencies(deployment, depSettings);
        }
    }
}
 
Example #27
Source File: ServiceActivatorDependencyProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Add the dependencies if the deployment contains a service activator loader entry.
 * @param phaseContext the deployment unit context
 * @throws DeploymentUnitProcessingException
 */
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final ResourceRoot deploymentRoot = phaseContext.getDeploymentUnit().getAttachment(Attachments.DEPLOYMENT_ROOT);
    final ModuleSpecification moduleSpecification = phaseContext.getDeploymentUnit().getAttachment(
            Attachments.MODULE_SPECIFICATION);
    if(deploymentRoot == null)
        return;
    final ServicesAttachment servicesAttachments = phaseContext.getDeploymentUnit().getAttachment(Attachments.SERVICES);
    if(servicesAttachments != null && !servicesAttachments.getServiceImplementations(ServiceActivator.class.getName()).isEmpty()) {
        moduleSpecification.addSystemDependency(MSC_DEP);
    }
}
 
Example #28
Source File: KeycloakAdapterConfigDeploymentProcessor.java    From keycloak with Apache License 2.0 5 votes vote down vote up
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();

    if (Configuration.INSTANCE.getSecureDeployment(deploymentUnit) != null) {
        addKeycloakSamlAuthData(phaseContext);
    }

    addConfigurationListener(phaseContext);
}
 
Example #29
Source File: ManifestAttachmentProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static Manifest getManifest(ResourceRoot resourceRoot) throws DeploymentUnitProcessingException {
    Manifest manifest = resourceRoot.getAttachment(Attachments.MANIFEST);
    if (manifest == null) {
        final VirtualFile deploymentRoot = resourceRoot.getRoot();
        try {
            manifest = VFSUtils.getManifest(deploymentRoot);
        } catch (IOException e) {
            throw ServerLogger.ROOT_LOGGER.failedToGetManifest(deploymentRoot, e);
        }
    }
    return manifest;
}
 
Example #30
Source File: ProcessesXmlProcessor.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected Enumeration<URL> getProcessesXmlResources(Module module, String[] deploymentDescriptors) throws DeploymentUnitProcessingException {
  try {
    return module.getClassLoader().getResources(PROCESSES_XML);
  } catch (IOException e) {
    throw new DeploymentUnitProcessingException(e);
  }
}