use of org.eclipse.jetty.security.LoginService in project jetty.project by eclipse.
the class ServerSupport method configureLoginServices.
/**
* Set up any security LoginServices provided.
*
* @param server the server
* @param loginServices the login services
*/
public static void configureLoginServices(Server server, LoginService[] loginServices) {
if (server == null)
throw new IllegalArgumentException("Server is null");
if (loginServices != null) {
for (LoginService loginService : loginServices) {
PluginLog.getLog().debug(loginService.getClass().getName() + ": " + loginService.toString());
server.addBean(loginService);
}
}
}
use of org.eclipse.jetty.security.LoginService in project blade by biezhi.
the class DeferredAuthentication method authenticate.
/* ------------------------------------------------------------ */
/**
* @see Deferred#authenticate(ServletRequest, ServletResponse)
*/
@Override
public Authentication authenticate(ServletRequest request, ServletResponse response) {
try {
LoginService login_service = _authenticator.getLoginService();
IdentityService identity_service = login_service.getIdentityService();
Authentication authentication = _authenticator.validateRequest(request, response, true);
if (authentication instanceof User && identity_service != null)
_previousAssociation = identity_service.associate(((User) authentication).getUserIdentity());
return authentication;
} catch (ServerAuthException e) {
LOG.debug(e);
}
return this;
}
use of org.eclipse.jetty.security.LoginService in project blade by biezhi.
the class SessionAuthentication method readObject.
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
stream.defaultReadObject();
SecurityHandler security = SecurityHandler.getCurrentSecurityHandler();
if (security == null)
throw new IllegalStateException("!SecurityHandler");
LoginService login_service = security.getLoginService();
if (login_service == null)
throw new IllegalStateException("!LoginService");
_userIdentity = login_service.login(_name, _credentials, null);
LOG.debug("Deserialized and relogged in {}", this);
}
use of org.eclipse.jetty.security.LoginService in project rest-assured by rest-assured.
the class WithJetty method startJetty.
@BeforeClass
public static void startJetty() throws Exception {
server = new Server();
HttpConfiguration httpConfig = new HttpConfiguration();
httpConfig.setSecureScheme("https");
httpConfig.setSecurePort(8443);
httpConfig.setOutputBufferSize(32768);
ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(httpConfig));
http.setPort(8080);
http.setIdleTimeout(30000);
HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig);
httpsConfig.addCustomizer(new SecureRequestCustomizer());
String file = WithJetty.class.getClassLoader().getResource("jetty_localhost_server.jks").getFile();
SslContextFactory sslContextFactory = new SslContextFactory(file);
sslContextFactory.setKeyStorePassword("test1234");
ServerConnector https = new ServerConnector(server, new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()), new HttpConnectionFactory(httpsConfig));
https.setPort(8443);
https.setIdleTimeout(50000);
String canonicalPath = new File(".").getCanonicalPath();
String scalatraPath = "/examples/scalatra-webapp";
// Security config
Constraint constraint = new Constraint();
constraint.setName(Constraint.__BASIC_AUTH);
constraint.setRoles(new String[] { "user", "admin", "moderator" });
constraint.setAuthenticate(true);
ConstraintMapping mapping = new ConstraintMapping();
mapping.setConstraint(constraint);
mapping.setPathSpec("/secured/*");
final String realmPath = scalatraPath + "/etc/realm.properties";
LoginService loginService = new HashLoginService("MyRealm", isExecutedFromMaven(canonicalPath) ? gotoProjectRoot().getCanonicalPath() + realmPath : canonicalPath + realmPath);
server.addBean(loginService);
ConstraintSecurityHandler security = new ConstraintSecurityHandler();
server.setHandler(security);
security.setConstraintMappings(Collections.singletonList(mapping));
security.setAuthenticator(new BasicAuthenticator());
security.setLoginService(loginService);
// End security config
WebAppContext wac = new WebAppContext();
wac.setContextPath("/");
String webAppPath = "/src/main/webapp";
final String scalatraWebAppPath = scalatraPath + webAppPath;
String warPath = isExecutedFromMaven(canonicalPath) ? gotoProjectRoot().getCanonicalPath() + scalatraWebAppPath : canonicalPath + scalatraWebAppPath;
wac.setWar(warPath);
wac.setServer(server);
security.setHandler(wac);
server.setHandler(security);
server.setConnectors(new Connector[] { http, https });
dontSendDateHeader(server);
server.start();
}
use of org.eclipse.jetty.security.LoginService in project cxf by apache.
the class BookServerSimpleSecurity method configureServer.
@Override
protected void configureServer(org.eclipse.jetty.server.Server server) throws Exception {
URL resource = getClass().getResource("/org/apache/cxf/systest/jaxrs/security/jetty-realm.properties");
LoginService realm = new HashLoginService("BookStoreRealm", resource.toString());
server.addBean(realm);
}
Aggregations