org.eclipse.jetty.jaas.JAASLoginService Java Examples

The following examples show how to use org.eclipse.jetty.jaas.JAASLoginService. 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: HttpServerExtension.java    From kareldb with Apache License 2.0 5 votes vote down vote up
@Override
protected ConstraintSecurityHandler configureBasicAuthentication(Server server,
                                                                 AvaticaServerConfiguration config) {
    LOG.info("Configuring basic auth");
    final String[] allowedRoles = config.getAllowedRoles();
    final String realm = config.getHashLoginServiceRealm();

    JAASLoginService loginService = new JAASLoginService(realm);
    server.addBean(loginService);

    return configureCommonAuthentication(Constraint.__BASIC_AUTH,
        allowedRoles, new BasicAuthenticator(), null, loginService);
}
 
Example #2
Source File: HttpServerExtension.java    From kareldb with Apache License 2.0 5 votes vote down vote up
@Override
protected ConstraintSecurityHandler configureDigestAuthentication(Server server,
                                                                  AvaticaServerConfiguration config) {
    LOG.info("Configuring digest auth");
    final String[] allowedRoles = config.getAllowedRoles();
    final String realm = config.getHashLoginServiceRealm();

    JAASLoginService loginService = new JAASLoginService(realm);
    server.addBean(loginService);

    return configureCommonAuthentication(Constraint.__DIGEST_AUTH,
        allowedRoles, new DigestAuthenticator(), null, loginService);
}
 
Example #3
Source File: Application.java    From rest-utils with Apache License 2.0 5 votes vote down vote up
protected LoginService createLoginService() {
  final String realm = config.getString(RestConfig.AUTHENTICATION_REALM_CONFIG);
  final String method = config.getString(RestConfig.AUTHENTICATION_METHOD_CONFIG);
  if (enableBasicAuth(method)) {
    return new JAASLoginService(realm);
  } else if (enableBearerAuth(method)) {
    throw new UnsupportedOperationException(
            "Must implement Application.createLoginService() when using '"
                    + RestConfig.AUTHENTICATION_METHOD_CONFIG + "="
                    + RestConfig.AUTHENTICATION_METHOD_BEARER + "'."
    );
  }
  return null;
}
 
Example #4
Source File: ApplicationTest.java    From rest-utils with Apache License 2.0 5 votes vote down vote up
@Test(expected = UnsupportedOperationException.class)
public void testBearerNoAuthenticator() {
  final Map<String, Object> config = ImmutableMap.of(
      RestConfig.AUTHENTICATION_METHOD_CONFIG, RestConfig.AUTHENTICATION_METHOD_BEARER);

  Application app = new TestApp(config) {
    @Override
    protected LoginService createLoginService() {
      return new JAASLoginService("realm");
    }
  };
  app.createBearerSecurityHandler();
}