@Override
  public void execute(OperationContext context, ModelNode operation)
      throws OperationFailedException {

    String operationName = NAME.resolveModelAttribute(context, operation).asString();
    boolean accessControl = ACCESS_CONTROL.resolveModelAttribute(context, operation).asBoolean();

    final DescribedOp describedOp =
        getDescribedOp(context, operationName, operation, !accessControl);
    if (describedOp == null
        || (context.getProcessType() == ProcessType.DOMAIN_SERVER
            && !describedOp.flags.contains(OperationEntry.Flag.RUNTIME_ONLY))) {
      throw new OperationFailedException(
          ControllerLogger.ROOT_LOGGER.operationNotRegistered(
              operationName, context.getCurrentAddress()));
    } else {
      ModelNode result = describedOp.getDescription();

      if (accessControl) {
        final PathAddress address = context.getCurrentAddress();
        ModelNode operationToCheck = Util.createOperation(operationName, address);
        operationToCheck.get(OPERATION_HEADERS).set(operation.get(OPERATION_HEADERS));
        AuthorizationResult authorizationResult = context.authorizeOperation(operationToCheck);
        result
            .get(ACCESS_CONTROL.getName(), EXECUTE)
            .set(authorizationResult.getDecision() == Decision.PERMIT);
      }

      context.getResult().set(result);
    }
  }
Exemplo n.º 2
0
 /**
  * Add a step triggering the {@linkplain
  * org.jboss.as.controller.OperationContext#reloadRequired()} in case the the cache service is
  * installed, since the transport-config operations need a reload/restart and can't be applied to
  * the runtime directly.
  *
  * @param context the operation context
  */
 void reloadRequiredStep(final OperationContext context) {
   if (context.getProcessType().isServer() && !context.isBooting()) {
     context.addStep(
         new OperationStepHandler() {
           @Override
           public void execute(final OperationContext context, final ModelNode operation)
               throws OperationFailedException {
             // add some condition here if reload needs to be conditional on context
             // e.g. if a service is not installed, don't do a reload
             context.reloadRequired();
             context.completeStep();
           }
         },
         OperationContext.Stage.RUNTIME);
   }
 }
 @Override
 public void execute(OperationContext context, ModelNode operation)
     throws OperationFailedException {
   if (context.getProcessType() == ProcessType.SELF_CONTAINED) {
     throw DomainControllerLogger.ROOT_LOGGER.cannotReadContentFromSelfContainedServer();
   }
   final Resource deploymentResource = context.readResource(PathAddress.EMPTY_ADDRESS);
   ModelNode contentItemNode = getContentItem(deploymentResource);
   // Validate this op is available
   if (!isManaged(contentItemNode)) {
     throw DomainControllerLogger.ROOT_LOGGER.cannotReadContentFromUnmanagedDeployment();
   }
   final byte[] deploymentHash =
       CONTENT_HASH.resolveModelAttribute(context, contentItemNode).asBytes();
   final ModelNode pathNode = DEPLOYMENT_CONTENT_PATH.resolveModelAttribute(context, operation);
   final String path;
   if (pathNode.isDefined()) {
     path = pathNode.asString();
   } else {
     path = "";
   }
   int depth = DEPTH.resolveModelAttribute(context, operation).asInt();
   boolean explodable = ARCHIVE.resolveModelAttribute(context, operation).asBoolean();
   try {
     for (ContentRepositoryElement content :
         contentRepository.listContent(
             deploymentHash, path, ContentFilter.Factory.createContentFilter(depth, explodable))) {
       ModelNode contentNode = new ModelNode();
       contentNode.get(PATH).set(content.getPath());
       contentNode.get(DIRECTORY).set(content.isFolder());
       if (!content.isFolder()) {
         contentNode.get(FILE_SIZE).set(content.getSize());
       }
       context.getResult().add(contentNode);
     }
   } catch (ExplodedContentException ex) {
     throw new OperationFailedException(ex.getMessage());
   }
 }
Exemplo n.º 4
0
  @Override
  protected void performBoottime(
      final OperationContext context, ModelNode operation, final ModelNode model)
      throws OperationFailedException {

    // setup IIOP related stuff
    // This goes here rather than in EJB3IIOPAdd as it affects the server when it is acting as an
    // iiop client
    // setup our dynamic stub factory
    DelegatingStubFactoryFactory.setOverriddenDynamicFactory(new DynamicStubFactoryFactory());

    // setup the substitution service, that translates between ejb proxies and IIOP stubs
    final RemoteObjectSubstitutionService substitutionService =
        new RemoteObjectSubstitutionService();
    context
        .getServiceTarget()
        .addService(RemoteObjectSubstitutionService.SERVICE_NAME, substitutionService)
        .addDependency(
            DeploymentRepository.SERVICE_NAME,
            DeploymentRepository.class,
            substitutionService.getDeploymentRepositoryInjectedValue())
        .install();

    RemoteObjectSubstitutionManager.setRemoteObjectSubstitution(substitutionService);

    // setup ejb: namespace
    EjbNamingContextSetup.setupEjbNamespace();
    // TODO: this is a bit of a hack
    InitialContext.addUrlContextFactory("ejb", new ejbURLContextFactory());
    final boolean appclient = context.getProcessType() == ProcessType.APPLICATION_CLIENT;

    final ModelNode defaultDistinctName =
        EJB3SubsystemRootResourceDefinition.DEFAULT_DISTINCT_NAME.resolveModelAttribute(
            context, model);
    final DefaultDistinctNameService defaultDistinctNameService =
        new DefaultDistinctNameService(
            defaultDistinctName.isDefined() ? defaultDistinctName.asString() : null);
    context
        .getServiceTarget()
        .addService(DefaultDistinctNameService.SERVICE_NAME, defaultDistinctNameService)
        .install();

    // set the default security domain name in the deployment unit processor, configured at the
    // subsytem level
    final ModelNode defaultSecurityDomainModelNode =
        EJB3SubsystemRootResourceDefinition.DEFAULT_SECURITY_DOMAIN.resolveModelAttribute(
            context, model);
    final String defaultSecurityDomain =
        defaultSecurityDomainModelNode.isDefined()
            ? defaultSecurityDomainModelNode.asString()
            : null;
    this.defaultSecurityDomainDeploymentProcessor.setDefaultSecurityDomainName(
        defaultSecurityDomain);

    // set the default security domain name in the deployment unit processor, configured at the
    // subsytem level
    final ModelNode defaultMissingMethod =
        EJB3SubsystemRootResourceDefinition.DEFAULT_MISSING_METHOD_PERMISSIONS_DENY_ACCESS
            .resolveModelAttribute(context, model);
    final boolean defaultMissingMethodValue = defaultMissingMethod.asBoolean();
    this.missingMethodPermissionsDenyAccessMergingProcessor.setDenyAccessByDefault(
        defaultMissingMethodValue);

    context.addStep(
        new AbstractDeploymentChainStep() {
          @Override
          protected void execute(DeploymentProcessorTarget processorTarget) {

            // DUP's that are used even for app client deployments
            processorTarget.addDeploymentProcessor(
                EJB3Extension.SUBSYSTEM_NAME,
                Phase.STRUCTURE,
                Phase.STRUCTURE_REGISTER_JBOSS_ALL_EJB,
                new JBossAllXmlParserRegisteringProcessor<EjbJarMetaData>(
                    EjbJarJBossAllParser.ROOT_ELEMENT,
                    EjbJarJBossAllParser.ATTACHMENT_KEY,
                    new EjbJarJBossAllParser()));
            processorTarget.addDeploymentProcessor(
                EJB3Extension.SUBSYSTEM_NAME,
                Phase.PARSE,
                Phase.PARSE_EJB_DEFAULT_DISTINCT_NAME,
                new EjbDefaultDistinctNameProcessor(defaultDistinctNameService));
            processorTarget.addDeploymentProcessor(
                EJB3Extension.SUBSYSTEM_NAME,
                Phase.PARSE,
                Phase.PARSE_EJB_CONTEXT_BINDING,
                new EjbContextJndiBindingProcessor());
            processorTarget.addDeploymentProcessor(
                EJB3Extension.SUBSYSTEM_NAME,
                Phase.PARSE,
                Phase.PARSE_EJB_DEPLOYMENT,
                new EjbJarParsingDeploymentUnitProcessor());
            processorTarget.addDeploymentProcessor(
                EJB3Extension.SUBSYSTEM_NAME,
                Phase.PARSE,
                Phase.PARSE_CREATE_COMPONENT_DESCRIPTIONS,
                new AnnotatedEJBComponentDescriptionDeploymentUnitProcessor(appclient));
            processorTarget.addDeploymentProcessor(
                EJB3Extension.SUBSYSTEM_NAME,
                Phase.PARSE,
                Phase.PARSE_EJB_SESSION_BEAN_DD,
                new SessionBeanXmlDescriptorProcessor(appclient));
            processorTarget.addDeploymentProcessor(
                EJB3Extension.SUBSYSTEM_NAME,
                Phase.PARSE,
                Phase.PARSE_ANNOTATION_EJB,
                new EjbAnnotationProcessor());
            processorTarget.addDeploymentProcessor(
                EJB3Extension.SUBSYSTEM_NAME,
                Phase.PARSE,
                Phase.PARSE_EJB_INJECTION_ANNOTATION,
                new EjbResourceInjectionAnnotationProcessor(appclient));
            processorTarget.addDeploymentProcessor(
                EJB3Extension.SUBSYSTEM_NAME,
                Phase.PARSE,
                Phase.PARSE_EJB_ASSEMBLY_DESC_DD,
                new AssemblyDescriptorProcessor());

            processorTarget.addDeploymentProcessor(
                EJB3Extension.SUBSYSTEM_NAME,
                Phase.DEPENDENCIES,
                Phase.DEPENDENCIES_EJB,
                new EjbDependencyDeploymentUnitProcessor());
            processorTarget.addDeploymentProcessor(
                EJB3Extension.SUBSYSTEM_NAME,
                Phase.POST_MODULE,
                Phase.POST_MODULE_EJB_HOME_MERGE,
                new HomeViewMergingProcessor(appclient));
            processorTarget.addDeploymentProcessor(
                EJB3Extension.SUBSYSTEM_NAME,
                Phase.POST_MODULE,
                Phase.POST_MODULE_EJB_REF,
                new EjbRefProcessor(appclient));
            processorTarget.addDeploymentProcessor(
                EJB3Extension.SUBSYSTEM_NAME,
                Phase.POST_MODULE,
                Phase.POST_MODULE_EJB_BUSINESS_VIEW_ANNOTATION,
                new BusinessViewAnnotationProcessor(appclient));
            processorTarget.addDeploymentProcessor(
                EJB3Extension.SUBSYSTEM_NAME,
                Phase.POST_MODULE,
                Phase.POST_MODULE_EJB_ORB_BIND,
                new IIOPJndiBindingProcessor());
            processorTarget.addDeploymentProcessor(
                EJB3Extension.SUBSYSTEM_NAME,
                Phase.POST_MODULE,
                Phase.POST_MODULE_EJB_JNDI_BINDINGS,
                new EjbJndiBindingsDeploymentUnitProcessor(appclient));
            processorTarget.addDeploymentProcessor(
                EJB3Extension.SUBSYSTEM_NAME,
                Phase.POST_MODULE,
                Phase.POST_MODULE_EJB_CLIENT_METADATA,
                new EJBClientDescriptorMetaDataProcessor());
            processorTarget.addDeploymentProcessor(
                EJB3Extension.SUBSYSTEM_NAME,
                Phase.POST_MODULE,
                Phase.POST_MODULE_EJB_DEFAULT_SECURITY_DOMAIN,
                EJB3SubsystemAdd.this.defaultSecurityDomainDeploymentProcessor);
            processorTarget.addDeploymentProcessor(
                EJB3Extension.SUBSYSTEM_NAME,
                Phase.POST_MODULE,
                Phase.POST_MODULE_EE_COMPONENT_SUSPEND,
                new EJBComponentSuspendDeploymentUnitProcessor());
            processorTarget.addDeploymentProcessor(
                EJB3Extension.SUBSYSTEM_NAME,
                Phase.POST_MODULE,
                Phase.POST_MODULE_EE_COMPONENT_SUSPEND + 1,
                new EjbClientContextSetupProcessor()); // TODO: real phase numbers

            processorTarget.addDeploymentProcessor(
                EJB3Extension.SUBSYSTEM_NAME,
                Phase.INSTALL,
                Phase.INSTALL_EJB_JACC_PROCESSING,
                new JaccEjbDeploymentProcessor());

            processorTarget.addDeploymentProcessor(
                EJB3Extension.SUBSYSTEM_NAME,
                Phase.CLEANUP,
                Phase.CLEANUP_EJB,
                new EjbCleanUpProcessor());

            if (!appclient) {
              // add the metadata parser deployment processor

              // Process @DependsOn after the @Singletons have been registered.
              processorTarget.addDeploymentProcessor(
                  EJB3Extension.SUBSYSTEM_NAME,
                  Phase.PARSE,
                  Phase.PARSE_EJB_TIMERSERVICE_BINDING,
                  new TimerServiceJndiBindingProcessor());
              processorTarget.addDeploymentProcessor(
                  EJB3Extension.SUBSYSTEM_NAME,
                  Phase.PARSE,
                  Phase.PARSE_EJB_APPLICATION_EXCEPTION_ANNOTATION,
                  new ApplicationExceptionAnnotationProcessor());
              processorTarget.addDeploymentProcessor(
                  EJB3Extension.SUBSYSTEM_NAME,
                  Phase.PARSE,
                  Phase.PARSE_EJB_DD_INTERCEPTORS,
                  new InterceptorClassDeploymentDescriptorProcessor());
              processorTarget.addDeploymentProcessor(
                  EJB3Extension.SUBSYSTEM_NAME,
                  Phase.PARSE,
                  Phase.PARSE_EJB_SECURITY_ROLE_REF_DD,
                  new SecurityRoleRefDDProcessor());
              processorTarget.addDeploymentProcessor(
                  EJB3Extension.SUBSYSTEM_NAME,
                  Phase.PARSE,
                  Phase.PARSE_PASSIVATION_ANNOTATION,
                  new PassivationAnnotationParsingProcessor());

              processorTarget.addDeploymentProcessor(
                  EJB3Extension.SUBSYSTEM_NAME,
                  Phase.POST_MODULE,
                  Phase.POST_MODULE_EJB_IMPLICIT_NO_INTERFACE_VIEW,
                  new ImplicitLocalViewProcessor());
              processorTarget.addDeploymentProcessor(
                  EJB3Extension.SUBSYSTEM_NAME,
                  Phase.POST_MODULE,
                  Phase.POST_MODULE_EJB_APPLICATION_EXCEPTIONS,
                  new ApplicationExceptionMergingProcessor());
              processorTarget.addDeploymentProcessor(
                  EJB3Extension.SUBSYSTEM_NAME,
                  Phase.POST_MODULE,
                  Phase.POST_MODULE_EJB_DD_INTERCEPTORS,
                  new DeploymentDescriptorInterceptorBindingsProcessor());
              processorTarget.addDeploymentProcessor(
                  EJB3Extension.SUBSYSTEM_NAME,
                  Phase.POST_MODULE,
                  Phase.POST_MODULE_EJB_DD_METHOD_RESOLUTION,
                  new DeploymentDescriptorMethodProcessor());
              processorTarget.addDeploymentProcessor(
                  EJB3Extension.SUBSYSTEM_NAME,
                  Phase.POST_MODULE,
                  Phase.POST_MODULE_EJB_TRANSACTION_MANAGEMENT,
                  new TransactionManagementMergingProcessor());
              processorTarget.addDeploymentProcessor(
                  EJB3Extension.SUBSYSTEM_NAME,
                  Phase.POST_MODULE,
                  Phase.POST_MODULE_EJB_CONCURRENCY_MANAGEMENT_MERGE,
                  new ConcurrencyManagementMergingProcessor());
              processorTarget.addDeploymentProcessor(
                  EJB3Extension.SUBSYSTEM_NAME,
                  Phase.POST_MODULE,
                  Phase.POST_MODULE_EJB_CONCURRENCY_MERGE,
                  new EjbConcurrencyMergingProcessor());
              processorTarget.addDeploymentProcessor(
                  EJB3Extension.SUBSYSTEM_NAME,
                  Phase.POST_MODULE,
                  Phase.POST_MODULE_EJB_TX_ATTR_MERGE,
                  new TransactionAttributeMergingProcessor());
              processorTarget.addDeploymentProcessor(
                  EJB3Extension.SUBSYSTEM_NAME,
                  Phase.POST_MODULE,
                  Phase.POST_MODULE_EJB_RUN_AS_MERGE,
                  new RunAsMergingProcessor());
              processorTarget.addDeploymentProcessor(
                  EJB3Extension.SUBSYSTEM_NAME,
                  Phase.POST_MODULE,
                  Phase.POST_MODULE_EJB_RESOURCE_ADAPTER_MERGE,
                  new ResourceAdaptorMergingProcessor());
              processorTarget.addDeploymentProcessor(
                  EJB3Extension.SUBSYSTEM_NAME,
                  Phase.POST_MODULE,
                  Phase.POST_MODULE_EJB_CLUSTERED,
                  new ClusteredSingletonMergingProcessor());
              processorTarget.addDeploymentProcessor(
                  EJB3Extension.SUBSYSTEM_NAME,
                  Phase.POST_MODULE,
                  Phase.POST_MODULE_EJB_DELIVERY_ACTIVE_MERGE,
                  new MdbDeliveryMergingProcessor());
              processorTarget.addDeploymentProcessor(
                  EJB3Extension.SUBSYSTEM_NAME,
                  Phase.POST_MODULE,
                  Phase.POST_MODULE_EJB_REMOVE_METHOD,
                  new RemoveMethodMergingProcessor());
              processorTarget.addDeploymentProcessor(
                  EJB3Extension.SUBSYSTEM_NAME,
                  Phase.POST_MODULE,
                  Phase.POST_MODULE_EJB_STARTUP_MERGE,
                  new StartupMergingProcessor());
              processorTarget.addDeploymentProcessor(
                  EJB3Extension.SUBSYSTEM_NAME,
                  Phase.POST_MODULE,
                  Phase.POST_MODULE_EJB_SECURITY_DOMAIN,
                  new SecurityDomainMergingProcessor());
              processorTarget.addDeploymentProcessor(
                  EJB3Extension.SUBSYSTEM_NAME,
                  Phase.POST_MODULE,
                  Phase.POST_MODULE_EJB_SECURITY_MISSING_METHOD_PERMISSIONS,
                  missingMethodPermissionsDenyAccessMergingProcessor);
              processorTarget.addDeploymentProcessor(
                  EJB3Extension.SUBSYSTEM_NAME,
                  Phase.POST_MODULE,
                  Phase.POST_MODULE_EJB_ROLES,
                  new DeclareRolesMergingProcessor());
              processorTarget.addDeploymentProcessor(
                  EJB3Extension.SUBSYSTEM_NAME,
                  Phase.POST_MODULE,
                  Phase.POST_MODULE_METHOD_PERMISSIONS,
                  new MethodPermissionsMergingProcessor());
              processorTarget.addDeploymentProcessor(
                  EJB3Extension.SUBSYSTEM_NAME,
                  Phase.POST_MODULE,
                  Phase.POST_MODULE_EJB_STATEFUL_TIMEOUT,
                  new StatefulTimeoutMergingProcessor());
              processorTarget.addDeploymentProcessor(
                  EJB3Extension.SUBSYSTEM_NAME,
                  Phase.POST_MODULE,
                  Phase.POST_MODULE_EJB_SESSION_SYNCHRONIZATION,
                  new SessionSynchronizationMergingProcessor());
              processorTarget.addDeploymentProcessor(
                  EJB3Extension.SUBSYSTEM_NAME,
                  Phase.POST_MODULE,
                  Phase.POST_MODULE_EJB_INIT_METHOD,
                  new InitMethodMergingProcessor());
              processorTarget.addDeploymentProcessor(
                  EJB3Extension.SUBSYSTEM_NAME,
                  Phase.POST_MODULE,
                  Phase.POST_MODULE_EJB_SESSION_BEAN,
                  new SessionBeanMergingProcessor());
              processorTarget.addDeploymentProcessor(
                  EJB3Extension.SUBSYSTEM_NAME,
                  Phase.POST_MODULE,
                  Phase.POST_MODULE_EJB_SECURITY_PRINCIPAL_ROLE_MAPPING_MERGE,
                  new SecurityRolesMergingProcessor());
              processorTarget.addDeploymentProcessor(
                  EJB3Extension.SUBSYSTEM_NAME,
                  Phase.POST_MODULE,
                  Phase.POST_MODULE_LOCAL_HOME,
                  new SessionBeanHomeProcessor());
              processorTarget.addDeploymentProcessor(
                  EJB3Extension.SUBSYSTEM_NAME,
                  Phase.POST_MODULE,
                  Phase.POST_MODULE_EJB_CACHE,
                  new CacheMergingProcessor());
              processorTarget.addDeploymentProcessor(
                  EJB3Extension.SUBSYSTEM_NAME,
                  Phase.POST_MODULE,
                  Phase.POST_MODULE_EJB_SLSB_POOL_NAME_MERGE,
                  new StatelessSessionBeanPoolMergingProcessor());
              processorTarget.addDeploymentProcessor(
                  EJB3Extension.SUBSYSTEM_NAME,
                  Phase.POST_MODULE,
                  Phase.POST_MODULE_EJB_MDB_POOL_NAME_MERGE,
                  new MessageDrivenBeanPoolMergingProcessor());
              // Add the deployment unit processor responsible for processing the user application
              // specific container interceptors configured in jboss-ejb3.xml
              processorTarget.addDeploymentProcessor(
                  EJB3Extension.SUBSYSTEM_NAME,
                  Phase.POST_MODULE,
                  Phase.POST_MODULE_EJB_USER_APP_SPECIFIC_CONTAINER_INTERCEPTORS,
                  new ContainerInterceptorBindingsDDProcessor());

              processorTarget.addDeploymentProcessor(
                  EJB3Extension.SUBSYSTEM_NAME,
                  Phase.INSTALL,
                  Phase.INSTALL_DEPENDS_ON_ANNOTATION,
                  new EjbDependsOnMergingProcessor());
              processorTarget.addDeploymentProcessor(
                  EJB3Extension.SUBSYSTEM_NAME,
                  Phase.INSTALL,
                  Phase.INSTALL_DEPLOYMENT_REPOSITORY,
                  new DeploymentRepositoryProcessor());
              processorTarget.addDeploymentProcessor(
                  EJB3Extension.SUBSYSTEM_NAME,
                  Phase.INSTALL,
                  Phase.INSTALL_EJB_MANAGEMENT_RESOURCES,
                  new EjbManagementDeploymentUnitProcessor());
              processorTarget.addDeploymentProcessor(
                  EJB3Extension.SUBSYSTEM_NAME,
                  Phase.INSTALL,
                  Phase.INSTALL_CACHE_DEPENDENCIES,
                  new CacheDependenciesProcessor());
              processorTarget.addDeploymentProcessor(
                  EJB3Extension.SUBSYSTEM_NAME,
                  Phase.INSTALL,
                  Phase.INSTALL_EE_MODULE_CONFIG + 1,
                  new MdbDeliveryDependenciesProcessor()); // TODO Phase: replace by
                                                           // Phase.INSTALL_MDB_DELIVERY_DEPENDENCIES
            }
          }
        },
        OperationContext.Stage.RUNTIME);

    // todo maybe needs
    // EJB3SubsystemRootResourceDefinition.DEFAULT_MDB_INSTANCE_POOL.resolveModelAttribute(context,model).isDefined()
    if (model.hasDefined(DEFAULT_MDB_INSTANCE_POOL)) {
      EJB3SubsystemDefaultPoolWriteHandler.MDB_POOL.updatePoolService(context, model);
    }

    if (model.hasDefined(DEFAULT_SLSB_INSTANCE_POOL)) {
      EJB3SubsystemDefaultPoolWriteHandler.SLSB_POOL.updatePoolService(context, model);
    }

    if (model.hasDefined(DEFAULT_ENTITY_BEAN_INSTANCE_POOL)) {
      EJB3SubsystemDefaultPoolWriteHandler.ENTITY_BEAN_POOL.updatePoolService(context, model);
    }

    if (model.hasDefined(DEFAULT_SFSB_CACHE)) {
      EJB3SubsystemDefaultCacheWriteHandler.SFSB_CACHE.updateCacheService(context, model);
    }

    if (model.hasDefined(DEFAULT_SFSB_PASSIVATION_DISABLED_CACHE)) {
      EJB3SubsystemDefaultCacheWriteHandler.SFSB_PASSIVATION_DISABLED_CACHE.updateCacheService(
          context, model);
    }

    if (model.hasDefined(DEFAULT_RESOURCE_ADAPTER_NAME)) {
      DefaultResourceAdapterWriteHandler.INSTANCE.updateDefaultAdapterService(context, model);
    }

    if (model.hasDefined(DEFAULT_SINGLETON_BEAN_ACCESS_TIMEOUT)) {
      DefaultSingletonBeanAccessTimeoutWriteHandler.INSTANCE
          .updateOrCreateDefaultSingletonBeanAccessTimeoutService(context, model);
    }

    if (model.hasDefined(DEFAULT_STATEFUL_BEAN_ACCESS_TIMEOUT)) {
      DefaultStatefulBeanAccessTimeoutWriteHandler.INSTANCE
          .updateOrCreateDefaultStatefulBeanAccessTimeoutService(context, model);
    }

    if (model.hasDefined(DEFAULT_ENTITY_BEAN_OPTIMISTIC_LOCKING)) {
      EJB3SubsystemDefaultEntityBeanOptimisticLockingWriteHandler.INSTANCE.updateOptimisticLocking(
          context, model);
    }

    ExceptionLoggingWriteHandler.INSTANCE.updateOrCreateDefaultExceptionLoggingEnabledService(
        context, model);

    final ServiceTarget serviceTarget = context.getServiceTarget();

    context
        .getServiceTarget()
        .addService(DeploymentRepository.SERVICE_NAME, new DeploymentRepository())
        .install();

    addRemoteInvocationServices(context, model, appclient);
    // add clustering service
    addClusteringServices(context, appclient);

    // add user transaction access control service
    final EJB3UserTransactionAccessControlService userTxAccessControlService =
        new EJB3UserTransactionAccessControlService();
    context
        .getServiceTarget()
        .addService(
            EJB3UserTransactionAccessControlService.SERVICE_NAME, userTxAccessControlService)
        .addDependency(
            UserTransactionAccessControlService.SERVICE_NAME,
            UserTransactionAccessControlService.class,
            userTxAccessControlService.getUserTransactionAccessControlServiceInjector())
        .install();

    if (!appclient) {
      final EJBUtilities utilities = new EJBUtilities();
      serviceTarget
          .addService(EJBUtilities.SERVICE_NAME, utilities)
          .addDependency(
              ConnectorServices.RA_REPOSITORY_SERVICE,
              ResourceAdapterRepository.class,
              utilities.getResourceAdapterRepositoryInjector())
          .addDependency(
              SimpleSecurityManagerService.SERVICE_NAME,
              ServerSecurityManager.class,
              utilities.getSecurityManagerInjector())
          .addDependency(
              TxnServices.JBOSS_TXN_TRANSACTION_MANAGER,
              TransactionManager.class,
              utilities.getTransactionManagerInjector())
          .addDependency(
              TxnServices.JBOSS_TXN_SYNCHRONIZATION_REGISTRY,
              TransactionSynchronizationRegistry.class,
              utilities.getTransactionSynchronizationRegistryInjector())
          .addDependency(
              TxnServices.JBOSS_TXN_USER_TRANSACTION,
              UserTransaction.class,
              utilities.getUserTransactionInjector())
          .setInitialMode(ServiceController.Mode.ACTIVE)
          .install();

      // create the POA Registry use by iiop
      final POARegistry poaRegistry = new POARegistry();
      context
          .getServiceTarget()
          .addService(POARegistry.SERVICE_NAME, poaRegistry)
          .addDependency(CorbaPOAService.ROOT_SERVICE_NAME, POA.class, poaRegistry.getRootPOA())
          .setInitialMode(ServiceController.Mode.PASSIVE)
          .install();

      EnableStatisticsWriteHandler.INSTANCE.updateToRuntime(context, model);
    }
  }
 @Override
 public void execute(OperationContext context, ModelNode operation)
     throws OperationFailedException {
   if (context.getProcessType() == ProcessType.SELF_CONTAINED) {
     throw ServerLogger.ROOT_LOGGER.cannotAddContentToSelfContainedServer();
   }
   final Resource deploymentResource = context.readResourceForUpdate(PathAddress.EMPTY_ADDRESS);
   ModelNode contentItemNode = getContentItem(deploymentResource);
   // Validate this op is available
   if (!isManaged(contentItemNode)) {
     throw ServerLogger.ROOT_LOGGER.cannotAddContentToUnmanagedDeployment();
   } else if (isArchive(contentItemNode)) {
     throw ServerLogger.ROOT_LOGGER.cannotAddContentToUnexplodedDeployment();
   }
   final String managementName = context.getCurrentAddress().getLastElement().getValue();
   final PathAddress address = PathAddress.pathAddress(DEPLOYMENT, managementName);
   final byte[] oldHash = CONTENT_HASH.resolveModelAttribute(context, contentItemNode).asBytes();
   final boolean overwrite = OVERWRITE.resolveModelAttribute(context, operation).asBoolean(true);
   List<ModelNode> contents = EXPLODED_CONTENT.resolveModelAttribute(context, operation).asList();
   final List<ExplodedContent> addedFiles = new ArrayList<>(contents.size());
   final byte[] newHash;
   if (contents.size() == 1 && contents.get(0).hasDefined(HASH)) {
     newHash =
         DeploymentHandlerUtil.addFromHash(
             contentRepository, contents.get(0), managementName, address, context);
     if (operation.hasDefined(DeploymentAttributes.UPDATED_PATHS.getName())) {
       for (ModelNode addedFile :
           DeploymentAttributes.UPDATED_PATHS.resolveModelAttribute(context, operation).asList()) {
         addedFiles.add(new ExplodedContent(addedFile.asString()));
       }
     }
   } else {
     for (ModelNode content : contents) {
       InputStream in;
       if (DeploymentHandlerUtils.hasValidContentAdditionParameterDefined(content)) {
         in = DeploymentHandlerUtils.getInputStream(context, content);
       } else {
         in = null;
       }
       String path = TARGET_PATH.resolveModelAttribute(context, content).asString();
       addedFiles.add(new ExplodedContent(path, in));
     }
     try {
       newHash = contentRepository.addContentToExploded(oldHash, addedFiles, overwrite);
     } catch (ExplodedContentException e) {
       throw createFailureException(e.toString());
     }
   }
   final List<String> relativePaths =
       addedFiles.stream().map(ExplodedContent::getRelativePath).collect(Collectors.toList());
   contentItemNode.get(CONTENT_HASH.getName()).set(newHash);
   contentItemNode.get(CONTENT_ARCHIVE.getName()).set(false);
   if (!addedFiles.isEmpty()
       && ENABLED.resolveModelAttribute(context, deploymentResource.getModel()).asBoolean()) {
     context.addStep(
         new OperationStepHandler() {
           @Override
           public void execute(OperationContext context, ModelNode operation)
               throws OperationFailedException {
             try {
               ExecutorService executor =
                   (ExecutorService)
                       context
                           .getServiceRegistry(false)
                           .getRequiredService(JBOSS_SERVER_EXECUTOR)
                           .getValue();
               CountDownLatch latch = copy(executor, relativePaths, managementName, newHash);
               if (latch != null) {
                 try {
                   if (!latch.await(60, TimeUnit.SECONDS)) {
                     return;
                   }
                 } catch (InterruptedException e) {
                   Thread.currentThread().interrupt();
                   throw createFailureException(e.toString());
                 }
               }
             } catch (IOException e) {
               throw createFailureException(e.toString());
             }
           }
         },
         OperationContext.Stage.RUNTIME);
   }
   context.completeStep(
       new OperationContext.ResultHandler() {
         @Override
         public void handleResult(
             ResultAction resultAction, OperationContext context, ModelNode operation) {
           if (resultAction == ResultAction.KEEP) {
             if (oldHash != null && (newHash == null || !Arrays.equals(oldHash, newHash))) {
               // The old content is no longer used; clean from repos
               contentRepository.removeContent(
                   ModelContentReference.fromModelAddress(address, oldHash));
             }
             if (newHash != null) {
               contentRepository.addContentReference(
                   ModelContentReference.fromModelAddress(address, newHash));
             }
           } else if (newHash != null && (oldHash == null || !Arrays.equals(oldHash, newHash))) {
             // Due to rollback, the new content isn't used; clean from repos
             contentRepository.removeContent(
                 ModelContentReference.fromModelAddress(address, newHash));
           }
         }
       });
 }
    @Override
    protected void performBoottime(
        OperationContext context,
        ModelNode operation,
        ModelNode model,
        ServiceVerificationHandler verificationHandler,
        List<ServiceController<?>> newControllers)
        throws OperationFailedException {
      SecurityLogger.ROOT_LOGGER.activatingSecuritySubsystem();

      if (context.getProcessType() != ProcessType.APPLICATION_CLIENT) {
        // remove once AS7-4687 is resolved
        SecurityActions.setSystemProperty(
            SecurityContextAssociation.SECURITYCONTEXT_THREADLOCAL, "true");
      }
      final ServiceTarget target = context.getServiceTarget();

      final SecurityBootstrapService bootstrapService = new SecurityBootstrapService();
      newControllers.add(
          target
              .addService(SecurityBootstrapService.SERVICE_NAME, bootstrapService)
              .addDependency(
                  Services.JBOSS_SERVICE_MODULE_LOADER,
                  ServiceModuleLoader.class,
                  bootstrapService.getServiceModuleLoaderInjectedValue())
              .addListener(verificationHandler)
              .setInitialMode(ServiceController.Mode.ACTIVE)
              .install());

      context.addStep(
          new AbstractDeploymentChainStep() {
            protected void execute(DeploymentProcessorTarget processorTarget) {}
          },
          OperationContext.Stage.RUNTIME);

      // add service to bind SecurityDomainJndiInjectable to JNDI
      final SecurityDomainJndiInjectable securityDomainJndiInjectable =
          new SecurityDomainJndiInjectable();
      final BinderService binderService = new BinderService("jaas");
      newControllers.add(
          target
              .addService(ContextNames.JBOSS_CONTEXT_SERVICE_NAME.append("jaas"), binderService)
              .addInjection(binderService.getManagedObjectInjector(), securityDomainJndiInjectable)
              .addDependency(
                  ContextNames.JBOSS_CONTEXT_SERVICE_NAME,
                  ServiceBasedNamingStore.class,
                  binderService.getNamingStoreInjector())
              .addDependency(
                  SecurityManagementService.SERVICE_NAME,
                  ISecurityManagement.class,
                  securityDomainJndiInjectable.getSecurityManagementInjector())
              .addListener(verificationHandler)
              .setInitialMode(ServiceController.Mode.ACTIVE)
              .install());

      // add security management service
      ModelNode modelNode =
          SecuritySubsystemRootResourceDefinition.DEEP_COPY_SUBJECT_MODE.resolveModelAttribute(
              context, model);
      final SecurityManagementService securityManagementService =
          new SecurityManagementService(
              AUTHENTICATION_MANAGER,
              modelNode.isDefined() && modelNode.asBoolean(),
              CALLBACK_HANDLER,
              AUTHORIZATION_MANAGER,
              AUDIT_MANAGER,
              IDENTITY_TRUST_MANAGER,
              MAPPING_MANAGER);
      newControllers.add(
          target
              .addService(SecurityManagementService.SERVICE_NAME, securityManagementService)
              .addDependency(
                  Services.JBOSS_SERVICE_MODULE_LOADER,
                  ServiceModuleLoader.class,
                  securityManagementService.getServiceModuleLoaderInjectedValue())
              .addListener(verificationHandler)
              .setInitialMode(ServiceController.Mode.ACTIVE)
              .install());

      // add subject factory service
      final SubjectFactoryService subjectFactoryService =
          new SubjectFactoryService(SUBJECT_FACTORY);
      newControllers.add(
          target
              .addService(SubjectFactoryService.SERVICE_NAME, subjectFactoryService)
              .addDependency(
                  SecurityManagementService.SERVICE_NAME,
                  ISecurityManagement.class,
                  subjectFactoryService.getSecurityManagementInjector())
              .addListener(verificationHandler)
              .setInitialMode(ServiceController.Mode.ACTIVE)
              .install());

      // add jaas configuration service
      Configuration loginConfig = XMLLoginConfigImpl.getInstance();
      final JaasConfigurationService jaasConfigurationService =
          new JaasConfigurationService(loginConfig);
      newControllers.add(
          target
              .addService(JaasConfigurationService.SERVICE_NAME, jaasConfigurationService)
              .addListener(verificationHandler)
              .setInitialMode(ServiceController.Mode.ACTIVE)
              .install());

      // add Simple Security Manager Service
      final SimpleSecurityManagerService simpleSecurityManagerService =
          new SimpleSecurityManagerService();

      newControllers.add(
          target
              .addService(SimpleSecurityManagerService.SERVICE_NAME, simpleSecurityManagerService)
              .addDependency(
                  SecurityManagementService.SERVICE_NAME,
                  ISecurityManagement.class,
                  simpleSecurityManagerService.getSecurityManagementInjector())
              .addListener(verificationHandler)
              .install());

      context.addStep(
          new AbstractDeploymentChainStep() {
            protected void execute(DeploymentProcessorTarget processorTarget) {
              processorTarget.addDeploymentProcessor(
                  SecurityExtension.SUBSYSTEM_NAME,
                  Phase.INSTALL,
                  Phase.INSTALL_JACC_POLICY,
                  new JaccEarDeploymentProcessor());
              processorTarget.addDeploymentProcessor(
                  SecurityExtension.SUBSYSTEM_NAME,
                  Phase.DEPENDENCIES,
                  Phase.DEPENDENCIES_SECURITY,
                  new SecurityDependencyProcessor());
            }
          },
          OperationContext.Stage.RUNTIME);
    }