Search in sources :

Example 1 with ServiceName

use of io.datarouter.web.config.service.ServiceName in project datarouter by hotpads.

the class DatarouterPermissionRequestHandler method showForm.

@Handler(defaultHandler = true)
private Mav showForm(OptionalString deniedUrl, OptionalString allowedRoles) {
    if (!authenticationConfig.useDatarouterAuthentication()) {
        return new MessageMav(noDatarouterAuthentication());
    }
    Mav mav = new Mav(files.jsp.authentication.permissionRequestJsp);
    mav.put("serviceName", serviceName.get());
    mav.put("permissionRequestPath", paths.permissionRequest.toSlashedString());
    Optional<String> defaultSpecifics = deniedUrl.map(url -> {
        return "I tried to go to this URL: " + url + "." + allowedRoles.map(" These are its allowed roles at the time of this request: "::concat).orElse("");
    });
    mav.put("defaultSpecifics", defaultSpecifics);
    DatarouterUser user = getCurrentUser();
    mav.put("currentRequest", datarouterPermissionRequestDao.scanOpenPermissionRequestsForUser(user.getId()).findMax(Comparator.comparing(request -> request.getKey().getRequestTime())).orElse(null));
    Set<String> emails = new HashSet<>();
    if (serverTypeDetector.mightBeProduction()) {
        emails.addAll(permissionRequestEmailType.tos);
    }
    emails.add(adminEmail.get());
    if (subscribersSettings.includeSubscribers.get()) {
        emails.addAll(subscibersEmail.get());
    }
    mav.put("email", emails);
    mav.put("submitPath", paths.permissionRequest.submit.join("/"));
    mav.put("declinePath", paths.permissionRequest.declineAll.join("/"));
    return mav;
}
Also used : MessageMav(io.datarouter.web.handler.mav.imp.MessageMav) DatarouterUserExternalDetailService(io.datarouter.web.user.detail.DatarouterUserExternalDetailService) Date(java.util.Date) DatarouterEmailSubscriberSettings(io.datarouter.storage.config.setting.DatarouterEmailSubscriberSettings) DatarouterHtmlEmailService(io.datarouter.web.email.DatarouterHtmlEmailService) LoggerFactory(org.slf4j.LoggerFactory) DatarouterUserInfo(io.datarouter.auth.service.DatarouterUserInfo) OptionalString(io.datarouter.web.handler.types.optional.OptionalString) ServiceName(io.datarouter.web.config.service.ServiceName) DatarouterAuthFiles(io.datarouter.auth.config.DatarouterAuthFiles) MessageMav(io.datarouter.web.handler.mav.imp.MessageMav) DatarouterUserService(io.datarouter.auth.service.DatarouterUserService) DatarouterUserRole(io.datarouter.web.user.role.DatarouterUserRole) GlobalRedirectMav(io.datarouter.web.handler.mav.imp.GlobalRedirectMav) InContextRedirectMav(io.datarouter.web.handler.mav.imp.InContextRedirectMav) ServerTypeDetector(io.datarouter.storage.servertype.ServerTypeDetector) TagCreator.table(j2html.TagCreator.table) Set(java.util.Set) Instant(java.time.Instant) ZoneId(java.time.ZoneId) DatarouterPermissionRequest(io.datarouter.auth.storage.permissionrequest.DatarouterPermissionRequest) DatarouterAuthenticationConfig(io.datarouter.web.user.authenticate.config.DatarouterAuthenticationConfig) ContainerTag(j2html.tags.ContainerTag) Objects(java.util.Objects) Optional(java.util.Optional) TagCreator.text(j2html.TagCreator.text) HashSet(java.util.HashSet) Inject(javax.inject.Inject) DatarouterUser(io.datarouter.web.user.databean.DatarouterUser) AdminEmail(io.datarouter.storage.config.properties.AdminEmail) DatarouterUserEditService(io.datarouter.auth.service.DatarouterUserEditService) TagCreator.p(j2html.TagCreator.p) Logger(org.slf4j.Logger) DatarouterAuthPaths(io.datarouter.auth.config.DatarouterAuthPaths) Mav(io.datarouter.web.handler.mav.Mav) TagCreator.b(j2html.TagCreator.b) StringTool(io.datarouter.util.string.StringTool) TagCreator.a(j2html.TagCreator.a) OptionalLong(io.datarouter.web.handler.types.optional.OptionalLong) ZonedDateFormatterTool(io.datarouter.util.time.ZonedDateFormatterTool) DomContent(j2html.tags.DomContent) DatarouterPermissionRequestDao(io.datarouter.auth.storage.permissionrequest.DatarouterPermissionRequestDao) TagCreator.td(j2html.TagCreator.td) PermissionRequestEmailType(io.datarouter.email.type.DatarouterEmailTypes.PermissionRequestEmailType) BaseHandler(io.datarouter.web.handler.BaseHandler) TagCreator.tr(j2html.TagCreator.tr) TagCreator.tbody(j2html.TagCreator.tbody) Comparator(java.util.Comparator) DatarouterSubscribersSupplier(io.datarouter.storage.config.DatarouterSubscribersSupplier) TagCreator.div(j2html.TagCreator.div) MessageMav(io.datarouter.web.handler.mav.imp.MessageMav) GlobalRedirectMav(io.datarouter.web.handler.mav.imp.GlobalRedirectMav) InContextRedirectMav(io.datarouter.web.handler.mav.imp.InContextRedirectMav) Mav(io.datarouter.web.handler.mav.Mav) DatarouterUser(io.datarouter.web.user.databean.DatarouterUser) OptionalString(io.datarouter.web.handler.types.optional.OptionalString) HashSet(java.util.HashSet) BaseHandler(io.datarouter.web.handler.BaseHandler)

Example 2 with ServiceName

use of io.datarouter.web.config.service.ServiceName in project datarouter by hotpads.

the class DatarouterWebGuiceModule method configureServlets.

@Override
protected void configureServlets() {
    install(new DatarouterSecretPluginBuilderImpl().build().getAsDefaultBinderModule());
    install(new DatarouterStorageGuiceModule());
    bind(ServletContextSupplier.class).toInstance(new ServletContextProvider(getServletContext()));
    bind(JsonSerializer.class).annotatedWith(Names.named(HandlerEncoder.DEFAULT_HANDLER_SERIALIZER)).to(GsonJsonSerializer.class);
    bind(PortIdentifier.class).annotatedWith(Names.named(CompoundPortIdentifier.COMPOUND_PORT_IDENTIFIER)).to(CompoundPortIdentifier.class);
    bindDefault(DatarouterAuthenticationConfig.class, BaseDatarouterAuthenticationConfig.class);
    bindDefaultInstance(ServiceName.class, new ServiceName(""));
    bindDefaultInstance(PublicDomain.class, new PublicDomain(""));
    bindDefaultInstance(PrivateDomain.class, new PrivateDomain(""));
    bindDefaultInstance(ContextName.class, new ContextName(""));
    bindDefault(BaseDatarouterSessionDao.class, NoOpDatarouterSessionDao.class);
    bindDefault(BaseDatarouterSamlDao.class, NoOpDatarouterSamlDao.class);
    bindDefault(ExceptionRecorder.class, NoOpExceptionRecorder.class);
    optionalBinder(AppNavBar.class);
    bindDefault(RoleManager.class, DatarouterRoleManager.class);
    optionalBinder(SamlRegistrar.class);
    bindDefault(SettingFinder.class, MemorySettingFinder.class);
    bindDefault(UserSessionService.class, NoOpUserSessionService.class);
    bindDefault(CurrentSessionInfo.class, NoOpCurrentSessionInfo.class);
    bindDefault(LatencyMonitoringGraphLink.class, NoOpLatencyMonitoringGraphLink.class);
    bindDefault(AppNavBarRegistrySupplier.class, NoOpAppNavBarRegistry.class);
    bindDefault(ChangelogRecorder.class, NoOpChangelogRecorder.class);
    // define as singleton for everybody
    bind(Gson.class).toInstance(GsonTool.GSON);
    bindDefaultInstance(DefaultEmailDistributionListZoneId.class, new DefaultEmailDistributionListZoneId(ZoneId.systemDefault()));
}
Also used : DefaultEmailDistributionListZoneId(io.datarouter.web.config.properties.DefaultEmailDistributionListZoneId) ServiceName(io.datarouter.web.config.service.ServiceName) DatarouterStorageGuiceModule(io.datarouter.storage.config.guice.DatarouterStorageGuiceModule) Gson(com.google.gson.Gson) DatarouterSecretPluginBuilderImpl(io.datarouter.secret.config.DatarouterSecretPlugin.DatarouterSecretPluginBuilder.DatarouterSecretPluginBuilderImpl) PrivateDomain(io.datarouter.web.config.service.PrivateDomain) PublicDomain(io.datarouter.web.config.service.PublicDomain) ContextName(io.datarouter.web.config.service.ContextName)

Example 3 with ServiceName

use of io.datarouter.web.config.service.ServiceName in project datarouter by hotpads.

the class TraceFilter method init.

@Override
public void init(FilterConfig filterConfig) {
    DatarouterInjector injector = getInjector(filterConfig.getServletContext());
    serverName = injector.getInstance(ServerName.class);
    trace2BufferForLocal = injector.getInstance(Trace2ForLocalFilterToMemoryBuffer.class);
    trace2BufferForPublisher = injector.getInstance(Trace2ForPublisherFilterToMemoryBuffer.class);
    traceSettings = injector.getInstance(DatarouterTraceFilterSettingRoot.class);
    urlBuilder = injector.getInstance(TraceUrlBuilder.class);
    currentSessionInfo = injector.getInstance(CurrentSessionInfo.class);
    handlerMetrics = injector.getInstance(HandlerMetrics.class);
    serviceName = injector.getInstance(ServiceName.class);
}
Also used : Trace2ForLocalFilterToMemoryBuffer(io.datarouter.trace.conveyor.local.Trace2ForLocalFilterToMemoryBuffer) DatarouterInjector(io.datarouter.inject.DatarouterInjector) ServiceName(io.datarouter.web.config.service.ServiceName) ServerName(io.datarouter.storage.config.properties.ServerName) HandlerMetrics(io.datarouter.web.handler.HandlerMetrics) Trace2ForPublisherFilterToMemoryBuffer(io.datarouter.trace.conveyor.publisher.Trace2ForPublisherFilterToMemoryBuffer) DatarouterTraceFilterSettingRoot(io.datarouter.trace.settings.DatarouterTraceFilterSettingRoot) TraceUrlBuilder(io.datarouter.trace.service.TraceUrlBuilder) CurrentSessionInfo(io.datarouter.web.user.session.CurrentSessionInfo)

Example 4 with ServiceName

use of io.datarouter.web.config.service.ServiceName in project datarouter by hotpads.

the class DatarouterWebPlugin method configure.

@Override
public void configure() {
    bind(FilesRoot.class).to(filesClass);
    bindActualNullSafe(ExceptionRecorder.class, exceptionRecorderClass);
    bindActualNullSafe(DatarouterAuthenticationConfig.class, authenticationConfigClass);
    bindActualNullSafe(CurrentSessionInfo.class, currentSessionInfoClass);
    bindDefault(ExceptionHandlingConfig.class, exceptionHandlingConfigClass);
    bindActualInstance(AppListenersClasses.class, new DatarouterAppListenersClasses(appListenerClasses));
    bindActualInstance(WebAppListenersClasses.class, new DatarouterWebAppListenersClasses(webAppListenerClasses));
    bindActualNullSafe(RoleManager.class, roleManagerClass);
    bindActualNullSafe(UserSessionService.class, userSessionServiceClass);
    bindActualNullSafe(DatarouterUserExternalDetailService.class, datarouterUserExternalDetailClass);
    bindActualNullSafe(AppNavBarRegistrySupplier.class, appNavBarRegistrySupplier);
    bind(HomepageHandler.class).to(homepageHandler);
    bind(HomepageRouteSet.class).to(homepageRouteSet);
    bindActualInstance(PluginRegistrySupplier.class, new PluginRegistry(registeredPlugins));
    bindActualInstance(NodeWidgetDatabeanExporterLinkSupplier.class, new NodeWidgetDatabeanExporterLink(nodeWidgetDatabeanExporterLink));
    bindActualInstance(NodeWidgetTableCountLinkSupplier.class, new NodeWidgetTableCountLink(nodeWidgetTableCountLink));
    bind(RequestProxySetter.class).to(requestProxy);
    bindActualInstance(DefaultEmailDistributionListZoneId.class, new DefaultEmailDistributionListZoneId(defaultEmailDistributionListZoneId));
    bindActualInstance(DailyDigestEmailZoneId.class, new DailyDigestEmailZoneId(dailyDigestEmailZoneId));
    bindActualInstance(ServiceName.class, new ServiceName(serviceName));
    bindActualInstance(PublicDomain.class, new PublicDomain(publicDomain));
    bindActualInstance(PrivateDomain.class, new PrivateDomain(privateDomain));
    bindActualInstance(ContextName.class, new ContextName(contextName));
}
Also used : NodeWidgetTableCountLink(io.datarouter.web.browse.widget.NodeWidgetTableCountLinkSupplier.NodeWidgetTableCountLink) HomepageRouteSet(io.datarouter.web.homepage.HomepageRouteSet) DefaultHomepageRouteSet(io.datarouter.web.homepage.DefaultHomepageRouteSet) DefaultEmailDistributionListZoneId(io.datarouter.web.config.properties.DefaultEmailDistributionListZoneId) DatarouterWebAppListenersClasses(io.datarouter.web.listener.WebAppListenersClasses.DatarouterWebAppListenersClasses) NodeWidgetDatabeanExporterLink(io.datarouter.web.browse.widget.NodeWidgetDatabeanExporterLinkSupplier.NodeWidgetDatabeanExporterLink) PublicDomain(io.datarouter.web.config.service.PublicDomain) DatarouterAppListenersClasses(io.datarouter.web.listener.AppListenersClasses.DatarouterAppListenersClasses) ServiceName(io.datarouter.web.config.service.ServiceName) PluginRegistry(io.datarouter.web.plugin.PluginRegistrySupplier.PluginRegistry) DailyDigestEmailZoneId(io.datarouter.web.digest.DailyDigestEmailZoneId) HomepageHandler(io.datarouter.web.homepage.HomepageHandler) SimpleHomepageHandler(io.datarouter.web.homepage.SimpleHomepageHandler) RequestProxySetter(io.datarouter.httpclient.proxy.RequestProxySetter) NoOpFilesRoot(io.datarouter.pathnode.FilesRoot.NoOpFilesRoot) FilesRoot(io.datarouter.pathnode.FilesRoot) PrivateDomain(io.datarouter.web.config.service.PrivateDomain) ContextName(io.datarouter.web.config.service.ContextName)

Aggregations

ServiceName (io.datarouter.web.config.service.ServiceName)4 DefaultEmailDistributionListZoneId (io.datarouter.web.config.properties.DefaultEmailDistributionListZoneId)2 ContextName (io.datarouter.web.config.service.ContextName)2 PrivateDomain (io.datarouter.web.config.service.PrivateDomain)2 PublicDomain (io.datarouter.web.config.service.PublicDomain)2 Gson (com.google.gson.Gson)1 DatarouterAuthFiles (io.datarouter.auth.config.DatarouterAuthFiles)1 DatarouterAuthPaths (io.datarouter.auth.config.DatarouterAuthPaths)1 DatarouterUserEditService (io.datarouter.auth.service.DatarouterUserEditService)1 DatarouterUserInfo (io.datarouter.auth.service.DatarouterUserInfo)1 DatarouterUserService (io.datarouter.auth.service.DatarouterUserService)1 DatarouterPermissionRequest (io.datarouter.auth.storage.permissionrequest.DatarouterPermissionRequest)1 DatarouterPermissionRequestDao (io.datarouter.auth.storage.permissionrequest.DatarouterPermissionRequestDao)1 PermissionRequestEmailType (io.datarouter.email.type.DatarouterEmailTypes.PermissionRequestEmailType)1 RequestProxySetter (io.datarouter.httpclient.proxy.RequestProxySetter)1 DatarouterInjector (io.datarouter.inject.DatarouterInjector)1 FilesRoot (io.datarouter.pathnode.FilesRoot)1 NoOpFilesRoot (io.datarouter.pathnode.FilesRoot.NoOpFilesRoot)1 DatarouterSecretPluginBuilderImpl (io.datarouter.secret.config.DatarouterSecretPlugin.DatarouterSecretPluginBuilder.DatarouterSecretPluginBuilderImpl)1 DatarouterSubscribersSupplier (io.datarouter.storage.config.DatarouterSubscribersSupplier)1