private void addPlugInAuthorizationService( OperationContext context, ModelNode model, String realmName, ServiceTarget serviceTarget, List<ServiceController<?>> newControllers, ServiceBuilder<?> realmBuilder, InjectedValue<SubjectSupplementalService> injector) throws OperationFailedException { ServiceName plugInServiceName = PlugInSubjectSupplemental.ServiceUtil.createServiceName(realmName); final String pluginName = PlugInAuthorizationResourceDefinition.NAME.resolveModelAttribute(context, model).asString(); final Map<String, String> properties = resolveProperties(context, model); PlugInSubjectSupplemental plugInSubjectSupplemental = new PlugInSubjectSupplemental(realmName, pluginName, properties); ServiceBuilder<?> plugInBuilder = serviceTarget.addService(plugInServiceName, plugInSubjectSupplemental); PlugInLoaderService.ServiceUtil.addDependency( plugInBuilder, plugInSubjectSupplemental.getPlugInLoaderServiceValue(), realmName, false); final ServiceController<?> serviceController = plugInBuilder.setInitialMode(ON_DEMAND).install(); if (newControllers != null) { newControllers.add(serviceController); } SubjectSupplementalService.ServiceUtil.addDependency( realmBuilder, injector, plugInServiceName, false); }
private void addPlugInAuthenticationService( OperationContext context, ModelNode model, String realmName, SecurityRealmService registry, ServiceTarget serviceTarget, List<ServiceController<?>> newControllers, ServiceBuilder<?> realmBuilder, Injector<CallbackHandlerService> injector) throws OperationFailedException { ServiceName plugInServiceName = PlugInAuthenticationCallbackHandler.ServiceUtil.createServiceName(realmName); final String pluginName = PlugInAuthorizationResourceDefinition.NAME.resolveModelAttribute(context, model).asString(); final Map<String, String> properties = resolveProperties(context, model); String mechanismName = PlugInAuthenticationResourceDefinition.MECHANISM .resolveModelAttribute(context, model) .asString(); AuthMechanism mechanism = AuthMechanism.valueOf(mechanismName); PlugInAuthenticationCallbackHandler plugInService = new PlugInAuthenticationCallbackHandler( registry.getName(), pluginName, properties, mechanism); ServiceBuilder<CallbackHandlerService> plugInBuilder = serviceTarget.addService(plugInServiceName, plugInService); PlugInLoaderService.ServiceUtil.addDependency( plugInBuilder, plugInService.getPlugInLoaderServiceValue(), realmName, false); final ServiceController<CallbackHandlerService> sc = plugInBuilder.setInitialMode(ON_DEMAND).install(); if (newControllers != null) { newControllers.add(sc); } CallbackHandlerService.ServiceUtil.addDependency( realmBuilder, injector, plugInServiceName, false); }
private ServiceName addPlugInLoaderService( String realmName, ModelNode plugInModel, ServiceTarget serviceTarget, List<ServiceController<?>> newControllers) { ServiceName plugInLoaderName = PlugInLoaderService.ServiceUtil.createServiceName(realmName); List<Property> plugIns = plugInModel.asPropertyList(); ArrayList<String> knownNames = new ArrayList<String>(plugIns.size()); for (Property current : plugIns) { knownNames.add(current.getName()); } PlugInLoaderService loaderService = new PlugInLoaderService(Collections.unmodifiableList(knownNames)); ServiceBuilder<PlugInLoaderService> builder = serviceTarget.addService(plugInLoaderName, loaderService); final ServiceController<PlugInLoaderService> sc = builder.setInitialMode(Mode.ON_DEMAND).install(); if (newControllers != null) { newControllers.add(sc); } return plugInLoaderName; }