예제 #1
0
 @Override
 protected void rollbackRuntime(
     OperationContext context,
     ModelNode operation,
     ModelNode model,
     List<ServiceController<?>> controllers) {
   ManagementUtil.updateUserDomainCallbackHandler(context, operation, true);
 }
예제 #2
0
 @Override
 protected void performRuntime(
     OperationContext context,
     ModelNode operation,
     ModelNode model,
     ServiceVerificationHandler verificationHandler,
     List<ServiceController<?>> newControllers)
     throws OperationFailedException {
   ManagementUtil.updateUserDomainCallbackHandler(context, operation, false);
 }
예제 #3
0
 @Override
 public void execute(OperationContext context, ModelNode operation)
     throws OperationFailedException {
   final List<ServiceController<?>> newControllers = new ArrayList<ServiceController<?>>();
   final String realmName = ManagementUtil.getSecurityRealmName(operation);
   final ModelNode model =
       Resource.Tools.readModel(context.readResource(PathAddress.EMPTY_ADDRESS));
   SecurityRealmAddHandler.INSTANCE.installServices(
       context, realmName, model, new ServiceVerificationHandler(), newControllers);
   context.completeStep(
       new OperationContext.RollbackHandler() {
         @Override
         public void handleRollback(OperationContext context, ModelNode operation) {
           for (ServiceController<?> sc : newControllers) {
             context.removeService(sc);
           }
         }
       });
 }
  @Override
  public void executeRuntimeStep(OperationContext context, ModelNode operation)
      throws OperationFailedException {
    final String attributeName = operation.require(ModelDescriptionConstants.NAME).asString();

    PathAddress pathAddress =
        PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR));
    String addressName = pathAddress.getElement(pathAddress.size() - 2).getValue();
    String roleName = pathAddress.getLastElement().getValue();

    final ServiceName serviceName =
        MessagingServices.getActiveMQServiceName(
            PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
    ServiceController<?> service = context.getServiceRegistry(false).getService(serviceName);
    ActiveMQServer server = ActiveMQServer.class.cast(service.getValue());
    AddressControl control =
        AddressControl.class.cast(
            server.getManagementService().getResource(ResourceNames.CORE_ADDRESS + addressName));

    if (control == null) {
      PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
      throw ControllerLogger.ROOT_LOGGER.managementResourceNotFound(address);
    }

    try {
      String rolesAsJSON = control.getRolesAsJSON();
      ModelNode res = ModelNode.fromJSONString(rolesAsJSON);
      ModelNode roles = ManagementUtil.convertSecurityRole(res);
      ModelNode matchedRole = findRole(roleName, roles);
      if (matchedRole == null || !matchedRole.hasDefined(attributeName)) {
        throw MessagingLogger.ROOT_LOGGER.unsupportedAttribute(attributeName);
      }
      boolean value = matchedRole.get(attributeName).asBoolean();
      context.getResult().set(value);
    } catch (Exception e) {
      context.getFailureDescription().set(e.getLocalizedMessage());
    }
  }