• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ClientConstants类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.jboss.as.controller.client.helpers.ClientConstants的典型用法代码示例。如果您正苦于以下问题:Java ClientConstants类的具体用法?Java ClientConstants怎么用?Java ClientConstants使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ClientConstants类属于org.jboss.as.controller.client.helpers包,在下文中一共展示了ClientConstants类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: executeReload

import org.jboss.as.controller.client.helpers.ClientConstants; //导入依赖的package包/类
private static void executeReload(ModelControllerClient client, boolean adminOnly) {
    ModelNode operation = new ModelNode();
    operation.get(OP_ADDR).setEmptyList();
    operation.get(OP).set("reload");
    operation.get("admin-only").set(adminOnly);
    try {
        ModelNode result = client.execute(operation);
        if (!"success".equals(result.get(ClientConstants.OUTCOME).asString())) {
            fail("Reload operation didn't finished successfully: " + result.asString());
        }
    } catch(IOException e) {
        final Throwable cause = e.getCause();
        if (!(cause instanceof ExecutionException) && !(cause instanceof CancellationException)) {
            throw new RuntimeException(e);
        } // else ignore, this might happen if the channel gets closed before we got the response
    }
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel-examples,代码行数:18,代码来源:ServerReload.java


示例2: testFilteringKeystoreCli

import org.jboss.as.controller.client.helpers.ClientConstants; //导入依赖的package包/类
@Test
public void testFilteringKeystoreCli() throws Exception {
    ModelNode operation = new ModelNode();
    operation.get(ClientConstants.OP_ADDR).add("subsystem","elytron").add(ElytronDescriptionConstants.FILTERING_KEY_STORE,"FilteringKeyStore");
    operation.get(ClientConstants.OP).set(ElytronDescriptionConstants.READ_ALIASES);
    List<ModelNode> nodes = assertSuccess(services.executeOperation(operation)).get(ClientConstants.RESULT).asList();
    Assert.assertEquals(1, nodes.size());
    Assert.assertEquals("firefly", nodes.get(0).asString());

    operation = new ModelNode();
    operation.get(ClientConstants.OP_ADDR).add("subsystem","elytron").add(ElytronDescriptionConstants.FILTERING_KEY_STORE,"FilteringKeyStore");
    operation.get(ClientConstants.OP).set(ElytronDescriptionConstants.READ_ALIAS);
    operation.get(ElytronDescriptionConstants.ALIAS).set("firefly");
    ModelNode firefly = assertSuccess(services.executeOperation(operation)).get(ClientConstants.RESULT);
    Assert.assertEquals("firefly", firefly.get(ElytronDescriptionConstants.ALIAS).asString());
    Assert.assertEquals(KeyStore.PrivateKeyEntry.class.getSimpleName(), firefly.get(ElytronDescriptionConstants.ENTRY_TYPE).asString());
    Assert.assertTrue(firefly.get(ElytronDescriptionConstants.CERTIFICATE_CHAIN).isDefined());
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:19,代码来源:KeyStoresTestCase.java


示例3: testDuplicateRealmValidation

import org.jboss.as.controller.client.helpers.ClientConstants; //导入依赖的package包/类
/**
 * Regression test for WFCORE-2614 - don't allow duplicating realms referenced from a single domain.
 */
@Test
public void testDuplicateRealmValidation() throws Exception {
    init();

    ModelNode realmNode = new ModelNode();

    ModelNode operation = Util.createEmptyOperation("list-add", PathAddress.pathAddress("subsystem", "elytron")
            .append(ElytronDescriptionConstants.SECURITY_DOMAIN, "MyDomain"));
    operation.get(ClientConstants.NAME).set(ElytronDescriptionConstants.REALMS);

    realmNode.get("realm").set("PropRealm");
    operation.get("value").set(realmNode);
    Assert.assertNotNull(assertFail(services.executeOperation(operation)).get(ClientConstants.RESULT).asString());

    realmNode.get("realm").set("FileRealm");
    operation.get("value").set(realmNode);
    Assert.assertNotNull(assertFail(services.executeOperation(operation)).get(ClientConstants.RESULT).asString());

    realmNode.get("realm").set("NonDomainRealm");
    operation.get("value").set(realmNode);
    Assert.assertNotNull(assertSuccess(services.executeOperation(operation)).get(ClientConstants.RESULT).asString());
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:26,代码来源:DomainTestCase.java


示例4: executeReload

import org.jboss.as.controller.client.helpers.ClientConstants; //导入依赖的package包/类
private void executeReload(StartMode startMode, String serverConfig) {
    ModelNode operation = new ModelNode();
    operation.get(OP_ADDR).setEmptyList();
    operation.get(OP).set("reload");
    if(startMode == StartMode.ADMIN_ONLY) {
        operation.get("admin-only").set(true);
    } else if(startMode == StartMode.SUSPEND) {
        operation.get("start-mode").set("suspend");
    }
    if (serverConfig != null) {
        operation.get(SERVER_CONFIG).set(serverConfig);
    }
    try {
        ModelNode result = client.getControllerClient().execute(operation);
        Assert.assertEquals("success", result.get(ClientConstants.OUTCOME).asString());
    } catch (IOException e) {
        final Throwable cause = e.getCause();
        if (!(cause instanceof ExecutionException) && !(cause instanceof CancellationException) && !(cause instanceof SocketException) ) {
            throw new RuntimeException(e);
        } // else ignore, this might happen if the channel gets closed before we got the response
    }finally {
        safeCloseClient();//close existing client
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:25,代码来源:Server.java


示例5: deploy

import org.jboss.as.controller.client.helpers.ClientConstants; //导入依赖的package包/类
/**
 * Deploys the archive to the running server.
 *
 * @param archive     the archive to deploy
 * @param runtimeName the runtime name for the deployment
 *
 * @throws IOException if an error occurs deploying the archive
 */
public static void deploy(final Archive<?> archive, final String runtimeName) throws IOException {
    // Use an operation to allow overriding the runtime name
    final ModelNode address = Operations.createAddress(DEPLOYMENT, archive.getName());
    final ModelNode addOp = createAddOperation(address);
    if (runtimeName != null && !archive.getName().equals(runtimeName)) {
        addOp.get(RUNTIME_NAME).set(runtimeName);
    }
    addOp.get("enabled").set(true);
    // Create the content for the add operation
    final ModelNode contentNode = addOp.get(CONTENT);
    final ModelNode contentItem = contentNode.get(0);
    contentItem.get(ClientConstants.INPUT_STREAM_INDEX).set(0);

    // Create an operation and add the input archive
    final OperationBuilder builder = OperationBuilder.create(addOp);
    builder.addInputStream(archive.as(ZipExporter.class).exportAsInputStream());

    // Deploy the content and check the results
    final ModelNode result = client.getControllerClient().execute(builder.build());
    if (!Operations.isSuccessfulOutcome(result)) {
        Assert.fail(String.format("Failed to deploy %s: %s", archive, Operations.getFailureDescription(result).asString()));
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:32,代码来源:AbstractLoggingTestCase.java


示例6: doesServerRequireRestart

import org.jboss.as.controller.client.helpers.ClientConstants; //导入依赖的package包/类
/**
 * Check if the server is in restart-required state, that means
 * management operation return "response-headers" : {"process-state" : "restart-required"}
 *
 * @return true if the server is in "restart-required" state
 * @throws Exception
 */
public static boolean doesServerRequireRestart() throws Exception {
    try (CLIWrapper cli = new CLIWrapper(true)) {
        cli.sendLine("patch info --json-output", true);
        String response = cli.readOutput();
        ModelNode responseNode = ModelNode.fromJSONString(response);
        ModelNode respHeaders = responseNode.get("response-headers");
        if (respHeaders != null && respHeaders.isDefined()) {
            ModelNode processState = respHeaders.get("process-state");
            return processState != null && processState.isDefined() && processState.asString()
                    .equals(ClientConstants.CONTROLLER_PROCESS_STATE_RESTART_REQUIRED);
        } else {
            return false;
        }
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:23,代码来源:CliUtilsForPatching.java


示例7: testDeployment

import org.jboss.as.controller.client.helpers.ClientConstants; //导入依赖的package包/类
private void testDeployment(final Archive<?> archive) throws IOException {
    final ModelControllerClient client = domainMasterLifecycleUtil.getDomainClient();
    final ModelNode readServerSubsystems = Operations.createOperation(ClientConstants.READ_CHILDREN_NAMES_OPERATION,
            Operations.createAddress("host", "master", "server", "main-one"));
    readServerSubsystems.get(ClientConstants.CHILD_TYPE).set(ClientConstants.SUBSYSTEM);

    final String name = archive.getName();

    // Deploy the archive
    execute(client, createDeployAddOperation(archive.as(ZipExporter.class).exportAsInputStream(), name, null));
    Assert.assertTrue("Deployment " + name + "  was not deployed.", hasDeployment(client, name));

    // Validate the subsystem child names on a server
    ModelNode result = execute(client, readServerSubsystems);
    validateSubsystemModel("/host=master/server=main-one", result);

    // Fully replace the deployment, but with the 'enabled' flag set to false, triggering undeploy
    final Operation fullReplaceOp = createReplaceAndDisableOperation(archive.as(ZipExporter.class).exportAsInputStream(), name, null);
    execute(client, fullReplaceOp);

    // Below validates that WFCORE-1577 is fixed, the model should not be missing on the /host=master/server=main-one or main-two

    // Validate the subsystem child names
    result = execute(client, readServerSubsystems);
    validateSubsystemModel("/host=master/server=main-one", result);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:27,代码来源:FullReplaceUndeployTestCase.java


示例8: hasDeployment

import org.jboss.as.controller.client.helpers.ClientConstants; //导入依赖的package包/类
private static boolean hasDeployment(final ModelControllerClient client, final String name) throws IOException {
    final ModelNode op = Operations.createOperation(ClientConstants.READ_CHILDREN_NAMES_OPERATION);
    op.get(CHILD_TYPE).set(DEPLOYMENT);
    final ModelNode listDeploymentsResult;
    try {
        listDeploymentsResult = client.execute(op);
        // Check to make sure there is an outcome
        if (Operations.isSuccessfulOutcome(listDeploymentsResult)) {
            final List<ModelNode> deployments = Operations.readResult(listDeploymentsResult).asList();
            for (ModelNode deployment : deployments) {
                if (name.equals(deployment.asString())) {
                    return true;
                }
            }
        } else {
            throw new IllegalStateException(Operations.getFailureDescription(listDeploymentsResult).asString());
        }
    } catch (IOException e) {
        throw new IllegalStateException(String.format("Could not execute operation '%s'", op), e);
    }
    return false;
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:23,代码来源:FullReplaceUndeployTestCase.java


示例9: registerAttributes

import org.jboss.as.controller.client.helpers.ClientConstants; //导入依赖的package包/类
@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {

    resourceRegistration.registerReadOnlyAttribute(ServerRootResourceDefinition.LAUNCH_TYPE, (context,operation) -> {
        readResourceServerConfig(context, operation);
        context.getResult().set(ServerEnvironment.LaunchType.DOMAIN.toString());
    });

    resourceRegistration.registerReadOnlyAttribute(ServerRootResourceDefinition.SERVER_STATE, (context, operation) -> {
        readResourceServerConfig(context, operation);
        // note this is inconsistent with the other values, should be lower case, preserved for now.
        context.getResult().set("STOPPED");
    });

    resourceRegistration.registerReadOnlyAttribute(ServerRootResourceDefinition.RUNTIME_CONFIGURATION_STATE,
            (context, operation) -> {
                readResourceServerConfig(context, operation);
                context.getResult().set(ClientConstants.CONTROLLER_PROCESS_STATE_STOPPED);
                }
            );
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:22,代码来源:StoppedServerResource.java


示例10: get

import org.jboss.as.controller.client.helpers.ClientConstants; //导入依赖的package包/类
@Override
public ServerDeploymentPlanResult get() throws InterruptedException, ExecutionException {
    boolean cleanup = true;
    ModelNode node;
    try {
        node = nodeFuture.get();
    } catch (InterruptedException ie) {
        cleanup = false;  // still may be in progress, so wait for finalize()
        throw ie;
    } finally {
        if (cleanup) {
            plan.cleanup();
        }
    }
    return getResultFromNode(node.get(ClientConstants.RESULT));
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:17,代码来源:ServerDeploymentPlanResultFuture.java


示例11: testEmptyRoot

import org.jboss.as.controller.client.helpers.ClientConstants; //导入依赖的package包/类
@Test
public void testEmptyRoot() throws Exception {
    KernelServices kernelServices = createEmptyRoot();

    ModelNode model = kernelServices.readWholeModel(false, true);
    assertAttribute(model, ModelDescriptionConstants.NAMESPACES, new ModelNode().setEmptyList());
    assertAttribute(model, ModelDescriptionConstants.SCHEMA_LOCATIONS, new ModelNode().setEmptyList());
    assertAttribute(model, ModelDescriptionConstants.NAME, new ModelNode(getDefaultServerName()));
    assertAttribute(model, ModelDescriptionConstants.PRODUCT_NAME, null);
    assertAttribute(model, ModelDescriptionConstants.PRODUCT_VERSION, null);
    assertAttribute(model, ModelDescriptionConstants.MANAGEMENT_MAJOR_VERSION, new ModelNode(Version.MANAGEMENT_MAJOR_VERSION));
    assertAttribute(model, ModelDescriptionConstants.MANAGEMENT_MINOR_VERSION, new ModelNode(Version.MANAGEMENT_MINOR_VERSION));
    assertAttribute(model, ModelDescriptionConstants.MANAGEMENT_MICRO_VERSION, new ModelNode(Version.MANAGEMENT_MICRO_VERSION));
    assertAttribute(model, ServerDescriptionConstants.PROCESS_STATE, new ModelNode("running"));
    assertAttribute(model, ServerDescriptionConstants.RUNTIME_CONFIGURATION_STATE, new ModelNode(ClientConstants.CONTROLLER_PROCESS_STATE_OK));
    assertAttribute(model, ServerDescriptionConstants.PROCESS_TYPE, new ModelNode("Server"));
    assertAttribute(model, ServerDescriptionConstants.LAUNCH_TYPE, new ModelNode("STANDALONE"));

    //These two cannot work in tests - placeholder
    assertAttribute(model, ModelDescriptionConstants.RELEASE_VERSION, new ModelNode("Unknown"));
    assertAttribute(model, ModelDescriptionConstants.RELEASE_CODENAME, new ModelNode(""));


    //Try changing namespaces, schema-locations and name
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:26,代码来源:StandaloneRootResourceTestCase.java


示例12: getServerGroupServers

import org.jboss.as.controller.client.helpers.ClientConstants; //导入依赖的package包/类
protected Set<String> getServerGroupServers(final String name) throws IOException {
    final Set<String> servers = new LinkedHashSet<>();
    final ModelNode address = Operations.createAddress(ClientConstants.HOST, "*", ClientConstants.SERVER_CONFIG, "*");
    final ModelNode op = Operations.createReadAttributeOperation(address, "group");
    final ModelNode result = executeForSuccess(op);
    for (ModelNode n : result.asList()) {
        // Get the address and parse it out as we only need the two values
        final List<ModelNode> segments = Operations.getOperationAddress(n).asList();
        // Should be at least two address segments
        if (segments.size() >= 2) {
            final String serverGroupName = Operations.readResult(n).asString();
            if (name.equals(serverGroupName)) {
                servers.add(segments.get(1).get(ClientConstants.SERVER_CONFIG).asString());
            }
        }
    }
    return Collections.unmodifiableSet(servers);
}
 
开发者ID:wildfly,项目名称:wildfly-arquillian,代码行数:19,代码来源:AbstractDomainManualModeTestCase.java


示例13: testConnection

import org.jboss.as.controller.client.helpers.ClientConstants; //导入依赖的package包/类
private String testConnection( final ModelControllerClient client ) throws Exception {
    try {
        final ModelNode op = new ModelNode( );
        op.get( ClientConstants.OP ).set( "read-resource" );

        final ModelNode returnVal = client.execute( new OperationBuilder( op ).build( ) );
        final String productName = returnVal.get( "result" ).get( "product-name" ).asString( );
        final String productVersion = returnVal.get( "result" ).get( "product-version" ).asString( );
        final String releaseVersion = returnVal.get( "result" ).get( "release-version" ).asString( );
        final String releaseCodeName = returnVal.get( "result" ).get( "release-codename" ).asString( );
        final StringBuilder stringBuilder = new StringBuilder( );
        stringBuilder.append( productName + ", " + productVersion );
        stringBuilder.append( " (" + releaseCodeName + ", " + releaseVersion + ")" );
        return stringBuilder.toString( );
    } catch ( Exception e ) {
        logger.error( "It was not possible to open connection to Wildfly/EAP server.", e );
        throw new Exception( "It was not possible to open connection to server. " + e.getMessage( ) );
    }
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:20,代码来源:WildflyBaseClient.java


示例14: getFailureDescriptionAsString

import org.jboss.as.controller.client.helpers.ClientConstants; //导入依赖的package包/类
/**
 * Parses the result and returns the failure description. If the result was successful, an empty string is
 * returned.
 *
 * @param result the result of executing an operation
 *
 * @return the failure message or an empty string
 */
public static String getFailureDescriptionAsString(final ModelNode result) {
    if (isSuccessfulOutcome(result)) {
        return "";
    }
    final String msg;
    if (result.hasDefined(ClientConstants.FAILURE_DESCRIPTION)) {
        if (result.hasDefined(ClientConstants.OP)) {
            msg = String.format("Operation '%s' at address '%s' failed: %s", result.get(ClientConstants.OP), result.get(ClientConstants.OP_ADDR), result
                    .get(ClientConstants.FAILURE_DESCRIPTION));
        } else {
            msg = String.format("Operation failed: %s", result.get(ClientConstants.FAILURE_DESCRIPTION));
        }
    } else {
        msg = String.format("An unexpected response was found checking the deployment. Result: %s", result);
    }
    return msg;
}
 
开发者ID:wildfly,项目名称:wildfly-maven-plugin,代码行数:26,代码来源:ServerOperations.java


示例15: testDeployNewServerGroup

import org.jboss.as.controller.client.helpers.ClientConstants; //导入依赖的package包/类
@Test
public void testDeployNewServerGroup() throws Exception {
    // Make sure the deployment is deployed to the main-server-group and not deployed to the other-server-group
    if (!deploymentManager.hasDeployment(DEPLOYMENT_NAME, "main-server-group")) {
        deploymentManager.deploy(getDeployment().addServerGroup("main-server-group"));
    }
    if (deploymentManager.hasDeployment(DEPLOYMENT_NAME, "other-server-group")) {
        deploymentManager.undeploy(UndeployDescription.of(DEPLOYMENT_NAME).addServerGroup("other-deployment-group"));
    }
    // Set up the other-server-group servers to ensure the full deployment process works correctly
    final ModelNode op = ServerOperations.createOperation("start-servers", ServerOperations.createAddress(ClientConstants.SERVER_GROUP, "other-server-group"));
    op.get("blocking").set(true);
    executeOperation(op);

    // Deploy to both server groups and ensure the deployment exists on both, it should already be on the
    // main-server-group and should have been added to the other-server-group
    final Set<String> serverGroups = new HashSet<>(Arrays.asList("main-server-group", "other-server-group"));
    executeAndVerifyDeploymentExists("deploy", "deploy-multi-server-group-pom.xml", null, serverGroups);
    deploymentManager.undeploy(UndeployDescription.of(DEPLOYMENT_NAME).addServerGroups(serverGroups));
}
 
开发者ID:wildfly,项目名称:wildfly-maven-plugin,代码行数:21,代码来源:DeployTest.java


示例16: of

import org.jboss.as.controller.client.helpers.ClientConstants; //导入依赖的package包/类
/**
 * Creates new deployment content based on the stream content. The stream content is copied, stored in-memory and
 * closed.
 *
 * @param content the content to deploy
 *
 * @return the deployment content
 */
static DeploymentContent of(final InputStream content) {
    final ByteArrayInputStream copiedContent = copy(content);
    return new DeploymentContent() {
        @Override
        void addContentToOperation(final OperationBuilder builder, final ModelNode op) {
            copiedContent.reset();
            final ModelNode contentNode = op.get(CONTENT);
            final ModelNode contentItem = contentNode.get(0);
            // The index is 0 based so use the input stream count before adding the input stream
            contentItem.get(ClientConstants.INPUT_STREAM_INDEX).set(builder.getInputStreamCount());
            builder.addInputStream(copiedContent);
        }

        @Override
        public String toString() {
            return String.format("%s(%s)", DeploymentContent.class.getName(), copiedContent);
        }
    };
}
 
开发者ID:wildfly,项目名称:wildfly-maven-plugin,代码行数:28,代码来源:DeploymentContent.java


示例17: testRevocationLists

import org.jboss.as.controller.client.helpers.ClientConstants; //导入依赖的package包/类
@Test
public void testRevocationLists() throws Throwable {
    ServiceName serviceName = Capabilities.TRUST_MANAGER_RUNTIME_CAPABILITY.getCapabilityServiceName("trust-with-crl");
    TrustManager trustManager = (TrustManager) services.getContainer().getService(serviceName).getValue();
    Assert.assertNotNull(trustManager);

    ModelNode operation = new ModelNode();
    operation.get(ClientConstants.OP_ADDR).add("subsystem", "elytron").add(ElytronDescriptionConstants.TRUST_MANAGER, "trust-with-crl");
    operation.get(ClientConstants.OP).set(ElytronDescriptionConstants.RELOAD_CERTIFICATE_REVOCATION_LIST);
    Assert.assertTrue(services.executeOperation(operation).get(OUTCOME).asString().equals(SUCCESS));
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:12,代码来源:TlsTestCase.java


示例18: testRevocationListsDp

import org.jboss.as.controller.client.helpers.ClientConstants; //导入依赖的package包/类
@Test
public void testRevocationListsDp() throws Throwable {
    ServiceName serviceName = Capabilities.TRUST_MANAGER_RUNTIME_CAPABILITY.getCapabilityServiceName("trust-with-crl-dp");
    TrustManager trustManager = (TrustManager) services.getContainer().getService(serviceName).getValue();
    Assert.assertNotNull(trustManager);

    ModelNode operation = new ModelNode();
    operation.get(ClientConstants.OP_ADDR).add("subsystem", "elytron").add(ElytronDescriptionConstants.TRUST_MANAGER, "trust-with-crl-dp");
    operation.get(ClientConstants.OP).set(ElytronDescriptionConstants.RELOAD_CERTIFICATE_REVOCATION_LIST);
    Assert.assertTrue(services.executeOperation(operation).get(OUTCOME).asString().equals(FAILED)); // not realoadable
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:12,代码来源:TlsTestCase.java


示例19: testLdapKeyStoreCli

import org.jboss.as.controller.client.helpers.ClientConstants; //导入依赖的package包/类
private void testLdapKeyStoreCli(String keystoreName, String alias) throws Exception {
    ModelNode operation = new ModelNode();
    operation.get(ClientConstants.OP_ADDR).add("subsystem", "elytron").add("ldap-key-store", keystoreName);
    operation.get(ClientConstants.OP).set(ElytronDescriptionConstants.READ_ALIASES);
    List<ModelNode> nodes = assertSuccess(services.executeOperation(operation)).get(ClientConstants.RESULT).asList();
    Assert.assertEquals(1, nodes.size());
    Assert.assertEquals(alias, nodes.get(0).asString());

    operation = new ModelNode();
    operation.get(ClientConstants.OP_ADDR).add("subsystem", "elytron").add("ldap-key-store", keystoreName);
    operation.get(ClientConstants.OP).set(ClientConstants.READ_ATTRIBUTE_OPERATION);
    operation.get(ClientConstants.NAME).set(ElytronDescriptionConstants.STATE);
    Assert.assertEquals(ServiceController.State.UP.toString(), assertSuccess(services.executeOperation(operation)).get(ClientConstants.RESULT).asString());

    operation = new ModelNode();
    operation.get(ClientConstants.OP_ADDR).add("subsystem", "elytron").add("ldap-key-store", keystoreName);
    operation.get(ClientConstants.OP).set(ClientConstants.READ_ATTRIBUTE_OPERATION);
    operation.get(ClientConstants.NAME).set(ElytronDescriptionConstants.SIZE);
    Assert.assertEquals(1, assertSuccess(services.executeOperation(operation)).get(ClientConstants.RESULT).asInt());

    operation = new ModelNode();
    operation.get(ClientConstants.OP_ADDR).add("subsystem", "elytron").add("ldap-key-store", keystoreName);
    operation.get(ClientConstants.OP).set(ElytronDescriptionConstants.READ_ALIAS);
    operation.get(ElytronDescriptionConstants.ALIAS).set(alias);

    ModelNode aliasNode = assertSuccess(services.executeOperation(operation)).get(ClientConstants.RESULT);
    Assert.assertNotNull(aliasNode.get(ElytronDescriptionConstants.CREATION_DATE).asString());
    Assert.assertEquals(KeyStore.PrivateKeyEntry.class.getSimpleName(), aliasNode.get(ElytronDescriptionConstants.ENTRY_TYPE).asString());
    Assert.assertFalse(aliasNode.get(ElytronDescriptionConstants.CERTIFICATE).isDefined()); // chain defined, certificate should be blank

    List<ModelNode> chain = aliasNode.get(ElytronDescriptionConstants.CERTIFICATE_CHAIN).asList();
    Assert.assertEquals("OU=Elytron,O=Elytron,C=UK,ST=Elytron,CN=Firefly", chain.get(0).get(ElytronDescriptionConstants.SUBJECT).asString());
    Assert.assertEquals("O=Root Certificate Authority,1.2.840.113549.1.9.1=#1613656c7974726f6e4077696c64666c792e6f7267,C=UK,ST=Elytron,CN=Elytron CA", chain.get(1).get(ElytronDescriptionConstants.SUBJECT).asString());
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:35,代码来源:LdapTestCase.java


示例20: testLdapKeyStoreCopyRemoveAlias

import org.jboss.as.controller.client.helpers.ClientConstants; //导入依赖的package包/类
@Test
public void testLdapKeyStoreCopyRemoveAlias() throws Exception {
    ServiceName serviceName = Capabilities.KEY_STORE_RUNTIME_CAPABILITY.getCapabilityServiceName("LdapKeyStoreMaximal");
    LdapKeyStoreService ldapKeyStoreService = (LdapKeyStoreService) services.getContainer().getService(serviceName).getService();
    KeyStore keyStore = ldapKeyStoreService.getModifiableValue();
    Assert.assertNotNull(keyStore);

    Key key = keyStore.getKey("serenity", "Elytron".toCharArray());
    Certificate[] chain = keyStore.getCertificateChain("serenity");
    Assert.assertNotNull(key);
    Assert.assertNotNull(chain);
    Assert.assertEquals(1, keyStore.size());

    // create two copies
    keyStore.setKeyEntry("serenity1", key, "password1".toCharArray(), chain);
    keyStore.setKeyEntry("serenity2", key, "password2".toCharArray(), chain);
    Assert.assertNotNull(keyStore.getKey("serenity1", "password1".toCharArray()));
    Assert.assertNotNull(keyStore.getKey("serenity2", "password2".toCharArray()));
    Assert.assertEquals(3, keyStore.size());
    Assert.assertEquals(3, Collections.list(keyStore.aliases()).size());

    ModelNode operation = new ModelNode(); // check count of copies through subsystem
    operation.get(ClientConstants.OP_ADDR).add("subsystem", "elytron").add("ldap-key-store", "LdapKeyStoreMaximal");
    operation.get(ClientConstants.OP).set(ElytronDescriptionConstants.READ_ALIASES);
    Assert.assertEquals(3, assertSuccess(services.executeOperation(operation)).get(ClientConstants.RESULT).asList().size());

    keyStore.deleteEntry("serenity1"); // remove through keystore operation
    Assert.assertNull(keyStore.getKey("serenity1", "password1".toCharArray()));
    Assert.assertEquals(2, keyStore.size());

    operation = new ModelNode(); // remove through subsystem operation
    operation.get(ClientConstants.OP_ADDR).add("subsystem", "elytron").add("ldap-key-store", "LdapKeyStoreMaximal");
    operation.get(ClientConstants.OP).set(ElytronDescriptionConstants.REMOVE_ALIAS);
    operation.get(ElytronDescriptionConstants.ALIAS).set("serenity2");
    assertSuccess(services.executeOperation(operation)).get(ClientConstants.RESULT);
    Assert.assertNull(keyStore.getKey("serenity2", "password2".toCharArray()));
    Assert.assertEquals(1, keyStore.size());
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:39,代码来源:LdapTestCase.java



注:本文中的org.jboss.as.controller.client.helpers.ClientConstants类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IntKeyIntValueHashMap类代码示例发布时间:2022-05-23
下一篇:
Java ImmutableDataManipulator类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap