本文整理匯總了Java中org.eclipse.jetty.security.ConstraintSecurityHandler.setAuthenticator方法的典型用法代碼示例。如果您正苦於以下問題:Java ConstraintSecurityHandler.setAuthenticator方法的具體用法?Java ConstraintSecurityHandler.setAuthenticator怎麽用?Java ConstraintSecurityHandler.setAuthenticator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jetty.security.ConstraintSecurityHandler
的用法示例。
在下文中一共展示了ConstraintSecurityHandler.setAuthenticator方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: basicAuth
import org.eclipse.jetty.security.ConstraintSecurityHandler; //導入方法依賴的package包/類
private static final SecurityHandler basicAuth(String realm)
{
HashLoginService l = new HashLoginService();
l.setConfig(new File(PlatformData.installationDirectory, "webusers.properties").getAbsolutePath());
l.setName(realm);
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("/ui/*");
ConstraintSecurityHandler csh = new ConstraintSecurityHandler();
csh.setAuthenticator(new BasicAuthenticator());
csh.setRealmName("myrealm");
csh.addConstraintMapping(cm);
csh.setLoginService(l);
return csh;
}
示例2: InMemoryIdentityManager
import org.eclipse.jetty.security.ConstraintSecurityHandler; //導入方法依賴的package包/類
public InMemoryIdentityManager() {
loginService = new HashLoginService();
loginService.setName(realm);
securityHandler = new ConstraintSecurityHandler();
securityHandler.setAuthenticator(new BasicAuthenticator());
securityHandler.setRealmName(realm);
securityHandler.setLoginService(loginService);
Constraint constraint = new Constraint();
constraint.setName(Constraint.__BASIC_AUTH);
// constraint.setRoles(new String[] { "getRole", "postRole", "allRole" });
constraint.setRoles(new String[]{Constraint.ANY_AUTH, "getRole", "postRole", "allRole"});
constraint.setAuthenticate(true);
ConstraintMapping cm = new ConstraintMapping();
cm.setConstraint(constraint);
cm.setPathSpec("/*");
securityHandler.addConstraintMapping(cm);
}
示例3: basicAuth
import org.eclipse.jetty.security.ConstraintSecurityHandler; //導入方法依賴的package包/類
private static final SecurityHandler basicAuth(String realm) {
final OfMeetLoginService loginService = new OfMeetLoginService();
loginService.setName(realm);
final Constraint constraint = new Constraint();
constraint.setName( Constraint.__BASIC_AUTH );
constraint.setRoles( new String[] { "ofmeet" } );
constraint.setAuthenticate( true );
final ConstraintMapping constraintMapping = new ConstraintMapping();
constraintMapping.setConstraint( constraint );
constraintMapping.setPathSpec( "/*" );
final ConstraintSecurityHandler securityHandler = new ConstraintSecurityHandler();
securityHandler.setAuthenticator( new BasicAuthenticator() );
securityHandler.setRealmName( realm );
securityHandler.addConstraintMapping( constraintMapping );
securityHandler.setLoginService( loginService );
return securityHandler;
}
示例4: configureCommonAuthentication
import org.eclipse.jetty.security.ConstraintSecurityHandler; //導入方法依賴的package包/類
protected ConstraintSecurityHandler configureCommonAuthentication(Server server,
ServerConnector connector, AvaticaServerConfiguration config, String constraintName,
String[] allowedRoles, Authenticator authenticator, String realm,
LoginService loginService) {
Constraint constraint = new Constraint();
constraint.setName(constraintName);
constraint.setRoles(allowedRoles);
// This is telling Jetty to not allow unauthenticated requests through (very important!)
constraint.setAuthenticate(true);
ConstraintMapping cm = new ConstraintMapping();
cm.setConstraint(constraint);
cm.setPathSpec("/*");
ConstraintSecurityHandler sh = new ConstraintSecurityHandler();
sh.setAuthenticator(authenticator);
sh.setLoginService(loginService);
sh.setConstraintMappings(new ConstraintMapping[]{cm});
sh.setRealmName(realm);
return sh;
}
示例5: basicAuth
import org.eclipse.jetty.security.ConstraintSecurityHandler; //導入方法依賴的package包/類
private static final SecurityHandler basicAuth(String username, String password, String realm) {
HashLoginService l = new HashLoginService();
l.putUser(username, Credential.getCredential(password), new String[] {"user"});
l.setName(realm);
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 ProxyAuthenticator());
csh.setRealmName("myrealm");
csh.addConstraintMapping(cm);
csh.setLoginService(l);
return csh;
}
示例6: basicAuth
import org.eclipse.jetty.security.ConstraintSecurityHandler; //導入方法依賴的package包/類
private static final SecurityHandler basicAuth(String username, String password, String realm) {
HashLoginService l = new HashLoginService();
l.putUser(username, Credential.getCredential(password), new String[] {"user"});
l.setName(realm);
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("myrealm");
csh.addConstraintMapping(cm);
csh.setLoginService(l);
return csh;
}
示例7: basicAuth
import org.eclipse.jetty.security.ConstraintSecurityHandler; //導入方法依賴的package包/類
private SecurityHandler basicAuth(String username, String password, String realm) {
HashLoginService l = new HashLoginService();
l.putUser(username, Credential.getCredential(password), new String[]{"user"});
l.setName(realm);
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("myrealm");
csh.addConstraintMapping(cm);
csh.setLoginService(l);
return csh;
}
示例8: basicAuth
import org.eclipse.jetty.security.ConstraintSecurityHandler; //導入方法依賴的package包/類
private SecurityHandler basicAuth(String username, String password, String realm) {
HashLoginService l = new HashLoginService();
l.putUser(username, Credential.getCredential(password), new String[]{"user"});
l.setName(realm);
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("myrealm");
csh.addConstraintMapping(cm);
csh.setLoginService(l);
return csh;
}
示例9: getSecurityHandler
import org.eclipse.jetty.security.ConstraintSecurityHandler; //導入方法依賴的package包/類
private SecurityHandler getSecurityHandler() throws IOException {
Constraint constraint = new Constraint(Constraint.__BASIC_AUTH, "user");
constraint.setAuthenticate(true);
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;
}
示例10: createSecurityHandler
import org.eclipse.jetty.security.ConstraintSecurityHandler; //導入方法依賴的package包/類
@Produces
@Named("securityHandler")
public static ConstraintSecurityHandler createSecurityHandler() {
Constraint constraint = new Constraint("BASIC", "customer");
constraint.setAuthenticate(true);
ConstraintMapping mapping = new ConstraintMapping();
mapping.setConstraint(constraint);
mapping.setPathSpec("/*");
ConstraintSecurityHandler handler = new ConstraintSecurityHandler();
handler.addConstraintMapping(mapping);
handler.setAuthenticator(new BasicAuthenticator());
handler.setLoginService(new HashLoginService("RiderAutoParts", "src/main/resources/users.properties"));
return handler;
}
示例11: basicAuth
import org.eclipse.jetty.security.ConstraintSecurityHandler; //導入方法依賴的package包/類
private static final SecurityHandler basicAuth(String username, String password, String realm) {
HashLoginService l = new HashLoginService();
l.putUser(username, Credential.getCredential(password), new String[] {"user"});
l.setName(realm);
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("myrealm");
csh.addConstraintMapping(cm);
csh.setLoginService(l);
return csh;
}
示例12: createServletContextHandlerBasic
import org.eclipse.jetty.security.ConstraintSecurityHandler; //導入方法依賴的package包/類
private ServletContextHandler createServletContextHandlerBasic(){
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS
| ServletContextHandler.SECURITY);
context.addServlet(new ServletHolder(injector().getInstance(LogoutServlet.class)), "/logout");
ConstraintSecurityHandler securityHandler = new ConstraintSecurityHandler();
UsersManager usersManager = injector().getInstance(UsersManager.class);
usersManager.initUsers();
securityHandler.setLoginService(usersManager.loginService());
FormAuthenticator authenticator = new FormAuthenticator();//"/login", "/login", false);
securityHandler.setAuthenticator(authenticator);
context.setSecurityHandler(securityHandler);
return context;
}
示例13: basicAuth
import org.eclipse.jetty.security.ConstraintSecurityHandler; //導入方法依賴的package包/類
private static final SecurityHandler basicAuth(String username, String password, String realm) {
HashLoginService l = new HashLoginService();
l.putUser(username, Credential.getCredential(password), new String[] {"user"});
l.setName(realm);
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);
csh.setLoginService(l);
return csh;
}
示例14: newSecurityHandler
import org.eclipse.jetty.security.ConstraintSecurityHandler; //導入方法依賴的package包/類
private ConstraintSecurityHandler newSecurityHandler(ResourceHandler handler) {
HashLoginService login = new HashLoginService();
login.putUser(USERNAME, Credential.getCredential(PASSWORD), new String[] { "user" });
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.addConstraintMapping(cm);
csh.setLoginService(login);
csh.setHandler(handler);
return csh;
}
示例15: basicAuth
import org.eclipse.jetty.security.ConstraintSecurityHandler; //導入方法依賴的package包/類
protected SecurityHandler basicAuth(String username, String password, String realm) {
HashLoginService l = new HashLoginService();
l.putUser(username, Credential.getCredential(password), new String[]{"user"});
l.setName(realm);
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("/auth/*");
ConstraintSecurityHandler csh = new ConstraintSecurityHandler();
csh.setAuthenticator(new BasicAuthenticator());
csh.setRealmName("myrealm");
csh.addConstraintMapping(cm);
csh.setLoginService(l);
return csh;
}