org.jboss.as.controller.PathAddress Java Examples

The following examples show how to use org.jboss.as.controller.PathAddress. 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: ModifiableRealmDecorator.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Try to obtain a {@link ModifiableSecurityRealm} based on the given {@link OperationContext}.
 *
 * @param context the current context
 * @return the current security realm
 * @throws OperationFailedException if any error occurs obtaining the reference to the security realm.
 */
static ModifiableSecurityRealm getModifiableSecurityRealm(OperationContext context) throws OperationFailedException {
    ServiceRegistry serviceRegistry = context.getServiceRegistry(true);
    PathAddress currentAddress = context.getCurrentAddress();
    RuntimeCapability<Void> runtimeCapability = MODIFIABLE_SECURITY_REALM_RUNTIME_CAPABILITY.fromBaseCapability(currentAddress.getLastElement().getValue());
    ServiceName realmName = runtimeCapability.getCapabilityServiceName();
    ServiceController<ModifiableSecurityRealm> serviceController = getRequiredService(serviceRegistry, realmName, ModifiableSecurityRealm.class);
    if ( serviceController.getState() != ServiceController.State.UP ){
        try {
            serviceController.awaitValue(500, TimeUnit.MILLISECONDS);
        } catch (IllegalStateException | InterruptedException | TimeoutException e) {
            throw ROOT_LOGGER.requiredServiceNotUp(serviceController.getName(), serviceController.getState());
        }
    }
    return serviceController.getValue();
}
 
Example #2
Source File: SyncModelOperationHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
List<ModelNode> getReverseList() {
    //This is the opposite order. Due to how the steps get added, once run we will do them in the following order:
    //  extension removes, extension adds, non-extension composite
    //  The non-extension composite in turn will do removes first, and then adds
    final List<ModelNode> result = new ArrayList<>();
    final ModelNode nonExtensionComposite = Util.createEmptyOperation(COMPOSITE, PathAddress.EMPTY_ADDRESS);
    final ModelNode nonExtensionSteps = nonExtensionComposite.get(STEPS).setEmptyList();
    final ListIterator<ModelNode> it = nonExtensionRemoves.listIterator(nonExtensionRemoves.size());
    while (it.hasPrevious()) {
        nonExtensionSteps.add(it.previous());
    }
    for (ModelNode op : nonExtensionAdds) {
        nonExtensionSteps.add(op);
    }
    if (nonExtensionSteps.asList().size() > 0) {
        result.add(nonExtensionComposite);
    }
    result.addAll(extensionAdds);
    result.addAll(extensionRemoves);
    return result;
}
 
Example #3
Source File: ProfileTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Test
public void testBadProfileIncludesWrite() throws Exception {

    KernelServices kernelServices = createKernelServicesBuilder(TestModelType.DOMAIN)
            .setXmlResource("domain.xml")
            .build();
    Assert.assertTrue(kernelServices.isSuccessfulBoot());

    PathAddress addr = PathAddress.pathAddress(PROFILE, "testA");
    ModelNode list = new ModelNode().add("bad-profile");
    ModelNode op = Util.getWriteAttributeOperation(addr, INCLUDES, list);
    ModelNode response = kernelServices.executeOperation(op);
    Assert.assertEquals(response.toString(), FAILED, response.get(OUTCOME).asString());
    Assert.assertTrue(response.toString(), response.get(FAILURE_DESCRIPTION).asString().contains("WFLYCTL0369"));

    ProfileUtils.executeDescribeProfile(kernelServices, "testA");
}
 
Example #4
Source File: ReadResourceDescriptionAccessControlTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Test
public void testDeepRecursiveReadResourceDefinitionReadWriteSensitivityAsMonitor() throws Exception {
    SensitiveTargetAccessConstraintDefinition constraint = createSensitivityConstraint("testDeepRecursiveReadResourceDefinitionReadWriteSensitivityAsMonitor", false, true, true);
    registerDeepResource(constraint);

    ModelNode op = createReadResourceDescriptionOperation(PathAddress.EMPTY_ADDRESS, StandardRole.MONITOR, false);
    ModelNode result = executeForResult(op);
    ResourceAccessControl accessControl = getResourceAccessControl(result);
    checkResourcePermissions(accessControl.defaultControl, true, false);
    ModelNode childDesc = getChildDescription(result, ONE);
    accessControl = getResourceAccessControl(childDesc);
    checkResourcePermissions(accessControl.defaultControl, false, false);
    childDesc = getChildDescription(childDesc, TWO);
    accessControl = getResourceAccessControl(childDesc);
    checkResourcePermissions(accessControl.defaultControl, false, false);
}
 
Example #5
Source File: TransformersImpl.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public Resource transformRootResource(TransformationInputs transformationInputs, Resource resource, ResourceIgnoredTransformationRegistry ignoredTransformationRegistry) throws OperationFailedException {
    // Transform the path address
    final PathAddress original = PathAddress.EMPTY_ADDRESS;
    final PathAddress transformed = transformAddress(original, target);
    final ResourceTransformationContext context = ResourceTransformationContextImpl.create(transformationInputs, target, transformed, original, ignoredTransformationRegistry);
    final ResourceTransformer transformer = target.resolveTransformer(context, original);
    if(transformer == null) {

        ControllerLogger.ROOT_LOGGER.tracef("resource %s does not need transformation", resource);
        return resource;
    }
    transformer.transformResource(context, transformed, resource);
    context.getLogger().flushLogQueue();
    return context.getTransformedRoot();
}
 
Example #6
Source File: SyncModelOperationHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void process(Node rootNode, final List<ModelNode> operations,
                     OrderedChildTypesAttachment orderedChildTypesAttachment) {

    for (final ModelNode operation : operations) {
        final String operationName = operation.get(OP).asString();
        final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
        final Node node;
        if (address.size() == 0) {
            node = rootNode;
        } else {
            node = rootNode.getOrCreate(null, address.iterator(), PathAddress.EMPTY_ADDRESS, orderedChildTypesAttachment);
        }
        if (operationName.equals(ADD)) {
            node.add = operation;
        } else if (operationName.equals(WRITE_ATTRIBUTE_OPERATION)) {
            final String name = operation.get(NAME).asString();
            node.attributes.put(name, operation);
        } else {
            node.operations.add(operation);
        }
    }
}
 
Example #7
Source File: ModelControllerMBeanHelper.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private Object getAttribute(final ManagementModelIntegration.ResourceAndRegistration reg, final PathAddress address, final String attribute, final ResourceAccessControl accessControl)  throws ReflectionException, AttributeNotFoundException, InstanceNotFoundException {
    final ImmutableManagementResourceRegistration registration = getMBeanRegistration(address, reg);
    final Map<String, AttributeAccess> attributes = registration.getAttributes(PathAddress.EMPTY_ADDRESS);
    final String attributeName = findAttributeName(attributes.keySet(), attribute);

    if (!accessControl.isReadableAttribute(attributeName)) {
        throw JmxLogger.ROOT_LOGGER.notAuthorizedToReadAttribute(attributeName);
    }


    ModelNode op = new ModelNode();
    op.get(OP).set(READ_ATTRIBUTE_OPERATION);
    op.get(OP_ADDR).set(address.toModelNode());
    op.get(NAME).set(attributeName);
    ModelNode result = execute(op);
    String error = getFailureDescription(result);
    if (error != null) {
        throw new AttributeNotFoundException(error);
    }
    ModelNode attrDesc = getAttributeDescription(attributeName, registration, attributes);
    return converters.fromModelNode(attrDesc, result.get(RESULT));
}
 
Example #8
Source File: LoggingDependenciesTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@After
public void stopContainer() throws Exception {
    // No need to undeploy the deployment should be in error, but check the deployments and undeploy if necessary,
    // for example if the test failed
    final ModelNode op = Operations.createReadResourceOperation(PathAddress.pathAddress("deployment", "*").toModelNode());
    final List<ModelNode> result = Operations.readResult(executeOperation(op)).asList();
    if (!result.isEmpty()) {
        try {
            undeploy();
        } catch (ServerDeploymentException e) {
            log.warn("Error undeploying", e);
        }
    }

    executeOperation(Operations.createWriteAttributeOperation(createAddress(), API_DEPENDENCIES, true));
    container.stop();
}
 
Example #9
Source File: SlaveReconnectTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private boolean checkHostServersStarted(DomainClient masterClient, String host) {
    try {
        ModelNode op = Util.createEmptyOperation(READ_CHILDREN_NAMES_OPERATION, PathAddress.pathAddress(HOST, host));
        op.get(CHILD_TYPE).set(SERVER);
        ModelNode ret = DomainTestUtils.executeForResult(op, masterClient);
        List<ModelNode> list = ret.asList();
        for (ModelNode entry : list) {
            String server = entry.asString();
            op = Util.createEmptyOperation(READ_ATTRIBUTE_OPERATION, PathAddress.pathAddress(HOST, host).append(SERVER, server));
            op.get(NAME).set("server-state");
            ModelNode state = DomainTestUtils.executeForResult(op, masterClient);
            return "running".equals(state.asString());
        }
        return false;
    } catch (Exception e) {
        return false;
    }
}
 
Example #10
Source File: ManagedDeploymentReadContentHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@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 contentPath = CONTENT_PATH.resolveModelAttribute(context, operation);
    final String path = contentPath.isDefined() ? contentPath.asString() : "";
    try {
        TypedInputStream inputStream = contentRepository.readContent(deploymentHash, path);
        String uuid = context.attachResultStream(inputStream.getContentType(), inputStream);
        context.getResult().get(UUID).set(uuid);
    } catch (ExplodedContentException ex) {
        throw new OperationFailedException(ex.getMessage());
    }
}
 
Example #11
Source File: ProxyControllerRegistration.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
    ManagementResourceRegistration getResourceRegistration(ListIterator<PathElement> iterator) {
        // BES 2011/06/14 I do not see why the IAE makes sense, so...
//        if (!iterator.hasNext()) {
//            return this;
//        }
//        throw new IllegalArgumentException("Can't get child registrations of a proxy");
        PathAddress childAddress = null;
        if (iterator.hasNext()) {
            childAddress = getPathAddress();
            while (iterator.hasNext()) {
                childAddress = childAddress.append(iterator.next());
            }
        }
        checkPermission();
        return childAddress == null ? this : new ChildRegistration(childAddress);
    }
 
Example #12
Source File: ResourceTransformationContextImpl.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
protected ResourceTransformer resolveTransformer(TransformerEntry entry, PathAddress address) {
    final ResourceTransformer transformer;
    try {
        transformer = entry.getResourceTransformer();
    } catch (NullPointerException e) {
        //Temp for WFCORE-1270 to get some more information
        NullPointerException npe = new NullPointerException("NPE for " + address);
        npe.setStackTrace(e.getStackTrace());
        throw npe;
    }
    if (transformer == null) {
        final ImmutableManagementResourceRegistration childReg = originalModel.getRegistration(address);
        if (childReg == null) {
            return ResourceTransformer.DISCARD;
        }
        if (childReg.isRemote() || childReg.isRuntimeOnly()) {
            return ResourceTransformer.DISCARD;
        }
        return ResourceTransformer.DEFAULT;
    }
    return transformer;
}
 
Example #13
Source File: AttributesTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Test
public void testNameFromAddressConverter() throws Exception {
    //Set up the model
    resourceModel.get("value").set("test");

    final ResourceTransformationDescriptionBuilder builder = TransformationDescriptionBuilder.Factory.createInstance(PATH);
    builder.getAttributeBuilder().setValueConverter(AttributeConverter.NAME_FROM_ADDRESS, "name").end();
    TransformationDescription.Tools.register(builder.build(), transformersSubRegistration);

    final Resource resource = transformResource();
    Assert.assertNotNull(resource);
    final Resource toto = resource.getChild(PATH);
    Assert.assertNotNull(toto);
    final ModelNode model = toto.getModel();
    Assert.assertEquals(2, model.keys().size());
    Assert.assertEquals("test", model.get("value").asString());
    Assert.assertEquals(PATH.getValue(), model.get("name").asString());

    ModelNode add = Util.createAddOperation(PathAddress.pathAddress(PATH));
    add.get("value").set("test");
    OperationTransformer.TransformedOperation transformedAdd = transformOperation(add);
    Assert.assertEquals("test", transformedAdd.getTransformedOperation().get("value").asString());
    Assert.assertEquals(PATH.getValue(), transformedAdd.getTransformedOperation().get("name").asString());

    //No point in testing write-attribute for a new attribute
}
 
Example #14
Source File: PeriodicRotatingFileAuditLogHandlerResourceDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static ModelNode createServerAddOperation(final PathAddress address, final ModelNode fileHandler){
    ModelNode add = Util.createAddOperation(address);
    for (AttributeDefinition def : FULL_ATTRIBUTES) {
        if (fileHandler.get(def.getName()).isDefined()) {
            add.get(def.getName()).set(fileHandler.get(def.getName()));
        }
    }
    return add;
}
 
Example #15
Source File: DomainDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) {
    super.performRuntime(context, operation, model);
    if (context.isResourceServiceRestartAllowed()) {
        final PathAddress address = context.getCurrentAddress();
        final String name = address.getLastElement().getValue();
        context.removeService(serviceName(name, address).append(INITIAL));
    }
}
 
Example #16
Source File: CapabilityScope.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Create a {@code CapabilityScope} appropriate for the given process type and address
 *
 * @param processType the type of process in which the {@code CapabilityScope} exists
 * @param address the address with which the {@code CapabilityScope} is associated
 */
public static CapabilityScope create(ProcessType processType, PathAddress address) {
    CapabilityScope context = CapabilityScope.GLOBAL;
    PathElement pe = processType.isServer() || address.size() == 0 ? null : address.getElement(0);
    if (pe != null) {
        String type = pe.getKey();
        switch (type) {
            case PROFILE: {
                context = address.size() == 1 ? ProfilesCapabilityScope.INSTANCE : new ProfileChildCapabilityScope(pe.getValue());
                break;
            }
            case SOCKET_BINDING_GROUP: {
                context = address.size() == 1 ? SocketBindingGroupsCapabilityScope.INSTANCE : new SocketBindingGroupChildScope(pe.getValue());
                break;
            }
            case HOST: {
                if (address.size() >= 2) {
                    PathElement hostElement = address.getElement(1);
                    final String hostType = hostElement.getKey();
                    switch (hostType) {
                        case SUBSYSTEM:
                        case SOCKET_BINDING_GROUP:
                            context = HostCapabilityScope.INSTANCE;
                            break;
                        case SERVER_CONFIG:
                            context = ServerConfigCapabilityScope.INSTANCE;
                    }
                }
                break;
            }
            case SERVER_GROUP :  {
                context = ServerGroupsCapabilityScope.INSTANCE;
                break;
            }
        }
    }
    return context;

}
 
Example #17
Source File: IgnoredResourcesProfileCloneTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static void reloadSlave(DomainLifecycleUtil slaveLifecycleUtil) throws Exception {
    ModelNode reload = Util.createEmptyOperation("reload", PathAddress.pathAddress(HOST, "slave"));
    reload.get(RESTART_SERVERS).set(false);
    reload.get(ADMIN_ONLY).set(false);
    slaveLifecycleUtil.executeAwaitConnectionClosed(reload);
    slaveLifecycleUtil.connect();
    slaveLifecycleUtil.awaitHostController(System.currentTimeMillis());
}
 
Example #18
Source File: AbstractConfigurationChangesTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public List<ModelNode> readConfigurationChanges(DomainClient client, PathElement prefix) throws IOException {
    PathAddress address = getAddress();
    if (prefix != null) {
        address = PathAddress.pathAddress().append(prefix).append(getAddress());
    }
    ModelNode readConfigChanges = Util.createOperation(LegacyConfigurationChangeResourceDefinition.OPERATION_NAME, address);
    ModelNode response = client.execute(readConfigChanges);
    assertThat(response.asString(), response.get(ClientConstants.OUTCOME).asString(), is(ClientConstants.SUCCESS));
    logger.info("For " + prefix + " we have " + response.get(ClientConstants.RESULT));
    return response.get(ClientConstants.RESULT).asList();
}
 
Example #19
Source File: ServerConfigTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testAddServerConfigBadServerGroup() throws Exception {

    KernelServices kernelServices = createKernelServices("host.xml");

    PathAddress pa = PathAddress.pathAddress(PathElement.pathElement(HOST, MASTER), PathElement.pathElement(SERVER_CONFIG, "server-four"));

    final ModelNode operation = Util.createAddOperation(pa);
    operation.get(GROUP).set("bad-group");

    ModelNode response = kernelServices.executeOperation(operation);
    Assert.assertEquals(response.toString(), FAILED, response.get(OUTCOME).asString());
    Assert.assertTrue(response.toString(), response.get(FAILURE_DESCRIPTION).asString().contains("WFLYCTL0369"));
}
 
Example #20
Source File: AuthorizedAddressTest.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Test of authorizeAddress method, of class AuthorizedAddress.
 */
@Test
public void testAccessAuthorizedAddress() {
    ModelNode address = PathAddress.pathAddress(PathElement.pathElement(DEPLOYMENT,"test.war"), PathElement.pathElement(SUBSYSTEM, "Undertow")).toModelNode();
    ModelNode authorizedAddress = address;
    OperationContext context = new AuthorizationOperationContext(authorizedAddress.asString());
    ModelNode operation = new ModelNode();
    operation.get(OP).set(READ_RESOURCE_OPERATION);
    operation.get(OP_ADDR).set(address);
    AuthorizedAddress expResult = new AuthorizedAddress(authorizedAddress, false);
    AuthorizedAddress result = AuthorizedAddress.authorizeAddress(context, operation);
    assertEquals(expResult, result);
}
 
Example #21
Source File: SocketBindingGroupIncludesHandlerTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testIncludesWithOverriddenSocketBindings() throws Exception {
    try {
        //Here we test changing the includes attribute value
        //Testing what happens when adding subsystems at runtime becomes a bit too hard to mock up
        //so we test that in ServerManagementTestCase
        PathAddress addr = getSocketBindingGroupAddress("binding-four");
        ModelNode list = new ModelNode().add("binding-three");
        ModelNode op = Util.getWriteAttributeOperation(addr, INCLUDES, list);
        MockOperationContext operationContext = getOperationContextForSocketBindingIncludes(addr, new RootResourceInitializer() {
            @Override
            public void addAdditionalResources(Resource root) {
                Resource subsystemA = Resource.Factory.create();
                root.getChild(PathElement.pathElement(SOCKET_BINDING_GROUP, "binding-three"))
                        .registerChild(PathElement.pathElement(SOCKET_BINDING, "a"), subsystemA);

                Resource subsystemB = Resource.Factory.create();
                Resource SocketBindingGroup4 = root.getChild(PathElement.pathElement(SOCKET_BINDING_GROUP, "binding-four"));
                SocketBindingGroup4.registerChild(PathElement.pathElement(SOCKET_BINDING, "a"), subsystemB);
            }
        });
        SocketBindingGroupResourceDefinition.createIncludesValidationHandler().execute(operationContext, op);
        operationContext.executeNextStep();
        Assert.fail("Expected error");
    } catch (OperationFailedException expected) {
        Assert.assertTrue(expected.getMessage().contains("166"));
        Assert.assertTrue(expected.getMessage().contains("'binding-four'"));
        Assert.assertTrue(expected.getMessage().contains("'binding-three'"));
        Assert.assertTrue(expected.getMessage().contains("'a'"));
    }
}
 
Example #22
Source File: AbstractClassificationResource.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public Resource navigate(PathAddress address) {
    if (address.size() == 0) {
        return this;
    } else {
        Resource child = requireChild(address.getElement(0));
        return address.size() == 1 ? child : child.navigate(address.subAddress(1));
    }
}
 
Example #23
Source File: OperationTimeoutTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@BeforeClass
public static void setupDomain() throws Exception {

    // We can't use the standard config or make this part of a TestSuite because we need to
    // set TIMEOUT_ADDER_CONFIG on the HC processes. There's no management API to do this post-boot
    final DomainTestSupport.Configuration configuration = DomainTestSupport.Configuration.create(OperationTimeoutTestCase.class.getSimpleName(),
        "domain-configs/domain-standard.xml", "host-configs/host-master.xml", "host-configs/host-slave.xml");
    configuration.getMasterConfiguration().addHostCommandLineProperty(TIMEOUT_CONFIG);
    configuration.getMasterConfiguration().addHostCommandLineProperty(TIMEOUT_ADDER_CONFIG);
    configuration.getSlaveConfiguration().addHostCommandLineProperty(TIMEOUT_CONFIG);
    configuration.getSlaveConfiguration().addHostCommandLineProperty(TIMEOUT_ADDER_CONFIG);

    testSupport = DomainTestSupport.create(configuration);

    testSupport.start();
    masterClient = testSupport.getDomainMasterLifecycleUtil().getDomainClient();

    // Initialize the test extension
    ExtensionSetup.initializeBlockerExtension(testSupport);

    ModelNode addExtension = Util.createAddOperation(PathAddress.pathAddress(PathElement.pathElement(EXTENSION, BlockerExtension.MODULE_NAME)));

    executeForResult(safeTimeout(addExtension), masterClient);

    ModelNode addSubsystem = Util.createAddOperation(PathAddress.pathAddress(
            PathElement.pathElement(PROFILE, "default"),
            PathElement.pathElement(SUBSYSTEM, BlockerExtension.SUBSYSTEM_NAME)));
    executeForResult(safeTimeout(addSubsystem), masterClient);

    restoreServerTimeouts("master", "main-one");
    restoreServerTimeouts("slave", "main-three");

    // Confirm that the timeout properties are what we expect on each process
    validateTimeoutProperties("master", null, "1", "1000");
    validateTimeoutProperties("slave", null, "1", "1000");
    validateTimeoutProperties("master", "main-one", "300", "5000");
    validateTimeoutProperties("slave", "main-three", "300", "5000");
}
 
Example #24
Source File: JmxAuditLogHandlerReferenceResourceDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private boolean lookForResource(final Resource root, final PathAddress pathAddress) {
    Resource current = root;
    for (PathElement element : pathAddress) {
        current = current.getChild(element);
        if (current == null) {
            return false;
        }
    }
    return true;
}
 
Example #25
Source File: RemoteOutboundConnectionWriteHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode resolvedValue, ModelNode currentValue, HandbackHolder<Boolean> handbackHolder) throws OperationFailedException {
    final ModelNode model = Resource.Tools.readModel(context.readResource(PathAddress.EMPTY_ADDRESS));
    boolean handback = applyModelToRuntime(context, operation, model);
    handbackHolder.setHandback(handback);
    return handback;

}
 
Example #26
Source File: OperationCancellationTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@AfterClass
public static void tearDownDomain() throws Exception {
    ModelNode removeSubsystem = Util.createEmptyOperation(REMOVE, PathAddress.pathAddress(
            PathElement.pathElement(PROFILE, "default"),
            SUBSYSTEM_ELEMENT));
    executeForResult(removeSubsystem, masterClient);

    PathAddress extensionAddress = PathAddress.pathAddress(EXTENSION, BlockerExtension.MODULE_NAME);
    ModelNode removeExtension = Util.createEmptyOperation(REMOVE, extensionAddress);
    executeForResult(removeExtension, masterClient);

    ModelNode removeSlaveSubsystem = Util.createEmptyOperation(REMOVE, SLAVE_ADDRESS.append(SUBSYSTEM_ELEMENT));
    executeForResult(removeSlaveSubsystem, masterClient);

    ModelNode removeSlaveExtension = Util.createEmptyOperation(REMOVE, SLAVE_ADDRESS.append(extensionAddress));
    executeForResult(removeSlaveExtension, masterClient);

    ModelNode removeMasterSubsystem = Util.createEmptyOperation(REMOVE, MASTER_ADDRESS.append(SUBSYSTEM_ELEMENT));
    executeForResult(removeMasterSubsystem, masterClient);

    ModelNode removeMasterExtension = Util.createEmptyOperation(REMOVE, MASTER_ADDRESS.append(extensionAddress));
    executeForResult(removeMasterExtension, masterClient);

    testSupport = null;
    masterClient = null;
    DomainTestSuite.stopSupport();
}
 
Example #27
Source File: LegacyConfigurationChangeResourceDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Checks if the calling user may execute the operation. If he may then he can see it te full operation
 * parameters.
 *
 * @param context the operation context.
 * @param op the operation we are securing.
 * @return the secured operation.
 * @throws OperationFailedException
 */
private ModelNode secureOperationParameters(OperationContext context, ModelNode op) throws OperationFailedException {
    ModelNode operation = op.clone();
    OperationEntry operationEntry = context.getRootResourceRegistration().getOperationEntry(
            PathAddress.pathAddress(operation.get(OP_ADDR)), operation.get(OP).asString());
    Set<Action.ActionEffect> effects = getEffects(operationEntry);
    if (context.authorize(operation, effects).getDecision() == AuthorizationResult.Decision.PERMIT) {
        return operation;
    } else {
        ModelNode securedOperation = new ModelNode();
        securedOperation.get(OP).set(operation.get(OP));
        securedOperation.get(OP_ADDR).set(operation.get(OP_ADDR));
        return securedOperation;
    }
}
 
Example #28
Source File: LegacyConfigurationChangesHistoryTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Before
public void setConfigurationChanges() throws Exception {
    ModelControllerClient client = getModelControllerClient();
    final ModelNode add = Util.createAddOperation(PathAddress.pathAddress(ADDRESS));
    add.get("max-history").set(MAX_HISTORY_SIZE);
    getManagementClient().executeForResult(add);
    createConfigurationChanges(client);
}
 
Example #29
Source File: StandaloneDeploymentTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testDeploymentFullReplaceHandlerNoDeployment() throws Exception {
    KernelServices kernelServices = createKernelServices();

    //Now start replacing it
    ModelNode op = Util.createOperation(DeploymentFullReplaceHandler.OPERATION_NAME, PathAddress.EMPTY_ADDRESS);
    op.get(NAME).set("Test1");
    op.get(CONTENT).add(getByteContent(6, 7, 8, 9, 10));
    kernelServices.executeForFailure(op);
    kernelServices.validateOperation(op);
}
 
Example #30
Source File: DiscardAttributesTransformer.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public TransformedOperation transformOperation(TransformationContext context, PathAddress address,
        ModelNode operation) throws OperationFailedException {
    if (attributeNames.contains(operation.get(NAME).asString())
            && discardApprover.isOperationDiscardAllowed(context, address, operation)) {
        return OperationTransformer.DISCARD.transformOperation(context, address, operation);
    }
    return OperationTransformer.DEFAULT.transformOperation(context, address, operation);
}