本文整理汇总了Java中org.eclipse.jetty.security.authentication.BasicAuthenticator类的典型用法代码示例。如果您正苦于以下问题:Java BasicAuthenticator类的具体用法?Java BasicAuthenticator怎么用?Java BasicAuthenticator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BasicAuthenticator类属于org.eclipse.jetty.security.authentication包,在下文中一共展示了BasicAuthenticator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: basicAuth
import org.eclipse.jetty.security.authentication.BasicAuthenticator; //导入依赖的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.authentication.BasicAuthenticator; //导入依赖的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.authentication.BasicAuthenticator; //导入依赖的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: basicAuth
import org.eclipse.jetty.security.authentication.BasicAuthenticator; //导入依赖的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;
}
示例5: basicAuth
import org.eclipse.jetty.security.authentication.BasicAuthenticator; //导入依赖的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;
}
示例6: basicAuth
import org.eclipse.jetty.security.authentication.BasicAuthenticator; //导入依赖的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;
}
示例7: getSecurityHandler
import org.eclipse.jetty.security.authentication.BasicAuthenticator; //导入依赖的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;
}
示例8: createSecurityHandler
import org.eclipse.jetty.security.authentication.BasicAuthenticator; //导入依赖的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;
}
示例9: basicAuth
import org.eclipse.jetty.security.authentication.BasicAuthenticator; //导入依赖的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;
}
示例10: BasicAuth
import org.eclipse.jetty.security.authentication.BasicAuthenticator; //导入依赖的package包/类
public BasicAuth() {
HashLoginService loginService = new HashLoginService();
loginService.putUser(Main.configuration.username, Credential.getCredential(Main.configuration.password), new String[]{"user"});
loginService.setName(Main.configuration.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("/*");
// Configure this ConstraintSecurityHandler:
setAuthenticator(new BasicAuthenticator());
setRealmName("myrealm");
addConstraintMapping(cm);
setLoginService(loginService);
}
示例11: basicAuth
import org.eclipse.jetty.security.authentication.BasicAuthenticator; //导入依赖的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;
}
示例12: newSecurityHandler
import org.eclipse.jetty.security.authentication.BasicAuthenticator; //导入依赖的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;
}
示例13: basicAuth
import org.eclipse.jetty.security.authentication.BasicAuthenticator; //导入依赖的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;
}
示例14: basicAuth
import org.eclipse.jetty.security.authentication.BasicAuthenticator; //导入依赖的package包/类
private static SecurityHandler basicAuth(String username, String password, String realm) {
HashLoginService loginService = new HashLoginService();
loginService.putUser(username, Credential.getCredential(password), new String[]{"user"});
loginService.setName(realm);
Constraint constraint = new Constraint();
constraint.setName(Constraint.__DIGEST_AUTH);
constraint.setRoles(new String[]{"user"});
constraint.setAuthenticate(true);
ConstraintMapping constraintMapping = new ConstraintMapping();
constraintMapping.setConstraint(constraint);
constraintMapping.setPathSpec("/*");
ConstraintSecurityHandler csh = new ConstraintSecurityHandler();
csh.setAuthenticator(new BasicAuthenticator());
csh.setRealmName("realm");
csh.addConstraintMapping(constraintMapping);
csh.setLoginService(loginService);
return csh;
}
示例15: createSecurityHandler
import org.eclipse.jetty.security.authentication.BasicAuthenticator; //导入依赖的package包/类
static ConstraintSecurityHandler createSecurityHandler(String realm, List<String> roles) {
final ConstraintSecurityHandler securityHandler = new ConstraintSecurityHandler();
Constraint constraint = new Constraint();
constraint.setAuthenticate(true);
constraint.setRoles(roles.toArray(new String[0]));
ConstraintMapping constraintMapping = new ConstraintMapping();
constraintMapping.setConstraint(constraint);
constraintMapping.setMethod("*");
constraintMapping.setPathSpec("/*");
securityHandler.addConstraintMapping(constraintMapping);
securityHandler.setAuthenticator(new BasicAuthenticator());
securityHandler.setLoginService(new JAASLoginService(realm));
securityHandler.setIdentityService(new DefaultIdentityService());
securityHandler.setRealmName(realm);
return securityHandler;
}