org.eclipse.jetty.util.security.Password Java Examples
The following examples show how to use
org.eclipse.jetty.util.security.Password.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestInvokeHttpCommon.java From localization_nifi with Apache License 2.0 | 5 votes |
private DigestAuthHandler() { digestAuthenticator = new DigestAuthenticator(); ConstraintSecurityHandler securityHandler = new ConstraintSecurityHandler(); HashLoginService hashLoginService = new HashLoginService("realm"); hashLoginService.putUser("basic_user", new Password("basic_password"), new String[]{"realm"}); securityHandler.setLoginService(hashLoginService); securityHandler.setIdentityService(new DefaultIdentityService()); digestAuthenticator.setConfiguration(securityHandler); }
Example #2
Source File: JenkinsRule.java From jenkins-test-harness with MIT License | 5 votes |
/** * Creates a {@link HashLoginService} with three users: alice, bob and charlie * * The password is same as the username * @return a new login service * @since 2.50 */ public static LoginService _configureUserRealm() { HashLoginService realm = new HashLoginService(); realm.setName("default"); // this is the magic realm name to make it effective on everywhere UserStore userStore = new UserStore(); realm.setUserStore( userStore ); userStore.addUser("alice", new Password("alice"), new String[]{"user","female"}); userStore.addUser("bob", new Password("bob"), new String[]{"user","male"}); userStore.addUser("charlie", new Password("charlie"), new String[]{"user","male"}); return realm; }
Example #3
Source File: HudsonTestCase.java From jenkins-test-harness with MIT License | 5 votes |
/** * Configures a security realm for a test. */ protected LoginService configureUserRealm() { HashLoginService realm = new HashLoginService(); realm.setName("default"); // this is the magic realm name to make it effective on everywhere UserStore userStore = new UserStore(); realm.setUserStore( userStore ); userStore.addUser("alice", new Password("alice"), new String[]{"user","female"}); userStore.addUser("bob", new Password("bob"), new String[]{"user","male"}); userStore.addUser("charlie", new Password("charlie"), new String[]{"user","male"}); return realm; }
Example #4
Source File: SslContextFactory.java From IoTgo_Android_App with MIT License | 5 votes |
/** * @param password * The password for the key store */ public void setKeyStorePassword(String password) { checkNotStarted(); _keyStorePassword = Password.getPassword(PASSWORD_PROPERTY,password,null); }
Example #5
Source File: SslContextFactory.java From IoTgo_Android_App with MIT License | 5 votes |
/** * @param password * The password (if any) for the specific key within the key store */ public void setKeyManagerPassword(String password) { checkNotStarted(); _keyManagerPassword = Password.getPassword(KEYPASSWORD_PROPERTY,password,null); }
Example #6
Source File: SslContextFactory.java From IoTgo_Android_App with MIT License | 5 votes |
/** * @param password * The password for the trust store */ public void setTrustStorePassword(String password) { checkNotStarted(); _trustStorePassword = Password.getPassword(PASSWORD_PROPERTY,password,null); }
Example #7
Source File: SslContextFactory.java From IoTgo_Android_App with MIT License | 5 votes |
/** * @param password * The password for the key store */ public void setKeyStorePassword(String password) { checkNotStarted(); _keyStorePassword = Password.getPassword(PASSWORD_PROPERTY,password,null); }
Example #8
Source File: SslContextFactory.java From IoTgo_Android_App with MIT License | 5 votes |
/** * @param password * The password (if any) for the specific key within the key store */ public void setKeyManagerPassword(String password) { checkNotStarted(); _keyManagerPassword = Password.getPassword(KEYPASSWORD_PROPERTY,password,null); }
Example #9
Source File: SslContextFactory.java From IoTgo_Android_App with MIT License | 5 votes |
/** * @param password * The password for the trust store */ public void setTrustStorePassword(String password) { checkNotStarted(); _trustStorePassword = Password.getPassword(PASSWORD_PROPERTY,password,null); }
Example #10
Source File: HttpReceiverServerPush.java From datacollector with Apache License 2.0 | 5 votes |
public static SecurityHandler getBasicAuthHandler(HttpSourceConfigs httpCourceConf) { List<CredentialValueUserPassBean> basicAuthUsers = httpCourceConf.getBasicAuthUsers(); HashLoginService loginService = new HashLoginService(); UserStore userStore = new UserStore(); boolean empty = true; for (CredentialValueUserPassBean userPassBean : basicAuthUsers) { String username = userPassBean.getUsername(); String password = userPassBean.get(); if(StringUtils.isNotEmpty(username) && StringUtils.isNotEmpty(password)) { userStore.addUser(username, new Password(password), new String[]{"sdc"}); empty = false; } } if(empty) { return null; } loginService.setUserStore(userStore); Constraint constraint = new Constraint(Constraint.__BASIC_AUTH,"sdc"); constraint.setAuthenticate(true); ConstraintMapping mapping = new ConstraintMapping(); mapping.setConstraint(constraint); mapping.setPathSpec("/*"); ConstraintSecurityHandler handler = new ConstraintSecurityHandler(); handler.setAuthenticator(new BasicAuthenticator()); handler.addConstraintMapping(mapping); handler.setLoginService(loginService); return handler; }
Example #11
Source File: CustomInitTest.java From rest-utils with Apache License 2.0 | 5 votes |
@Override protected UserPrincipal loadUserInfo(final String username) { if (username.equals("jun")) { return new UserPrincipal(username, new Password("kafka-")); } if (username.equals("neha")) { return new UserPrincipal(username, new Password("akfak")); } return null; }
Example #12
Source File: StandaloneAdminWeb.java From chipster with MIT License | 5 votes |
public static void main(String args[]) throws Exception { org.eclipse.jetty.server.Server adminServer = new org.eclipse.jetty.server.Server(); ServerConnector connector = new ServerConnector(adminServer); connector.setPort(8083); adminServer.setConnectors(new Connector[]{ connector }); Constraint constraint = new Constraint(); constraint.setName(Constraint.__BASIC_AUTH); constraint.setRoles(new String[] {"admin_role"}); constraint.setAuthenticate(true); ConstraintMapping cm = new ConstraintMapping(); cm.setConstraint(constraint); cm.setPathSpec("/*"); HashLoginService loginService = new HashLoginService("Please enter Chipster Admin username and password"); loginService.update("chipster", new Password("chipster"), new String[] {"admin_role"}); ConstraintSecurityHandler sh = new ConstraintSecurityHandler(); sh.setLoginService(loginService); sh.addConstraintMapping(cm); WebAppContext context = new WebAppContext(); File war = new File("../chipster/dist/admin-web.war"); //File war = new File("webapps/admin-web.war"); context.setWar(war.getAbsolutePath()); System.out.println(war.getAbsolutePath()); context.setContextPath("/"); context.setHandler(sh); HandlerCollection handlers = new HandlerCollection(); handlers.setHandlers(new Handler[] {context, new DefaultHandler()}); adminServer.setHandler(handlers); adminServer.start(); }
Example #13
Source File: HttpProtocolServer.java From gitflow-incremental-builder with MIT License | 4 votes |
private UserStore buildUserStore() { UserStore userStore = new UserStore(); userStore.addUser(username, new Password(password), ROLES); return userStore; }
Example #14
Source File: JettyHttpServer.java From everrest with Eclipse Public License 2.0 | 4 votes |
public void start() throws Exception { RequestLogHandler handler = new RequestLogHandler(); if (context == null) { context = new ServletContextHandler(handler, "/", ServletContextHandler.SESSIONS); } context.setEventListeners(new EventListener[]{new EverrestInitializedListener()}); ServletHolder servletHolder = new ServletHolder(new EverrestServlet()); context.addServlet(servletHolder, UNSECURE_PATH_SPEC); context.addServlet(servletHolder, SECURE_PATH_SPEC); //set up security Constraint constraint = new Constraint(); constraint.setName(Constraint.__BASIC_AUTH); constraint.setRoles(new String[]{"cloud-admin", "users", "user", "temp_user"}); constraint.setAuthenticate(true); ConstraintMapping constraintMapping = new ConstraintMapping(); constraintMapping.setConstraint(constraint); constraintMapping.setPathSpec(SECURE_PATH_SPEC); ConstraintSecurityHandler securityHandler = new ConstraintSecurityHandler(); securityHandler.addConstraintMapping(constraintMapping); HashLoginService loginService = new HashLoginService(); UserStore userStore = new UserStore(); userStore.addUser(ADMIN_USER_NAME, new Password(ADMIN_USER_PASSWORD), new String[]{"cloud-admin", "users", "user", "temp_user", "developer", "admin", "workspace/developer", "workspace/admin", "account/owner", "account/member", "system/admin", "system/manager" }); userStore.addUser(MANAGER_USER_NAME, new Password(MANAGER_USER_PASSWORD), new String[]{"cloud-admin", "user", "temp_user", "users"}); loginService.setUserStore(userStore); securityHandler.setLoginService(loginService); securityHandler.setAuthenticator(new BasicAuthenticator()); context.setSecurityHandler(securityHandler); server.setHandler(handler); server.start(); ResourceBinder binder = (ResourceBinder)context.getServletContext().getAttribute(ResourceBinder.class.getName()); DependencySupplier dependencies = (DependencySupplier)context.getServletContext().getAttribute(DependencySupplier.class.getName()); GroovyResourcePublisher groovyPublisher = new GroovyResourcePublisher(binder, dependencies); context.getServletContext().setAttribute(GroovyResourcePublisher.class.getName(), groovyPublisher); }
Example #15
Source File: Manager.java From chipster with MIT License | 4 votes |
private void startAdmin(Configuration configuration) throws IOException, Exception { org.eclipse.jetty.server.Server adminServer = new org.eclipse.jetty.server.Server(); ServerConnector connector = new ServerConnector(adminServer); connector.setPort(configuration.getInt("manager", "admin-port")); adminServer.setConnectors(new Connector[]{ connector }); Constraint constraint = new Constraint(); constraint.setName(Constraint.__BASIC_AUTH); constraint.setRoles(new String[] {ADMIN_ROLE}); constraint.setAuthenticate(true); ConstraintMapping cm = new ConstraintMapping(); cm.setConstraint(constraint); cm.setPathSpec("/*"); HashLoginService loginService = new HashLoginService("Please enter Chipster Admin username and password"); loginService.update(configuration.getString("manager", "admin-username"), new Password(configuration.getString("manager", "admin-password")), new String[] {ADMIN_ROLE}); ConstraintSecurityHandler sh = new ConstraintSecurityHandler(); sh.setLoginService(loginService); sh.addConstraintMapping(cm); WebAppContext context = new WebAppContext(); context.setWar(new File(DirectoryLayout.getInstance().getWebappsDir(), "admin-web.war").getAbsolutePath()); context.setContextPath("/"); // context.setDescriptor(new ClassPathResource("WebContent/WEB-INF/web.xml").getURI().toString()); // context.setResourceBase(new ClassPathResource("WebContent").getURI().toString()); // context.setContextPath("/"); // context.setParentLoaderPriority(true); context.setHandler(sh); HandlerCollection handlers = new HandlerCollection(); handlers.setHandlers(new Handler[] {context, new DefaultHandler()}); adminServer.setHandler(handlers); adminServer.start(); }