Package org.eclipse.jetty.security

Examples of org.eclipse.jetty.security.ConstraintSecurityHandler


        ConstraintMapping cm = new ConstraintMapping();
        cm.setPathSpec("/*");
        cm.setConstraint(constraint);

        ConstraintSecurityHandler sh = new ConstraintSecurityHandler();
        sh.setAuthenticator(new BasicAuthenticator());
        sh.setConstraintMappings(new ConstraintMapping[] {cm});
       
        HashLoginService loginService = new HashLoginService("MyRealm", "src/test/resources/myRealm.properties");
        sh.setLoginService(loginService);
        sh.setConstraintMappings(new ConstraintMapping[]{cm});

        return sh;
    }
View Full Code Here


        loginService.putUser( Users.JANNE, new Password(Users.JANNE_PASS), new String[] {"Authenticated"} );

        WebAppContext webAppContext = new WebAppContext(path, context);

        // Add a security handler.
        SecurityHandler csh = new ConstraintSecurityHandler();
        csh.setLoginService( loginService );
        webAppContext.setSecurityHandler( csh );

        log.error( "Adding webapp " + context + " for path " + path );
        handlerCollection.addHandler( webAppContext );
View Full Code Here

        loginService.putUser( Users.JANNE, new Password(Users.JANNE_PASS), new String[] {"Authenticated"} );

        WebAppContext webAppContext = new WebAppContext(path, context);

        // Add a security handler.
        SecurityHandler csh = new ConstraintSecurityHandler();
        csh.setLoginService( loginService );
        webAppContext.setSecurityHandler( csh );

        log.error( "Adding webapp " + context + " for path " + path );
        handlerCollection.addHandler( webAppContext );
View Full Code Here

      // create the servlet request handler
      ServletContextHandler servletHandler = createServletHandler(servletDefinition);
      // add security handler if security settings were specified
      if (servletDefinition.isRequireHttps()
          || servletDefinition.isRequireBasicAuth()) {
        ConstraintSecurityHandler securityHandler = createSecurityHandler(
            server, servletDefinition);
        servletHandler.setSecurityHandler(securityHandler);
      }
      servletHandlers.addHandler(servletHandler);
    }
View Full Code Here

   *            The {@link Server} for which the security handler is created.
   * @return
   */
  private ConstraintSecurityHandler createSecurityHandler(Server server,
      ServletDefinition servletDefinition) {
    ConstraintSecurityHandler securityHandler = new ConstraintSecurityHandler();
    securityHandler.setServer(server);

    Constraint constraint = new Constraint();
    constraint.setName("security" + servletDefinition.hashCode());

    if (servletDefinition.isRequireBasicAuth()) {
      // add basic authentication and role-based authorization based on
      // the credentials store (realm file)
      LoginService loginService = new HashLoginService(
          "elastisys:scale security realm",
          servletDefinition.getRealmFile());
      securityHandler.getServer().addBean(loginService);
      securityHandler.setAuthenticator(new BasicAuthenticator());
      securityHandler.setLoginService(loginService);
      constraint.setAuthenticate(true);
      constraint.setRoles(new String[] { servletDefinition
          .getRequireRole() });
    }

    // require confidential transport: HTTP requests will be redirected to
    // the secure (https) port.
    if (servletDefinition.isRequireHttps()) {
      constraint.setDataConstraint(Constraint.DC_CONFIDENTIAL);
    }

    // apply constraint to all pages/web resources
    ConstraintMapping mapping = new ConstraintMapping();
    mapping.setConstraint(constraint);
    mapping.setPathSpec("/*");
    securityHandler.setConstraintMappings(Lists.newArrayList(mapping));

    return securityHandler;
  }
View Full Code Here

        ConstraintMapping cm = new ConstraintMapping();
        cm.setPathSpec("/*");
        cm.setConstraint(constraint);

        ConstraintSecurityHandler sh = new ConstraintSecurityHandler();
        sh.setAuthenticator(new BasicAuthenticator());
        sh.setConstraintMappings(Arrays.asList(new ConstraintMapping[] {cm}));

        HashLoginService loginService = new HashLoginService("MyRealm", "src/test/resources/myRealm.properties");
        sh.setLoginService(loginService);
        sh.setConstraintMappings(Arrays.asList(new ConstraintMapping[]{cm}));

        return sh;
    }
View Full Code Here

        ConstraintMapping cm = new ConstraintMapping();
        cm.setPathSpec("/*");
        cm.setConstraint(constraint);

        ConstraintSecurityHandler sh = new ConstraintSecurityHandler();
        sh.setAuthenticator(new BasicAuthenticator());
        sh.setConstraintMappings(Arrays.asList(new ConstraintMapping[] {cm}));

        HashLoginService loginService = new HashLoginService("MyRealm", "src/test/resources/myRealm.properties");
        sh.setLoginService(loginService);
        sh.setConstraintMappings(Arrays.asList(new ConstraintMapping[]{cm}));

        return sh;
    }
View Full Code Here

        ConstraintMapping cm = new ConstraintMapping();
        cm.setPathSpec("/*");
        cm.setConstraint(constraint);

        ConstraintSecurityHandler sh = new ConstraintSecurityHandler();
        sh.setAuthenticator(new BasicAuthenticator());
        sh.setConstraintMappings(Arrays.asList(new ConstraintMapping[] {cm}));

        HashLoginService loginService = new HashLoginService("MyRealm", "src/test/resources/myRealm.properties");
        sh.setLoginService(loginService);
        sh.setConstraintMappings(Arrays.asList(new ConstraintMapping[]{cm}));

        return sh;
    }
View Full Code Here

        ConstraintMapping cm = new ConstraintMapping();
        cm.setPathSpec("/*");
        cm.setConstraint(constraint);

        ConstraintSecurityHandler sh = new ConstraintSecurityHandler();
        sh.setAuthenticator(new BasicAuthenticator());
        sh.setConstraintMappings(Arrays.asList(new ConstraintMapping[] {cm}));

        HashLoginService loginService = new HashLoginService("MyRealm", "src/test/resources/myRealm.properties");
        sh.setLoginService(loginService);
        sh.setConstraintMappings(Arrays.asList(new ConstraintMapping[]{cm}));

        return sh;
    }
View Full Code Here

        ConstraintMapping cm = new ConstraintMapping();
        cm.setPathSpec("/*");
        cm.setConstraint(constraint);

        ConstraintSecurityHandler sh = new ConstraintSecurityHandler();
        sh.setAuthenticator(new BasicAuthenticator());
        sh.setConstraintMappings(Arrays.asList(new ConstraintMapping[] {cm}));

        HashLoginService loginService = new HashLoginService("MyRealm", "src/test/resources/myRealm.properties");
        sh.setLoginService(loginService);
        sh.setConstraintMappings(Arrays.asList(new ConstraintMapping[]{cm}));

        return sh;
    }
View Full Code Here

TOP

Related Classes of org.eclipse.jetty.security.ConstraintSecurityHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.