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

Java SecurityConstraint类代码示例

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

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



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

示例1: postProcess

import io.undertow.servlet.api.SecurityConstraint; //导入依赖的package包/类
@Override
public void postProcess(BootContext context) {
  boolean statelessAuth = statelessAuth(context);
  DeploymentInfo deploymentInfo = context.deploymentInfo();

  deploymentInfo.addAuthenticationMechanism(RestAuthenticationMechanism.MECHANISM_NAME, (name, formParserFactory,
    properties) -> new RestAuthenticationMechanism(statelessAuth, context.getService(UserRepository.class)));

  LoginConfig loginConfig = new LoginConfig(RestAuthenticationMechanism.MECHANISM_NAME, "vas-db-realm");
  deploymentInfo.setLoginConfig(loginConfig);

  deploymentInfo.setIdentityManager(context.getService(IdentityManager.class));
  deploymentInfo.addSecurityConstraint(new SecurityConstraint().addRoleAllowed(User.ROLE).addWebResourceCollection(
    new WebResourceCollection().addUrlPattern("/*")));

  logoutServlet(context, deploymentInfo);
}
 
开发者ID:vvergnolle,项目名称:vas,代码行数:18,代码来源:AuthHttpHandlerPostProcessor.java


示例2: setServletSecurity

import io.undertow.servlet.api.SecurityConstraint; //导入依赖的package包/类
@Override
public Set<String> setServletSecurity(final ServletSecurityElement constraint) {
    if (constraint == null) {
        throw UndertowMessages.MESSAGES.argumentCannotBeNull("constraint");
    }
    DeploymentInfo deploymentInfo = deployment.getDeploymentInfo();

    //this is not super efficient, but it does not really matter
    final Set<String> urlPatterns = new HashSet<>();
    for (SecurityConstraint sc : deploymentInfo.getSecurityConstraints()) {
        for (WebResourceCollection webResources : sc.getWebResourceCollections()) {
            urlPatterns.addAll(webResources.getUrlPatterns());
        }
    }
    final Set<String> ret = new HashSet<>();
    for (String url : servletInfo.getMappings()) {
        if (urlPatterns.contains(url)) {
            ret.add(url);
        }
    }
    ServletSecurityInfo info = new ServletSecurityInfo();
    servletInfo.setServletSecurityInfo(info);
    info.setTransportGuaranteeType(constraint.getTransportGuarantee() == CONFIDENTIAL ? TransportGuaranteeType.CONFIDENTIAL : TransportGuaranteeType.NONE)
            .setEmptyRoleSemantic(emptyRoleSemantic(constraint.getEmptyRoleSemantic()))
            .addRolesAllowed(constraint.getRolesAllowed());

    for (final HttpMethodConstraintElement methodConstraint : constraint.getHttpMethodConstraints()) {
        info.addHttpMethodSecurityInfo(new HttpMethodSecurityInfo()
                .setTransportGuaranteeType(methodConstraint.getTransportGuarantee() == CONFIDENTIAL ? TransportGuaranteeType.CONFIDENTIAL : TransportGuaranteeType.NONE)
                .setMethod(methodConstraint.getMethodName())
                .setEmptyRoleSemantic(emptyRoleSemantic(methodConstraint.getEmptyRoleSemantic()))
                .addRolesAllowed(methodConstraint.getRolesAllowed()));
    }
    return ret;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:36,代码来源:ServletRegistrationImpl.java


示例3: securityConstraint

import io.undertow.servlet.api.SecurityConstraint; //导入依赖的package包/类
private static SecurityConstraint securityConstraint(Config cfg) {
    return Servlets.securityConstraint()
            .addRolesAllowed(cfg.getStringList(KEY_AUTH_ROLES))
            .addWebResourceCollection(Servlets.webResourceCollection()
                    .addHttpMethods(cfg.getStringList(KEY_SECURED_URLS_ALLOWED_METHODS))
                    .addUrlPatterns(cfg.getStringList(KEY_SECURED_URLS)));
}
 
开发者ID:AdeptJ,项目名称:adeptj-runtime,代码行数:8,代码来源:Server.java


示例4: configureDeploymentSecurity

import io.undertow.servlet.api.SecurityConstraint; //导入依赖的package包/类
private void configureDeploymentSecurity(DeploymentInfo deploymentInfo) {
    deploymentInfo.setIdentityManager(identityManager);
    deploymentInfo.setLoginConfig(new LoginConfig(HttpServletRequest.BASIC_AUTH, "lightblueRealm"));
    deploymentInfo.addSecurityConstraint(new SecurityConstraint()
            .addWebResourceCollection(new WebResourceCollection().addUrlPattern("/*"))
            .addRoleAllowed(SECURITY_ROLE_AUTHENTICATED));
    deploymentInfo.addSecurityRole(SECURITY_ROLE_AUTHENTICATED);
}
 
开发者ID:lightblue-platform,项目名称:lightblue-rest,代码行数:9,代码来源:LightblueRestTestHarness.java


示例5: addConstraints

import io.undertow.servlet.api.SecurityConstraint; //导入依赖的package包/类
public void addConstraints(DeploymentInfo servletBuilder, ServerOptions serverOptions) {
    servletBuilder.addSecurityConstraint(new SecurityConstraint()
            .addWebResourceCollection(new WebResourceCollection()
                    .addUrlPattern("*"))
            .addRoleAllowed("role1")
            .setEmptyRoleSemantic(SecurityInfo.EmptyRoleSemantic.DENY));
}
 
开发者ID:cfmlprojects,项目名称:runwar,代码行数:8,代码来源:SecurityManager.java


示例6: securityConstraint

import io.undertow.servlet.api.SecurityConstraint; //导入依赖的package包/类
public static SecurityConstraint securityConstraint() {
    return new SecurityConstraint();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:4,代码来源:Servlets.java


示例7: addServant

import io.undertow.servlet.api.SecurityConstraint; //导入依赖的package包/类
public void addServant(URL nurl, UndertowHTTPHandler handler) {

        ServletInfo servletInfo = Servlets.servlet("DefaultServlet", DefaultServlet.class).addMapping("/*");

        DeploymentInfo servletBuilder = Servlets.deployment()
            .setClassLoader(WildflyHTTPServerEngine.class.getClassLoader())
            .setContextPath(nurl.getPath())
            .setDeploymentName("cxfdestination.war")
            .addServlets(servletInfo);

        if (nurl.getProtocol().equals("https")) {
            SecurityConstraint securityConstraint = new SecurityConstraint();
            WebResourceCollection webResourceCollection = new WebResourceCollection();
            webResourceCollection.addUrlPattern("/*");

            securityConstraint.addWebResourceCollection(webResourceCollection);
            securityConstraint.setTransportGuaranteeType(TransportGuaranteeType.CONFIDENTIAL);
            securityConstraint.setEmptyRoleSemantic(SecurityInfo.EmptyRoleSemantic.PERMIT);

            servletBuilder.addSecurityConstraint(securityConstraint);
            servletBuilder.setConfidentialPortManager(exchange -> {
                int port = exchange.getConnection().getLocalAddress(InetSocketAddress.class).getPort();
                return defaultHost.getServer().getValue().lookupSecurePort(port);
            });
        }

        manager = Servlets.defaultContainer().addDeployment(servletBuilder);
        manager.deploy();

        try {
            HttpHandler servletHandler = manager.start();
            defaultHost.registerDeployment(manager.getDeployment(), servletHandler);

            UndertowHTTPDestination destination = handler.getHTTPDestination();
            destination.setServletContext(manager.getDeployment().getServletContext());

            ManagedServlet managedServlet = manager.getDeployment().getServlets().getManagedServlet("DefaultServlet");
            DefaultServlet servletInstance = (DefaultServlet) managedServlet.getServlet().getInstance();
            servletInstance.setHTTPDestination(destination);
        } catch (ServletException ex) {
            throw new IllegalStateException(ex);
        }
    }
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:44,代码来源:WildflyHTTPServerEngine.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java JavaUtils类代码示例发布时间:2022-05-23
下一篇:
Java ConditionalExpression类代码示例发布时间: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