Package org.eclipse.jetty.security

Examples of org.eclipse.jetty.security.ConstraintSecurityHandler


    /**
     * Construct new security handler for basic authentication.
     */
    public SecurityHandler getObject() throws Exception {
       
        ConstraintSecurityHandler securityHandler = new ConstraintSecurityHandler();
        securityHandler.setAuthenticator(authenticator);
        securityHandler.setRealmName(realm);
       
        for (Entry<String, Constraint> constraint : constraints.entrySet()) {
            ConstraintMapping constraintMapping = new ConstraintMapping();
            constraintMapping.setConstraint(constraint.getValue());
            constraintMapping.setPathSpec(constraint.getKey());
           
            securityHandler.addConstraintMapping(constraintMapping);
        }
       
        for (User user : users) {
            loginService.putUser(user.getName(), Credential.getCredential(user.getPassword()), user.getRoles());
        }
       
        securityHandler.setLoginService(loginService);
       
        return securityHandler;
    }
View Full Code Here


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

                ConstraintSecurityHandler sh =
                        crossOriginOn ? new CrossOriginConstraintSecurityHandler() : new ConstraintSecurityHandler();
                sh.setAuthenticator(authenticator);
                sh.setConstraintMappings(Collections.singletonList(cm));

                LoginService loginService =
                        new SecurityServiceLoginService(securityService, login.getCredentialType(), loginCacheSeconds);
                sh.setLoginService(loginService);

                localRootContextHandler.setSecurityHandler(sh);
            }

            if (crossOriginOn) {
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

   
    JAASLoginService loginService = new JAASLoginService("OpenGamma");
    loginService.setLoginModuleName("og");
    server.addBean(loginService);

    ConstraintSecurityHandler securityHandler = new ConstraintSecurityHandler();
    securityHandler.addConstraintMapping(restrictedConstraintMapping);
    securityHandler.addConstraintMapping(publicConstraintMapping);
    securityHandler.setAuthenticator(new BasicAuthenticator());
    securityHandler.setLoginService(loginService);
    securityHandler.setIdentityService(new DefaultIdentityService());
    securityHandler.setStrict(false);
    securityHandler.setRealmName("OpenGamma");
    server.addBean(securityHandler);

    // Insert the security handler in the chain before the existing handler
    securityHandler.setHandler(server.getHandler());
    server.setHandler(securityHandler);
  }
View Full Code Here

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

      ConstraintSecurityHandler sh = new ConstraintSecurityHandler();
      sh.addConstraintMapping(mapping);
      sh.setAuthenticator(new BasicAuthenticator());
      sh.setLoginService(loginService);
      sh.setStrict(true);

      // set the handers: the server hands the request to the security handler,
      // which hands the request to the other handlers when authenticated
      sh.setHandler(handlers);
      server.setHandler(sh);
    } else {
      server.setHandler(handlers);
    }
  }
View Full Code Here

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

      ConstraintSecurityHandler sh = new ConstraintSecurityHandler();
      sh.addConstraintMapping(mapping);
      sh.setAuthenticator(new BasicAuthenticator());
      sh.setLoginService(loginService);
      sh.setStrict(true);

      // set the handers: the server hands the request to the security handler,
      // which hands the request to the other handlers when authenticated
      sh.setHandler(handlers);
      server.setHandler(sh);
    } else {
      server.setHandler(handlers);
    }
  }
View Full Code Here

     * Set up security handling. This will vary from container to container, however the important
     * this is that something, somewhere maps each HTTP request to a java.security.Principal. In
     * this app, the DummyAuthenticator is specific to Jetty and just looks for the presence of an
     * isAdmin query parameter.
     */
    ConstraintSecurityHandler sh = new ConstraintSecurityHandler();
    sh.setAuthenticator(new DummyAuthenticator());
    sh.setIdentityService(new DefaultIdentityService());
    context.setSecurityHandler(sh);

    Server server = new Server(port);
    server.setHandler(context);
    try {
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.