Package org.eclipse.jetty.security

Examples of org.eclipse.jetty.security.ConstraintMapping


        Constraint constraint = new Constraint();
        constraint.setName(Constraint.__BASIC_AUTH);
        constraint.setRoles(pRoles);
        constraint.setAuthenticate(true);

        ConstraintMapping cm = new ConstraintMapping();
        cm.setConstraint(constraint);
        cm.setPathSpec("/*");
        return new ConstraintMapping[] { cm };
    }
View Full Code Here


    ConstraintSecurityHandler securityHandler = new ConstraintSecurityHandler();
    Constraint constraint = new Constraint();
    constraint.setName("auth");
    constraint.setAuthenticate( true );
    constraint.setRoles(new String[] { "user", "admin" });
    ConstraintMapping mapping = new ConstraintMapping();
    mapping.setPathSpec( "/*" );
    mapping.setConstraint( constraint );
    securityHandler.setConstraintMappings(Collections.singletonList(mapping));
    securityHandler.setAuthenticator(new BasicAuthenticator());
    securityHandler.setLoginService(loginService);

    ResourceHandler resourceHandler = new ResourceHandler();
View Full Code Here

    @Test
    public void itRequiresAuthenticationForAllRequests() throws Exception {
      config.configureContext(context);
     
      final ConstraintSecurityHandler securityHandler = (ConstraintSecurityHandler) context.getSecurityHandler();
      final ConstraintMapping authenticateAll = securityHandler.getConstraintMappings()[0];
      assertThat(authenticateAll.getPathSpec(), is("/*"));
      assertThat(authenticateAll.getConstraint().getAuthenticate(), is(true));
      assertThat(authenticateAll.getConstraint().getRoles(), is(new String[] { "user" }));
    }
View Full Code Here

    @Test
    public void itDoesNotRequireAuthenticationForAHealthCheckRequest() throws Exception {
      config.configureContext(context);
     
      final ConstraintSecurityHandler securityHandler = (ConstraintSecurityHandler) context.getSecurityHandler();
      final ConstraintMapping authenticateAll = securityHandler.getConstraintMappings()[1];
      assertThat(authenticateAll.getPathSpec(), is("/health/"));
      assertThat(authenticateAll.getConstraint().getAuthenticate(), is(false));
    }
View Full Code Here

    @Test
    public void itDoesNotRequireAuthenticationForAStatsRequest() throws Exception {
      config.configureContext(context);
     
      final ConstraintSecurityHandler securityHandler = (ConstraintSecurityHandler) context.getSecurityHandler();
      final ConstraintMapping authenticateAll = securityHandler.getConstraintMappings()[2];
      assertThat(authenticateAll.getPathSpec(), is("/stats/*"));
      assertThat(authenticateAll.getConstraint().getAuthenticate(), is(false));
    }
View Full Code Here

   
    final Constraint requireAuthentication = new Constraint();
    requireAuthentication.setAuthenticate(true);
    requireAuthentication.setRoles(new String[] { "user" });
   
    final ConstraintMapping authenticateAll = new ConstraintMapping();
    authenticateAll.setPathSpec("/*");
    authenticateAll.setConstraint(requireAuthentication);
   
    final Constraint passThrough = new Constraint();
    passThrough.setAuthenticate(false);
   
    final ConstraintMapping healthCheckExemption = new ConstraintMapping();
    healthCheckExemption.setPathSpec("/health/");
    healthCheckExemption.setConstraint(passThrough);
   
    final ConstraintMapping statsExemption = new ConstraintMapping();
    statsExemption.setPathSpec("/stats/*");
    statsExemption.setConstraint(passThrough);
   
    securityHandler.setConstraintMappings(new ConstraintMapping[] { authenticateAll, healthCheckExemption, statsExemption });
    context.setSecurityHandler(securityHandler);
  }
View Full Code Here

      protected void loadUsers() throws IOException {
        putUser(username, new Password(password), new String[] { role });
      }
    };

    ConstraintMapping cm = new ConstraintMapping();
    cm.setConstraint(new Constraint());
    cm.getConstraint().setAuthenticate(true);
    cm.getConstraint().setDataConstraint(Constraint.DC_NONE);
    cm.getConstraint().setRoles(new String[] { role });
    cm.setPathSpec("/*");

    ConstraintSecurityHandler sec = new ConstraintSecurityHandler();
    sec.setStrict(false);
    sec.setRealmName(realm);
    sec.setAuthenticator(authType);
View Full Code Here

    Constraint constraint = new Constraint();
    constraint.setName(Constraint.__BASIC_AUTH);
    constraint.setRoles(new String[]{"users"});
    constraint.setAuthenticate(true);

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

    ConstraintSecurityHandler securityHandler = new ConstraintSecurityHandler();
    securityHandler.setRealmName("Test Server");
    securityHandler.setAuthMethod("BASIC");
    securityHandler.setStrict(true);
View Full Code Here

        Constraint constraint = new Constraint();
        constraint.setName(Constraint.__BASIC_AUTH);
        constraint.setRoles(new String[]{"user"});
        constraint.setAuthenticate(true);

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

        ConstraintSecurityHandler csh = new ConstraintSecurityHandler();
        csh.setAuthenticator(new BasicAuthenticator());
        csh.setRealmName(realm);
        csh.addConstraintMapping(cm);
View Full Code Here

        org.eclipse.jetty.util.security.Constraint constraint = new org.eclipse.jetty.util.security.Constraint();
        constraint.setName(__BASIC_AUTH);
        constraint.setRoles(new String[]{"user"});
        constraint.setAuthenticate(true);

        ConstraintMapping cm = new ConstraintMapping();
        cm.setConstraint(constraint);
        cm.setPathSpec(path);

        securityHandler.addConstraintMapping(cm);
    }
View Full Code Here

TOP

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

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.