org.jboss.as.controller.AbstractAddStepHandler Java Examples
The following examples show how to use
org.jboss.as.controller.AbstractAddStepHandler.
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: HttpServerDefinitions.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
static ResourceDefinition getServiceLoaderServerMechanismFactoryDefinition() { AttributeDefinition[] attributes = new AttributeDefinition[] { MODULE }; AbstractAddStepHandler add = new TrivialAddHandler<HttpServerAuthenticationMechanismFactory>(HttpServerAuthenticationMechanismFactory.class, ServiceController.Mode.ACTIVE, ServiceController.Mode.PASSIVE, attributes, HTTP_SERVER_MECHANISM_FACTORY_RUNTIME_CAPABILITY) { @Override protected ValueSupplier<HttpServerAuthenticationMechanismFactory> getValueSupplier( ServiceBuilder<HttpServerAuthenticationMechanismFactory> serviceBuilder, OperationContext context, ModelNode model) throws OperationFailedException { final String module = MODULE.resolveModelAttribute(context, model).asStringOrNull(); return () -> { try { ClassLoader classLoader = doPrivileged((PrivilegedExceptionAction<ClassLoader>) () -> resolveClassLoader(module)); return new SetMechanismInformationMechanismFactory(new ServiceLoaderServerMechanismFactory(classLoader)); } catch (Exception e) { throw new StartException(e); } }; } }; return wrapFactory(new TrivialResourceDefinition(ElytronDescriptionConstants.SERVICE_LOADER_HTTP_SERVER_MECHANISM_FACTORY, add, attributes, HTTP_SERVER_MECHANISM_FACTORY_RUNTIME_CAPABILITY)); }
Example #2
Source File: PrincipalTransformerDefinitions.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
static ResourceDefinition getRegexValidatingPrincipalTransformerDefinition() { final AttributeDefinition[] attributes = new AttributeDefinition[] { PATTERN, MATCH }; AbstractAddStepHandler add = new TrivialAddHandler<PrincipalTransformer>(PrincipalTransformer.class, attributes, PRINCIPAL_TRANSFORMER_RUNTIME_CAPABILITY) { @Override protected ValueSupplier<PrincipalTransformer> getValueSupplier(ServiceBuilder<PrincipalTransformer> serviceBuilder, OperationContext context, ModelNode model) throws OperationFailedException { final Pattern pattern = Pattern.compile(PATTERN.resolveModelAttribute(context, model).asString()); final boolean match = MATCH.resolveModelAttribute(context, model).asBoolean(); return () -> PrincipalTransformer.from(new RegexNameValidatingRewriter(pattern, match).asPrincipalRewriter()); } }; return new TrivialResourceDefinition(REGEX_VALIDATING_PRINCIPAL_TRANSFORMER, add, attributes, PRINCIPAL_TRANSFORMER_RUNTIME_CAPABILITY); }
Example #3
Source File: AggregateComponentDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
static <T> AggregateComponentDefinition<T> create(Class<T> aggregationType, String componentName, String referencesName, RuntimeCapability<?> runtimeCapability, Function<T[], T> aggregator, boolean dependOnProviderRegistration) { String capabilityName = runtimeCapability.getName(); StringListAttributeDefinition aggregateReferences = new StringListAttributeDefinition.Builder(referencesName) .setMinSize(2) .setRequired(true) .setCapabilityReference(capabilityName, capabilityName)//todo this is ultra fishy .setRestartAllServices() .build(); AbstractAddStepHandler add = new AggregateComponentAddHandler<T>(aggregationType, aggregator, aggregateReferences, runtimeCapability, dependOnProviderRegistration); OperationStepHandler remove = new TrivialCapabilityServiceRemoveHandler(add, runtimeCapability); OperationStepHandler write = new ElytronReloadRequiredWriteAttributeHandler(aggregateReferences); return new AggregateComponentDefinition<T>(aggregationType, componentName, add, remove, aggregateReferences, write, runtimeCapability); }
Example #4
Source File: RealmMapperDefinitions.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
static ResourceDefinition getConstantRealmMapper() { AbstractAddStepHandler add = new TrivialAddHandler<RealmMapper>(RealmMapper.class, CONSTANT_REALM_MAPPER_ATTRIBUTES, REALM_MAPPER_RUNTIME_CAPABILITY) { @Override protected ValueSupplier<RealmMapper> getValueSupplier(ServiceBuilder<RealmMapper> serviceBuilder, OperationContext context, ModelNode model) throws OperationFailedException { final String realmName = REALM_NAME.resolveModelAttribute(context, model).asString(); return () -> RealmMapper.single(realmName); } }; return TrivialResourceDefinition.builder() .setPathKey(ElytronDescriptionConstants.CONSTANT_REALM_MAPPER) .setAddHandler(add) .setAttributes(CONSTANT_REALM_MAPPER_ATTRIBUTES) .setRuntimeCapabilities(REALM_MAPPER_RUNTIME_CAPABILITY).build(); }
Example #5
Source File: FilteredReadChildrenResourcesTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override protected void initModel(ManagementModel managementModel) { ManagementResourceRegistration registration = managementModel.getRootResourceRegistration(); GlobalOperationHandlers.registerGlobalOperations(registration, ProcessType.EMBEDDED_SERVER); GlobalNotifications.registerGlobalNotifications(registration, ProcessType.EMBEDDED_SERVER); registration.registerSubModel(new SimpleResourceDefinition( new Parameters(pathElement(UNCONSTRAINED_RESOURCE), new NonResolvingResourceDescriptionResolver()) .setAddHandler(new AbstractAddStepHandler() {}) .setRemoveHandler(new AbstractRemoveStepHandler() {}))); registration.registerSubModel(new SimpleResourceDefinition( new Parameters(pathElement(SENSITIVE_CONSTRAINED_RESOURCE), new NonResolvingResourceDescriptionResolver()) .setAddHandler(new AbstractAddStepHandler() {}) .setRemoveHandler(new AbstractRemoveStepHandler() {}) .setAccessConstraints(MY_SENSITIVE_CONSTRAINT))); }
Example #6
Source File: TrivialResourceDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private TrivialResourceDefinition(String pathKey, ResourceDescriptionResolver resourceDescriptionResolver, AbstractAddStepHandler add, AbstractRemoveStepHandler remove, AttributeDefinition[] attributes, Map<AttributeDefinition, OperationStepHandler> readOnlyAttributes, Map<OperationDefinition, OperationStepHandler> operations, List<ResourceDefinition> children, RuntimeCapability<?>[] runtimeCapabilities) { super(new Parameters(PathElement.pathElement(pathKey), resourceDescriptionResolver) .setAddHandler(add) .setRemoveHandler(remove) .setAddRestartLevel(OperationEntry.Flag.RESTART_RESOURCE_SERVICES) .setRemoveRestartLevel(OperationEntry.Flag.RESTART_RESOURCE_SERVICES) .setCapabilities(runtimeCapabilities)); this.attributes = attributes; this.readOnlyAttributes = readOnlyAttributes; this.operations = operations; this.children = children; }
Example #7
Source File: FilteredReadChildrenNamesTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override protected void initModel(ManagementModel managementModel) { ManagementResourceRegistration registration = managementModel.getRootResourceRegistration(); GlobalOperationHandlers.registerGlobalOperations(registration, ProcessType.EMBEDDED_SERVER); GlobalNotifications.registerGlobalNotifications(registration, ProcessType.EMBEDDED_SERVER); registration.registerSubModel(new SimpleResourceDefinition( new Parameters(pathElement(UNCONSTRAINED_RESOURCE), new NonResolvingResourceDescriptionResolver()) .setAddHandler(new AbstractAddStepHandler() {}) .setRemoveHandler(new AbstractRemoveStepHandler() {}))); registration.registerSubModel(new SimpleResourceDefinition( new Parameters(pathElement(SENSITIVE_CONSTRAINED_RESOURCE), new NonResolvingResourceDescriptionResolver()) .setAddHandler(new AbstractAddStepHandler() {}) .setRemoveHandler(new AbstractRemoveStepHandler() {}) .setAccessConstraints(MY_SENSITIVE_CONSTRAINT))); }
Example #8
Source File: PrincipalTransformerDefinitions.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
static ResourceDefinition getRegexPrincipalTransformerDefinition() { final AttributeDefinition[] attributes = new AttributeDefinition[] { PATTERN, REPLACEMENT, REPLACE_ALL }; AbstractAddStepHandler add = new TrivialAddHandler<PrincipalTransformer>(PrincipalTransformer.class, attributes, PRINCIPAL_TRANSFORMER_RUNTIME_CAPABILITY) { @Override protected ValueSupplier<PrincipalTransformer> getValueSupplier(ServiceBuilder<PrincipalTransformer> serviceBuilder, OperationContext context, ModelNode model) throws OperationFailedException { final Pattern pattern = Pattern.compile(PATTERN.resolveModelAttribute(context, model).asString()); final String replacement = REPLACEMENT.resolveModelAttribute(context, model).asString(); final boolean replaceAll = REPLACE_ALL.resolveModelAttribute(context, model).asBoolean(); return () -> PrincipalTransformer.from(new RegexNameRewriter(pattern, replacement, replaceAll).asPrincipalRewriter()); } }; return new TrivialResourceDefinition(REGEX_PRINCIPAL_TRANSFORMER, add, attributes, PRINCIPAL_TRANSFORMER_RUNTIME_CAPABILITY); }
Example #9
Source File: ValidateSubsystemExtension.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void initialize(ExtensionContext context) { final SubsystemRegistration subsystem = context.registerSubsystem(SUBSYSTEM_NAME, ModelVersion.create(1)); SimpleResourceDefinition subsystemResource = new SimpleResourceDefinition(new SimpleResourceDefinition.Parameters( PathElement.pathElement(SUBSYSTEM, SUBSYSTEM_NAME), new NonResolvingResourceDescriptionResolver()) ); final ManagementResourceRegistration registration = subsystem.registerSubsystemModel(subsystemResource); //We always need to add an 'add' operation registration.registerOperationHandler( SimpleOperationDefinitionBuilder.of(ADD, NonResolvingResourceDescriptionResolver.INSTANCE) .setParameters(addAttributes) .build(), new AbstractAddStepHandler(addAttributes)); //We always need to add a 'describe' operation registration.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION, GenericSubsystemDescribeHandler.INSTANCE); subsystem.registerXMLElementWriter(parser); }
Example #10
Source File: RoleMapperDefinitions.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
static ResourceDefinition getRegexRoleMapperDefinition() { AbstractAddStepHandler add = new RoleMapperAddHandler(PATTERN, REPLACEMENT, KEEP_NON_MAPPED, REPLACE_ALL) { @Override protected ValueSupplier<RoleMapper> getValueSupplier(OperationContext context, ModelNode model) throws OperationFailedException { final String regex = PATTERN.resolveModelAttribute(context, model).asString(); final String replacement = REPLACEMENT.resolveModelAttribute(context, model).asString(); final Boolean keepNonMapped = KEEP_NON_MAPPED.resolveModelAttribute(context, model).asBoolean(); final Boolean replaceAll = REPLACE_ALL.resolveModelAttribute(context, model).asBoolean(); final RegexRoleMapper roleMapper = new RegexRoleMapper.Builder() .setPattern(regex) .setReplacement(replacement) .setKeepNonMapped(keepNonMapped) .setReplaceAll(replaceAll) .build(); return () -> roleMapper; } }; return new RoleMapperResourceDefinition(ElytronDescriptionConstants.REGEX_ROLE_MAPPER, add, PATTERN, REPLACEMENT, KEEP_NON_MAPPED, REPLACE_ALL); }
Example #11
Source File: SaslServerDefinitions.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
SaslServerResourceDefinition(String pathKey, AbstractAddStepHandler add, AttributeDefinition ... attributes) { super(new Parameters(PathElement.pathElement(pathKey), ElytronExtension.getResourceDescriptionResolver(pathKey)) .setAddHandler(add) .setRemoveHandler(new TrivialCapabilityServiceRemoveHandler(add, SASL_SERVER_FACTORY_RUNTIME_CAPABILITY)) .setAddRestartLevel(OperationEntry.Flag.RESTART_RESOURCE_SERVICES) .setRemoveRestartLevel(OperationEntry.Flag.RESTART_RESOURCE_SERVICES) .setCapabilities(SASL_SERVER_FACTORY_RUNTIME_CAPABILITY)); this.pathKey = pathKey; this.attributes = attributes; }
Example #12
Source File: HttpServerDefinitions.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
static ResourceDefinition getProviderHttpServerMechanismFactoryDefinition() { AttributeDefinition[] attributes = new AttributeDefinition[] { PROVIDERS }; AbstractAddStepHandler add = new TrivialAddHandler<HttpServerAuthenticationMechanismFactory>(HttpServerAuthenticationMechanismFactory.class, attributes, HTTP_SERVER_MECHANISM_FACTORY_RUNTIME_CAPABILITY) { @Override protected ValueSupplier<HttpServerAuthenticationMechanismFactory> getValueSupplier( ServiceBuilder<HttpServerAuthenticationMechanismFactory> serviceBuilder, OperationContext context, ModelNode model) throws OperationFailedException { String providers = PROVIDERS.resolveModelAttribute(context, model).asStringOrNull(); final Supplier<Provider[]> providerSupplier; if (providers != null) { final InjectedValue<Provider[]> providersInjector = new InjectedValue<Provider[]>(); serviceBuilder.addDependency(context.getCapabilityServiceName( buildDynamicCapabilityName(PROVIDERS_CAPABILITY, providers), Provider[].class), Provider[].class, providersInjector); providerSupplier = providersInjector::getValue; } else { providerSupplier = Security::getProviders; } Predicate<Provider.Service> serviceFilter = (Provider.Service s) -> HttpServerAuthenticationMechanismFactory.class.getSimpleName().equals(s.getType()); return () -> { final Provider[] actualProviders = providerSupplier.get(); if ( findProviderService(actualProviders, serviceFilter) == null ) { throw ROOT_LOGGER.noSuitableProvider(HttpServerAuthenticationMechanismFactory.class.getSimpleName()); } return new SetMechanismInformationMechanismFactory(new SecurityProviderServerMechanismFactory(actualProviders)); }; } }; return wrapFactory(new TrivialResourceDefinition(ElytronDescriptionConstants.PROVIDER_HTTP_SERVER_MECHANISM_FACTORY, add, attributes, HTTP_SERVER_MECHANISM_FACTORY_RUNTIME_CAPABILITY)); }
Example #13
Source File: RealmDefinitions.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
static ResourceDefinition getIdentityRealmDefinition() { AbstractAddStepHandler add = new TrivialAddHandler<SecurityRealm>(SecurityRealm.class, IDENTITY_REALM_ATTRIBUTES, SECURITY_REALM_RUNTIME_CAPABILITY) { @Override protected ValueSupplier<SecurityRealm> getValueSupplier(ServiceBuilder<SecurityRealm> serviceBuilder, OperationContext context, ModelNode model) throws OperationFailedException { final String identity = IDENTITY.resolveModelAttribute(context, model).asString(); final String attributeName = ATTRIBUTE_NAME.resolveModelAttribute(context, model).asStringOrNull(); final List<String> attributeValues = ATTRIBUTE_VALUES.unwrap(context, model); return () -> { final Map<String, ? extends Collection<String>> attributesMap; if (attributeName != null) { attributesMap = Collections.singletonMap(attributeName, Collections.unmodifiableList(attributeValues)); } else { attributesMap = Collections.emptyMap(); } final Map<String, SimpleRealmEntry> realmMap = Collections.singletonMap(identity, new SimpleRealmEntry(Collections.emptyList(), new MapAttributes(attributesMap))); SimpleMapBackedSecurityRealm securityRealm = new SimpleMapBackedSecurityRealm(); securityRealm.setPasswordMap(realmMap); return securityRealm; }; } }; return new TrivialResourceDefinition(ElytronDescriptionConstants.IDENTITY_REALM, add, IDENTITY_REALM_ATTRIBUTES, SECURITY_REALM_RUNTIME_CAPABILITY); }
Example #14
Source File: SaslServerDefinitions.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
static ResourceDefinition getProviderSaslServerFactoryDefinition() { AbstractAddStepHandler add = new SaslServerAddHandler(PROVIDERS) { @Override protected ServiceBuilder<SaslServerFactory> installService(OperationContext context, ServiceName saslServerFactoryName, ModelNode model) throws OperationFailedException { String providers = PROVIDERS.resolveModelAttribute(context, model).asStringOrNull(); final InjectedValue<Provider[]> providerInjector = new InjectedValue<Provider[]>(); final Supplier<Provider[]> providerSupplier = providers != null ? (providerInjector::getValue) : (Security::getProviders); TrivialService<SaslServerFactory> saslServiceFactoryService = new TrivialService<SaslServerFactory>(() -> new SecurityProviderSaslServerFactory(providerSupplier)); ServiceTarget serviceTarget = context.getServiceTarget(); ServiceBuilder<SaslServerFactory> serviceBuilder = serviceTarget.addService(saslServerFactoryName, saslServiceFactoryService); if (providers != null) { serviceBuilder.addDependency(context.getCapabilityServiceName(RuntimeCapability.buildDynamicCapabilityName(PROVIDERS_CAPABILITY, providers), Provider[].class), Provider[].class, providerInjector); } return serviceBuilder; } }; return wrap(new SaslServerResourceDefinition(ElytronDescriptionConstants.PROVIDER_SASL_SERVER_FACTORY, add, PROVIDERS), SaslServerDefinitions::getSaslServerAvailableMechanisms); }
Example #15
Source File: ReadAttributeTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
TestResourceDefinition(String path, boolean useDefaultReadAttributeHandler, AccessConstraintDefinition... constraintDefinitions) { super(new Parameters(pathElement(path), new NonResolvingResourceDescriptionResolver()) .setAddHandler(new AbstractAddStepHandler() {}) .setRemoveHandler(new AbstractRemoveStepHandler() {}) .setAccessConstraints(constraintDefinitions)); this.useDefaultReadAttributeHandler = useDefaultReadAttributeHandler; }
Example #16
Source File: AccessIdentityResourceDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private AccessIdentityResourceDefinition(AbstractAddStepHandler add) { super(new Parameters(PATH_ELEMENT, DomainManagementResolver.getResolver("core.identity")) .setAddHandler(add) .setRemoveHandler(ReloadRequiredRemoveStepHandler.INSTANCE) .setAddRestartLevel(OperationEntry.Flag.RESTART_NONE) .setRemoveRestartLevel(OperationEntry.Flag.RESTART_RESOURCE_SERVICES) .setCapabilities(MANAGEMENT_IDENTITY_RUNTIME_CAPABILITY) .setAccessConstraints(SensitiveTargetAccessConstraintDefinition.ACCESS_CONTROL)); }
Example #17
Source File: RoleMapperDefinitions.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
static ResourceDefinition getAddSuffixRoleMapperDefinition() { AbstractAddStepHandler add = new RoleMapperAddHandler(SUFFIX) { @Override protected ValueSupplier<RoleMapper> getValueSupplier(OperationContext context, ModelNode model) throws OperationFailedException { final String suffix = SUFFIX.resolveModelAttribute(context, model).asString(); return () -> (Roles r) -> r.addSuffix(suffix); } }; return new RoleMapperResourceDefinition(ElytronDescriptionConstants.ADD_SUFFIX_ROLE_MAPPER, add, SUFFIX); }
Example #18
Source File: RoleMapperDefinitions.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
static ResourceDefinition getAddPrefixRoleMapperDefinition() { AbstractAddStepHandler add = new RoleMapperAddHandler(PREFIX) { @Override protected ValueSupplier<RoleMapper> getValueSupplier(OperationContext context, ModelNode model) throws OperationFailedException { final String prefix = PREFIX.resolveModelAttribute(context, model).asString(); return () -> (Roles r) -> r.addPrefix(prefix); } }; return new RoleMapperResourceDefinition(ElytronDescriptionConstants.ADD_PREFIX_ROLE_MAPPER, add, PREFIX); }
Example #19
Source File: RoleMapperDefinitions.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
RoleMapperResourceDefinition(String pathKey, AbstractAddStepHandler add, AttributeDefinition ... attributes) { super(new Parameters(PathElement.pathElement(pathKey), ElytronExtension.getResourceDescriptionResolver(pathKey)) .setAddHandler(add) .setRemoveHandler(new TrivialCapabilityServiceRemoveHandler(add, ROLE_MAPPER_RUNTIME_CAPABILITY)) .setAddRestartLevel(OperationEntry.Flag.RESTART_RESOURCE_SERVICES) .setRemoveRestartLevel(OperationEntry.Flag.RESTART_RESOURCE_SERVICES) .setCapabilities(ROLE_MAPPER_RUNTIME_CAPABILITY)); this.pathKey = pathKey; this.attributes = attributes; }
Example #20
Source File: RoleMapperDefinitions.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
static ResourceDefinition getConstantRoleMapperDefinition() { AbstractAddStepHandler add = new RoleMapperAddHandler(ROLES) { @Override protected ValueSupplier<RoleMapper> getValueSupplier(OperationContext context, ModelNode model) throws OperationFailedException { List<String> rolesList = ROLES.unwrap(context, model); final Roles roles = Roles.fromSet(new HashSet<>(rolesList)); return () -> (Roles r) -> roles; } }; return new RoleMapperResourceDefinition(ElytronDescriptionConstants.CONSTANT_ROLE_MAPPER, add, ROLES); }
Example #21
Source File: PrincipalTransformerDefinitions.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
static ResourceDefinition getConstantPrincipalTransformerDefinition() { final AttributeDefinition[] attributes = new AttributeDefinition[] { CONSTANT }; AbstractAddStepHandler add = new TrivialAddHandler<PrincipalTransformer>(PrincipalTransformer.class, attributes, PRINCIPAL_TRANSFORMER_RUNTIME_CAPABILITY) { @Override protected ValueSupplier<PrincipalTransformer> getValueSupplier(ServiceBuilder<PrincipalTransformer> serviceBuilder, OperationContext context, ModelNode model) throws OperationFailedException { final Principal principal = new NamePrincipal(CONSTANT.resolveModelAttribute(context, model).asString()); return () -> p -> principal; } }; return new TrivialResourceDefinition(CONSTANT_PRINCIPAL_TRANSFORMER, add, attributes, PRINCIPAL_TRANSFORMER_RUNTIME_CAPABILITY); }
Example #22
Source File: EvidenceDecoderDefinitions.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
static ResourceDefinition getX500SubjectEvidenceDecoderDefinition() { final AttributeDefinition[] attributes = new AttributeDefinition[] {}; AbstractAddStepHandler add = new TrivialAddHandler<EvidenceDecoder>(EvidenceDecoder.class, attributes, EVIDENCE_DECODER_RUNTIME_CAPABILITY) { @Override protected ValueSupplier<EvidenceDecoder> getValueSupplier(ServiceBuilder<EvidenceDecoder> serviceBuilder, OperationContext context, ModelNode model) throws OperationFailedException { return () -> new X500SubjectEvidenceDecoder(); } }; return new TrivialResourceDefinition(X500_SUBJECT_EVIDENCE_DECODER, add, attributes, EVIDENCE_DECODER_RUNTIME_CAPABILITY); }
Example #23
Source File: EvidenceDecoderDefinitions.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
static ResourceDefinition getX509SubjectAltNameEvidenceDecoderDefinition() { final AttributeDefinition[] attributes = new AttributeDefinition[] { ALT_NAME_TYPE, SEGMENT }; AbstractAddStepHandler add = new TrivialAddHandler<EvidenceDecoder>(EvidenceDecoder.class, attributes, EVIDENCE_DECODER_RUNTIME_CAPABILITY) { @Override protected ValueSupplier<EvidenceDecoder> getValueSupplier(ServiceBuilder<EvidenceDecoder> serviceBuilder, OperationContext context, ModelNode model) throws OperationFailedException { final String altNameType = ALT_NAME_TYPE.resolveModelAttribute(context, model).asString(); final int segment = SEGMENT.resolveModelAttribute(context, model).asInt(); return () -> new X509SubjectAltNameEvidenceDecoder(SubjectAltNameType.fromName(altNameType).getType(), segment); } }; return new TrivialResourceDefinition(X509_SUBJECT_ALT_NAME_EVIDENCE_DECODER, add, attributes, EVIDENCE_DECODER_RUNTIME_CAPABILITY); }
Example #24
Source File: SSLDefinitions.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private static ResourceDefinition createSSLContextDefinition(String pathKey, boolean server, AbstractAddStepHandler addHandler, AttributeDefinition[] attributes, boolean serverOrHostController) { Builder builder = TrivialResourceDefinition.builder() .setPathKey(pathKey) .setAddHandler(addHandler) .setAttributes(attributes) .setRuntimeCapabilities(SSL_CONTEXT_RUNTIME_CAPABILITY); if (serverOrHostController) { builder.addReadOnlyAttribute(ACTIVE_SESSION_COUNT, new SSLContextRuntimeHandler() { @Override protected void performRuntime(ModelNode result, ModelNode operation, SSLContext sslContext) throws OperationFailedException { SSLSessionContext sessionContext = server ? sslContext.getServerSessionContext() : sslContext.getClientSessionContext(); int sum = 0; for (byte[] b : Collections.list(sessionContext.getIds())) { int i = 1; sum += i; } result.set(sum); } @Override protected ServiceUtil<SSLContext> getSSLContextServiceUtil() { return server ? SERVER_SERVICE_UTIL : CLIENT_SERVICE_UTIL; } }).addChild(new SSLSessionDefinition(server)); } return builder.build(); }
Example #25
Source File: PrincipalDecoderDefinitions.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
static ResourceDefinition getConstantPrincipalDecoder() { AttributeDefinition[] attributes = new AttributeDefinition[] { CONSTANT }; AbstractAddStepHandler add = new PrincipalDecoderAddHandler(attributes) { @Override protected ValueSupplier<PrincipalDecoder> getValueSupplier(ServiceBuilder<?> serviceBuilder, OperationContext context, ModelNode model) throws OperationFailedException { final String constant = CONSTANT.resolveModelAttribute(context, model).asString(); return () -> PrincipalDecoder.constant(constant); } }; return new PrincipalDecoderResourceDefinition(ElytronDescriptionConstants.CONSTANT_PRINCIPAL_DECODER, add, attributes); }
Example #26
Source File: PrincipalDecoderDefinitions.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
static ResourceDefinition getConcatenatingPrincipalDecoder() { AttributeDefinition[] attributes = new AttributeDefinition[] { JOINER, PRINCIPAL_DECODERS }; AbstractAddStepHandler add = new PrincipalDecoderAddHandler(attributes) { @Override protected ValueSupplier<PrincipalDecoder> getValueSupplier(ServiceBuilder<?> serviceBuilder, OperationContext context, ModelNode model) throws OperationFailedException { final String joiner = JOINER.resolveModelAttribute(context, model).asString(); final List<String> decoders = PRINCIPAL_DECODERS.unwrap(context, model); final List<InjectedValue<PrincipalDecoder>> principalDecoderInjectors = new ArrayList<>(); final String baseCapabilityName = PRINCIPAL_DECODER_RUNTIME_CAPABILITY.getName(); for (String decoder : decoders) { InjectedValue<PrincipalDecoder> principalDecoderInjector = new InjectedValue<>(); String runtimeCapabilityName = RuntimeCapability.buildDynamicCapabilityName(baseCapabilityName, decoder); ServiceName decoderServiceName = context.getCapabilityServiceName(runtimeCapabilityName, PrincipalDecoder.class); serviceBuilder.addDependency(decoderServiceName, PrincipalDecoder.class, principalDecoderInjector); principalDecoderInjectors.add(principalDecoderInjector); } return () -> { final ArrayList<PrincipalDecoder> principalDecoders = new ArrayList<>(principalDecoderInjectors.size()); for (InjectedValue<PrincipalDecoder> current : principalDecoderInjectors) { principalDecoders.add(current.getValue()); } return PrincipalDecoder.concatenating(joiner, principalDecoders.toArray(new PrincipalDecoder[principalDecoders.size()])); }; } }; return new PrincipalDecoderResourceDefinition(ElytronDescriptionConstants.CONCATENATING_PRINCIPAL_DECODER, add, attributes); }
Example #27
Source File: PrincipalDecoderDefinitions.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
PrincipalDecoderResourceDefinition(String pathKey, AbstractAddStepHandler add, AttributeDefinition ... attributes) { super(new Parameters(PathElement.pathElement(pathKey), ElytronExtension.getResourceDescriptionResolver(pathKey)) .setAddHandler(add) .setRemoveHandler(new TrivialCapabilityServiceRemoveHandler(add, PRINCIPAL_DECODER_RUNTIME_CAPABILITY, PRINCIPAL_TRANSFORMER_RUNTIME_CAPABILITY)) .setAddRestartLevel(OperationEntry.Flag.RESTART_RESOURCE_SERVICES) .setRemoveRestartLevel(OperationEntry.Flag.RESTART_RESOURCE_SERVICES) .setCapabilities(PRINCIPAL_DECODER_RUNTIME_CAPABILITY, PRINCIPAL_TRANSFORMER_RUNTIME_CAPABILITY)); this.pathKey = pathKey; this.attributes = attributes; }
Example #28
Source File: SensitiveResource.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
public SensitiveResource(PathElement pathElement) { super(new Parameters(pathElement, new NonResolvingResourceDescriptionResolver()) .setAddHandler(new AbstractAddStepHandler()) .setRemoveHandler(ReloadRequiredRemoveStepHandler.INSTANCE) .setAccessConstraints(SensitiveTargetAccessConstraintDefinition.SECURITY_DOMAIN, new ApplicationTypeAccessConstraintDefinition(new ApplicationTypeConfig("security", "security-domain")))); }
Example #29
Source File: SensitiveResource.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
public SensitiveResource(PathElement pathElement) { super(new Parameters(pathElement, new NonResolvingResourceDescriptionResolver()) .setAddHandler(new AbstractAddStepHandler()) .setRemoveHandler(ModelOnlyRemoveStepHandler.INSTANCE) .setAccessConstraints(SensitiveTargetAccessConstraintDefinition.SECURITY_DOMAIN, new ApplicationTypeAccessConstraintDefinition(new ApplicationTypeConfig("rbac", "security-domain")))); }
Example #30
Source File: CustomComponentDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private static <C, T> Parameters addAddRemoveHandlers(Parameters parameters, Class<C> serviceType, Function<C, T> wrapper, RuntimeCapability<?> ... runtimeCapabilities) { AbstractAddStepHandler add = new ComponentAddHandler<>(serviceType, wrapper, runtimeCapabilities); OperationStepHandler remove = new TrivialCapabilityServiceRemoveHandler(add, runtimeCapabilities); parameters.setAddHandler(add); parameters.setRemoveHandler(remove); return parameters; }