Java Code Examples for org.jboss.dmr.ModelNode#add()
The following examples show how to use
org.jboss.dmr.ModelNode#add() .
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: ResourceCompositeOperationHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
protected ModelNode buildOperationAddress(CommandContext ctx) throws CommandFormatException { final String name = ResourceCompositeOperationHandler.this.name.getValue(ctx.getParsedCommandLine(), true); ModelNode address = new ModelNode(); if(isDependsOnProfile() && ctx.isDomainMode()) { final String profile = ResourceCompositeOperationHandler.this.profile.getValue(ctx.getParsedCommandLine()); if(profile == null) { throw new OperationFormatException("Required argument --profile is missing."); } address.add(Util.PROFILE, profile); } for(OperationRequestAddress.Node node : getRequiredAddress()) { address.add(node.getType(), node.getName()); } address.add(getRequiredType(), name); return address; }
Example 2
Source File: DataSourceAddCompositeHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
protected ModelNode buildRequestWithoutHeaders(CommandContext ctx) throws CommandFormatException { final ModelNode req = super.buildRequestWithoutHeaders(ctx); final ModelNode steps = req.get(Util.STEPS); final ModelNode conPropsNode = conProps.toModelNode(ctx); if(conPropsNode != null) { final List<Property> propsList = conPropsNode.asPropertyList(); for(Property prop : propsList) { final ModelNode address = this.buildOperationAddress(ctx); address.add(CONNECTION_PROPERTIES, prop.getName()); final ModelNode addProp = new ModelNode(); addProp.get(Util.ADDRESS).set(address); addProp.get(Util.OPERATION).set(Util.ADD); addProp.get(Util.VALUE).set(prop.getValue()); steps.add(addProp); } } return req; }
Example 3
Source File: HostXml_5.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private void parseHttpManagementInterface(XMLExtendedStreamReader reader, ModelNode address, List<ModelNode> list) throws XMLStreamException { final ModelNode operationAddress = address.clone(); operationAddress.add(MANAGEMENT_INTERFACE, HTTP_INTERFACE); final ModelNode addOp = Util.getEmptyOperation(ADD, operationAddress); // Handle attributes parseHttpManagementInterfaceAttributes(reader, addOp); // Handle elements while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { requireNamespace(reader, namespace); final Element element = Element.forName(reader.getLocalName()); switch (element) { case SOCKET: parseHttpManagementSocket(reader, addOp); break; case HTTP_UPGRADE: parseHttpUpgrade(reader, addOp); break; default: throw unexpectedElement(reader); } } list.add(addOp); }
Example 4
Source File: HostXml_7.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
protected void parseDiscoveryOptionProperty(XMLExtendedStreamReader reader, ModelNode discoveryOptionProperties) throws XMLStreamException { String propertyName = null; String propertyValue = null; EnumSet<Attribute> required = EnumSet.of(Attribute.NAME, Attribute.VALUE); final int count = reader.getAttributeCount(); for (int i = 0; i < count; i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); required.remove(attribute); switch (attribute) { case NAME: { propertyName = value; break; } case VALUE: { propertyValue = value; break; } default: throw unexpectedAttribute(reader, i); } } if (required.size() > 0) { throw missingRequired(reader, required); } discoveryOptionProperties.add(propertyName, propertyValue); requireNoContent(reader); }
Example 5
Source File: IdentityOperationsTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private ModelNode createRemoveAttributeOperation(PathAddress parentAddress, String principalName, String key, String... values) { ModelNode valuesNode = new ModelNode(); for (String value : values) { valuesNode.add(value); } return SubsystemOperations.OperationBuilder.create(ElytronDescriptionConstants.REMOVE_IDENTITY_ATTRIBUTE, parentAddress.toModelNode()) .addAttribute(ModifiableRealmDecorator.RemoveIdentityAttributeHandler.IDENTITY, principalName) .addAttribute(ModifiableRealmDecorator.RemoveIdentityAttributeHandler.NAME, key) .addAttribute(ModifiableRealmDecorator.RemoveIdentityAttributeHandler.VALUE, valuesNode) .build(); }
Example 6
Source File: ExpressionTypeConverterUnitTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void testSimpleTypeEmptyList() throws Exception { ModelNode description = createDescription(ModelType.LIST, ModelType.INT); TypeConverter converter = getConverter(description); Assert.assertEquals(ArrayType.getArrayType(SimpleType.STRING), converter.getOpenType()); ModelNode node = new ModelNode(); node.add(""); node.add(""); Assert.assertTrue(Arrays.equals(new Integer[] {null, null} , assertCast(String[].class, converter.fromModelNode(node)))); }
Example 7
Source File: ServiceVerificationHelper.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private static void reportUnavailableRequiredServices(Set<ServiceName> unavailableServices, ModelNode failureDescription) { if (!unavailableServices.isEmpty()) { ModelNode requiredServicesNode = failureDescription.get(ControllerLogger.ROOT_LOGGER.missingRequiredServices()); for (ServiceName serviceName : unavailableServices) { requiredServicesNode.add(serviceName.getCanonicalName()); } } }
Example 8
Source File: ValidateAddressOperationTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void testInvalidPath() throws IOException, MgmtOperationException { ModelNode op = ModelUtil.createOpNode(null, ValidateAddressOperationHandler.OPERATION_NAME); final ModelNode addr = op.get(VALUE); addr.add("socket-binding-group", "standard-sockets"); addr.add("wrong", "illegal"); final ModelNode result = executeOperation(op); assertTrue(result.hasDefined(VALID)); final ModelNode value = result.get(VALID); assertFalse(value.asBoolean()); assertTrue(result.hasDefined(PROBLEM)); final ModelNode problem = result.get(PROBLEM); assertTrue(problem.asString().matches("WFLYCTL0217.+\"wrong\".+\"illegal\".*")); }
Example 9
Source File: DomainSuspendResumeTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private static ModelNode createOpNode(String address, String operation) { ModelNode op = new ModelNode(); // set address ModelNode list = op.get("address").setEmptyList(); if (address != null) { String[] pathSegments = address.split("/"); for (String segment : pathSegments) { String[] elements = segment.split("="); list.add(elements[0], elements[1]); } } op.get("operation").set(operation); return op; }
Example 10
Source File: SecurityDomainJBossASClient.java From hawkular-agent with Apache License 2.0 | 5 votes |
private void addPossibleExpression(ModelNode node, String name, String value) { if (value != null && value.contains("${")) { node.add(name, new ModelNode(ModelType.EXPRESSION).set(new ValueExpression(value))); } else { node.add(name, value); } }
Example 11
Source File: PatchInfoHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private ModelNode patchIdInfo(final OperationContext context, final String patchId, final boolean verbose, final PatchingHistory.Iterator i) { while(i.hasNext()) { final Entry entry = i.next(); if(patchId.equals(entry.getPatchId())) { final ModelNode result = new ModelNode(); result.get(Constants.PATCH_ID).set(entry.getPatchId()); result.get(Constants.TYPE).set(entry.getType().getName()); result.get(Constants.DESCRIPTION).set(entry.getMetadata().getDescription()); final String link = entry.getMetadata().getLink(); if (link != null) { result.get(Constants.LINK).set(link); } final Identity identity = entry.getMetadata().getIdentity(); result.get(Constants.IDENTITY_NAME).set(identity.getName()); result.get(Constants.IDENTITY_VERSION).set(identity.getVersion()); if(verbose) { final ModelNode list = result.get(Constants.ELEMENTS).setEmptyList(); final Patch metadata = entry.getMetadata(); for(PatchElement e : metadata.getElements()) { final ModelNode element = new ModelNode(); element.get(Constants.PATCH_ID).set(e.getId()); element.get(Constants.TYPE).set(e.getProvider().isAddOn() ? Constants.ADD_ON : Constants.LAYER); element.get(Constants.NAME).set(e.getProvider().getName()); element.get(Constants.DESCRIPTION).set(e.getDescription()); list.add(element); } } return result; } } return null; }
Example 12
Source File: JBossASClient.java From hawkular-agent with Apache License 2.0 | 5 votes |
/** * Creates a batch of operations that can be atomically invoked. * * @param steps the different operation steps of the batch * * @return the batch operation node */ public static ModelNode createBatchRequest(ModelNode... steps) { final ModelNode composite = new ModelNode(); composite.get(OPERATION).set(BATCH); composite.get(ADDRESS).setEmptyList(); final ModelNode stepsNode = composite.get(BATCH_STEPS); for (ModelNode step : steps) { if (step != null) { stepsNode.add(step); } } return composite; }
Example 13
Source File: PlatformMBeanResourceUnitTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private static ModelNode getAddress(final String type, final String name) { final ModelNode result = new ModelNode(); result.add(CORE_SERVICE, PLATFORM_MBEAN); if (type != null) { result.add(TYPE, type); if (name != null) { result.add(NAME, name); } } return result; }
Example 14
Source File: CachedDcDomainTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private ModelNode getCreateOperationTestLoggingCategory() { final ModelNode addrLogger = getProfileDefaultLoggingAddr(); addrLogger.add(LOGGER, TEST_LOGGER_NAME); final ModelNode createOp = Operations.createAddOperation(addrLogger); createOp.get("level").set("TRACE"); createOp.get("category").set(TEST_LOGGER_NAME); return createOp; }
Example 15
Source File: StandaloneXml_11.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
private void parseConstantHeaders(XMLExtendedStreamReader reader, ModelNode addOp) throws XMLStreamException { // Attributes requireNoAttributes(reader); ModelNode constantHeaders= new ModelNode(); // Content while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { requireNamespace(reader, namespace); if (Element.forName(reader.getLocalName()) != Element.HEADER_MAPPING) { throw unexpectedElement(reader); } ModelNode headerMapping = new ModelNode(); requireSingleAttribute(reader, Attribute.PATH.getLocalName()); // After double checking the name of the only attribute we can retrieve it. HttpManagementResourceDefinition.PATH.parseAndSetParameter(reader.getAttributeValue(0), headerMapping, reader); ModelNode headers = new ModelNode(); boolean headerFound = false; while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { requireNamespace(reader, namespace); if (Element.forName(reader.getLocalName()) != Element.HEADER) { throw unexpectedElement(reader); } headerFound = true; ModelNode header= new ModelNode(); final int count = reader.getAttributeCount(); for (int i = 0; i < count; i++) { final String value = reader.getAttributeValue(i); if (!isNoNamespaceAttribute(reader, i)) { throw unexpectedAttribute(reader, i); } else { final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case NAME: { HttpManagementResourceDefinition.HEADER_NAME.parseAndSetParameter(value, header, reader); break; } case VALUE: { HttpManagementResourceDefinition.HEADER_VALUE.parseAndSetParameter(value, header, reader); break; } default: throw unexpectedAttribute(reader, i); } } } headers.add(header); requireNoContent(reader); } if (headerFound == false) { throw missingRequiredElement(reader, Collections.singleton(Element.HEADER.getLocalName())); } headerMapping.get(ModelDescriptionConstants.HEADERS).set(headers); constantHeaders.add(headerMapping); } addOp.get(ModelDescriptionConstants.CONSTANT_HEADERS).set(constantHeaders); }
Example 16
Source File: KeyStoresTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
@Test public void testGenerateKeyPair() throws Exception { addKeyStore(); try { int numAliasesBefore = readAliases().size(); ModelNode operation = new ModelNode(); operation.get(ClientConstants.OP_ADDR).add("subsystem", "elytron").add("key-store", KEYSTORE_NAME); operation.get(ClientConstants.OP).set(ElytronDescriptionConstants.GENERATE_KEY_PAIR); operation.get(ElytronDescriptionConstants.ALIAS).set("bsmith"); operation.get(ElytronDescriptionConstants.ALGORITHM).set("RSA"); operation.get(ElytronDescriptionConstants.KEY_SIZE).set(1024); operation.get(ElytronDescriptionConstants.VALIDITY).set(365); operation.get(ElytronDescriptionConstants.SIGNATURE_ALGORITHM).set("SHA256withRSA"); operation.get(ElytronDescriptionConstants.DISTINGUISHED_NAME).set("CN=bob smith, OU=jboss, O=red hat, L=raleigh, ST=north carolina, C=us"); ModelNode extensions = new ModelNode(); extensions.add(getExtension(false, "ExtendedKeyUsage", "clientAuth")); extensions.add(getExtension(true, "KeyUsage", "digitalSignature")); extensions.add(getExtension(false, "SubjectAlternativeName", "email:[email protected],DNS:bobsmith.example.com")); operation.get(ElytronDescriptionConstants.EXTENSIONS).set(extensions); operation.get(CredentialReference.CREDENTIAL_REFERENCE).get(CredentialReference.CLEAR_TEXT).set(KEY_PASSWORD); assertSuccess(services.executeOperation(operation)); assertEquals(numAliasesBefore + 1, readAliases().size()); ModelNode newAlias = readAlias("bsmith"); assertEquals(KeyStore.PrivateKeyEntry.class.getSimpleName(), newAlias.get(ElytronDescriptionConstants.ENTRY_TYPE).asString()); assertEquals(1, newAlias.get(ElytronDescriptionConstants.CERTIFICATE_CHAIN).asList().size()); ServiceName serviceName = Capabilities.KEY_STORE_RUNTIME_CAPABILITY.getCapabilityServiceName(KEYSTORE_NAME); KeyStore keyStore = (KeyStore) services.getContainer().getService(serviceName).getValue(); assertNotNull(keyStore); X509Certificate certificate = (X509Certificate) keyStore.getCertificate("bsmith"); assertEquals("RSA", certificate.getPublicKey().getAlgorithm()); assertEquals(1024, ((RSAKey) certificate.getPublicKey()).getModulus().bitLength()); Date notBefore = certificate.getNotBefore(); Date notAfter = certificate.getNotAfter(); assertEquals(365, (notAfter.getTime() - notBefore.getTime()) / (1000 * 60 * 60 * 24)); assertEquals("SHA256withRSA", certificate.getSigAlgName()); assertEquals(new X500Principal("CN=bob smith, OU=jboss, O=red hat, L=raleigh, ST=north carolina, C=us"), certificate.getSubjectX500Principal()); assertEquals(new X500Principal("CN=bob smith, OU=jboss, O=red hat, L=raleigh, ST=north carolina, C=us"), certificate.getIssuerX500Principal()); try { certificate.verify(certificate.getPublicKey()); } catch (Exception e) { fail("Exception not expected"); } assertEquals(1, certificate.getCriticalExtensionOIDs().size()); assertEquals(3, certificate.getNonCriticalExtensionOIDs().size()); assertEquals(Arrays.asList(X500.OID_KP_CLIENT_AUTH), certificate.getExtendedKeyUsage()); boolean[] keyUsage = certificate.getKeyUsage(); assertTrue(KeyUsage.digitalSignature.in(keyUsage)); final Collection<List<?>> names = certificate.getSubjectAlternativeNames(); assertEquals(2, names.size()); final Iterator<List<?>> iterator = names.iterator(); List<?> item = iterator.next(); assertEquals(2, item.size()); assertEquals(Integer.valueOf(GeneralName.RFC_822_NAME), item.get(0)); assertEquals("[email protected]", item.get(1)); item = iterator.next(); assertEquals(2, item.size()); assertEquals(Integer.valueOf(GeneralName.DNS_NAME), item.get(0)); assertEquals("bobsmith.example.com", item.get(1)); assertNotNull(certificate.getExtensionValue(X500.OID_CE_SUBJECT_KEY_IDENTIFIER)); assertNotNull(keyStore.getKey("bsmith", KEY_PASSWORD.toCharArray())); } finally { removeKeyStore(); } }
Example 17
Source File: HostControllerExecutionSupport.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
/** * Create a HostControllerExecutionSupport for a given operation. * * * @param context * @param operation the operation * @param hostName the name of the host executing the operation * @param domainModelProvider source for the domain model * @param ignoredDomainResourceRegistry registry of resource addresses that should be ignored * @throws OperationFailedException * * @return the HostControllerExecutionSupport */ public static HostControllerExecutionSupport create(OperationContext context, final ModelNode operation, final String hostName, final DomainModelProvider domainModelProvider, final IgnoredDomainResourceRegistry ignoredDomainResourceRegistry, final boolean isRemoteDomainControllerIgnoreUnaffectedConfiguration, final ExtensionRegistry extensionRegistry) throws OperationFailedException { String targetHost = null; PathElement runningServerTarget = null; ModelNode runningServerOp = null; final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR)); if (address.size() > 0) { PathElement first = address.getElement(0); if (HOST.equals(first.getKey()) && !first.isMultiTarget()) { targetHost = first.getValue(); if (address.size() > 1 && RUNNING_SERVER.equals(address.getElement(1).getKey())) { runningServerTarget = address.getElement(1); ModelNode relativeAddress = new ModelNode().setEmptyList(); for (int i = 2; i < address.size(); i++) { PathElement element = address.getElement(i); relativeAddress.add(element.getKey(), element.getValue()); } runningServerOp = operation.clone(); runningServerOp.get(OP_ADDR).set(relativeAddress); } } } HostControllerExecutionSupport result; if (targetHost != null && !hostName.equals(targetHost)) { // HostControllerExecutionSupport representing another host result = new IgnoredOpExecutionSupport(ignoredDomainResourceRegistry); } else if (runningServerTarget != null) { // HostControllerExecutionSupport representing a server op final Resource domainModel = domainModelProvider.getDomainModel(); final Resource hostModel = domainModel.getChild(PathElement.pathElement(HOST, targetHost)); if (runningServerTarget.isMultiTarget()) { return new DomainOpExecutionSupport(ignoredDomainResourceRegistry, operation, PathAddress.EMPTY_ADDRESS); } else { final String serverName = runningServerTarget.getValue(); // TODO prevent NPE final String serverGroup = hostModel.getChild(PathElement.pathElement(SERVER_CONFIG, serverName)).getModel().require(GROUP).asString(); final ServerIdentity serverIdentity = new ServerIdentity(targetHost, serverGroup, serverName); result = new DirectServerOpExecutionSupport(ignoredDomainResourceRegistry, serverIdentity, runningServerOp); } } else if (COMPOSITE.equals(operation.require(OP).asString())) { // Recurse into the steps to see what's required if (operation.hasDefined(STEPS)) { List<HostControllerExecutionSupport> parsedSteps = new ArrayList<HostControllerExecutionSupport>(); for (ModelNode step : operation.get(STEPS).asList()) { // Propagate the caller-type=user header if (operation.hasDefined(OPERATION_HEADERS, CALLER_TYPE) && operation.get(OPERATION_HEADERS, CALLER_TYPE).asString().equals(USER)) { step = step.clone(); step.get(OPERATION_HEADERS, CALLER_TYPE).set(USER); } parsedSteps.add(create(context, step, hostName, domainModelProvider, ignoredDomainResourceRegistry, isRemoteDomainControllerIgnoreUnaffectedConfiguration, extensionRegistry)); } result = new MultiStepOpExecutionSupport(ignoredDomainResourceRegistry, parsedSteps); } else { // Will fail later result = new DomainOpExecutionSupport(ignoredDomainResourceRegistry, operation, address); } } else if (targetHost == null && isResourceExcluded(context, ignoredDomainResourceRegistry, isRemoteDomainControllerIgnoreUnaffectedConfiguration, domainModelProvider, hostName, address, extensionRegistry, operation)) { result = new IgnoredOpExecutionSupport(ignoredDomainResourceRegistry); } else { result = new DomainOpExecutionSupport(ignoredDomainResourceRegistry, operation, address); } return result; }
Example 18
Source File: HostXml_9.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
private ModelNode parseDiscoveryOptionAttributes(final XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> list, final Set<String> discoveryOptionNames) throws XMLStreamException { // OP_ADDR will be set after parsing the NAME attribute final ModelNode discoveryOptionAddress = address.clone(); discoveryOptionAddress.add(CORE_SERVICE, DISCOVERY_OPTIONS); final ModelNode addOp = Util.getEmptyOperation(ADD, new ModelNode()); list.add(addOp); final Set<Attribute> required = EnumSet.of(Attribute.NAME, Attribute.CODE); final int count = reader.getAttributeCount(); for (int i = 0; i < count; i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); required.remove(attribute); switch (attribute) { case NAME: { if (!discoveryOptionNames.add(value)) { throw ParseUtils.duplicateNamedElement(reader, value); } addOp.get(OP_ADDR).set(discoveryOptionAddress).add(DISCOVERY_OPTION, value); break; } case CODE: { DiscoveryOptionResourceDefinition.CODE.parseAndSetParameter(value, addOp, reader); break; } case MODULE: { DiscoveryOptionResourceDefinition.MODULE.parseAndSetParameter(value, addOp, reader); break; } default: throw unexpectedAttribute(reader, i); } } if (required.size() > 0) { throw missingRequired(reader, required); } return addOp; }
Example 19
Source File: LinebreaksTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
@Test public void testLineBreaksAndTabs() throws Exception { final StringBuilder buf = new StringBuilder(); buf.append("/subsystem=security/security-domain=DemoAuthRealm/authentication=classic:add( \\").append(Util.LINE_SEPARATOR); buf.append('\t').append("login-modules=[ \\").append(Util.LINE_SEPARATOR); buf.append("\t\t").append("{ \\").append(Util.LINE_SEPARATOR); buf.append("\t\t\t").append("\"code\" => \"Database\", \\").append(Util.LINE_SEPARATOR); buf.append("\t\t\t").append("flag=>required, \\").append(Util.LINE_SEPARATOR); buf.append("\t\t\t").append("test1 = > required, \\").append(Util.LINE_SEPARATOR); buf.append("\t\t\t").append("test2 =\"> required\", \\").append(Util.LINE_SEPARATOR); buf.append("\t\t\t").append("\"module-options\" = [ \\").append(Util.LINE_SEPARATOR); buf.append("\t\t\t\t").append("\"unauthenticatedIdentity\"=\"guest\", \\").append(Util.LINE_SEPARATOR); buf.append("\t\t\t\t").append("\"dsJndiName\"=\"java:jboss/jdbc/ApplicationDS\", \\").append(Util.LINE_SEPARATOR); buf.append("\t\t\t\t").append("\"principalsQuery\"=\"select password from users where username=?\", \\").append(Util.LINE_SEPARATOR); buf.append("\t\t\t\t").append("\"rolesQuery\"=\"select name, 'Roles' FROM user_roless ur, roles r, user u WHERE u.username=? and u.id = ur.user_id and ur.role_id = r.id\", \\").append(Util.LINE_SEPARATOR); buf.append("\t\t\t\t").append("\"hashAlgorithm\" = \"MD5\", \\").append(Util.LINE_SEPARATOR); buf.append("\t\t\t\t").append("hashEncoding = hex \\").append(Util.LINE_SEPARATOR); buf.append("\t\t\t").append("] \\").append(Util.LINE_SEPARATOR); buf.append("\t\t").append("} \\").append(Util.LINE_SEPARATOR); buf.append('\t').append(']').append(Util.LINE_SEPARATOR); buf.append(')'); final ModelNode node = ctx.buildRequest(buf.toString()); ModelNode addr = new ModelNode(); addr.add("subsystem", "security"); addr.add("security-domain", "DemoAuthRealm"); addr.add("authentication", "classic"); assertEquals(addr, node.get(Util.ADDRESS)); assertEquals("add", node.get(Util.OPERATION).asString()); final ModelNode loginModules = node.get("login-modules"); assertTrue(loginModules.isDefined()); assertEquals(ModelType.LIST, loginModules.getType()); List<ModelNode> list = loginModules.asList(); assertEquals(1, list.size()); final ModelNode module = list.get(0); assertTrue(module.isDefined()); assertEquals("Database", module.get("code").asString()); assertEquals("required", module.get("flag").asString()); assertEquals("> required", module.get("test1").asString()); assertEquals("> required", module.get("test2").asString()); final ModelNode options = module.get("module-options"); assertTrue(options.isDefined()); assertEquals(ModelType.LIST, options.getType()); list = options.asList(); assertEquals(6, list.size()); assertEquals("guest", list.get(0).get("unauthenticatedIdentity").asString()); assertEquals("java:jboss/jdbc/ApplicationDS", list.get(1).get("dsJndiName").asString()); assertEquals("select password from users where username=?", list.get(2).get("principalsQuery").asString()); assertEquals("select name, 'Roles' FROM user_roless ur, roles r, user u WHERE u.username=? and u.id = ur.user_id and ur.role_id = r.id", list.get(3).get("rolesQuery").asString()); assertEquals("MD5", list.get(4).get("hashAlgorithm").asString()); assertEquals("hex", list.get(5).get("hashEncoding").asString()); }
Example 20
Source File: CapabilityRegistryResourceDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
private static void populateRegistrationPoints(ModelNode points, Set<RegistrationPoint> registrationPoints) { for (RegistrationPoint point : registrationPoints) { points.add(point.getAddress().toCLIStyleString()); } }