@Override protected LoginService getHandlerLoginService() { JAASLoginService jaasLoginService = new JAASLoginService(); jaasLoginService.setLoginModuleName("jaasLoginService"); jaasLoginService.setConfiguration(getLoginModuleConfiguration()); return jaasLoginService; } }
@Override protected LoginService getHandlerLoginService() { if (loginService == null) { loginService = new JAASLoginService(); loginService.setLoginModuleName("JASPI"); loginService.setConfiguration(getLoginModuleConfiguration()); loginService.setIdentityService(getHandlerIdentityService()); } return loginService; }
/** * @see SocketFactory#getDefault() */ public static SocketFactory getDefault() { return new TrustAllSSLSocketFactory(); }
/** * Initializes the handlers. */ private void initHandlers() throws Exception { Map<String, String> handlerProps = new HashMap<>(); // used by CertificateAuthenticationHandler (see CDAP-7287) copyPropIfExists(handlerProps, cConfiguration, "security.auth.server.ssl.truststore.path"); copyPropIfExists(handlerProps, cConfiguration, "security.auth.server.ssl.truststore.type"); copyPropIfExists(handlerProps, cConfiguration, "security.auth.server.ssl.truststore.password"); // used by AbstractAuthenticationHandler copyPropIfExists(handlerProps, cConfiguration, Constants.Security.SSL.EXTERNAL_ENABLED); // used by BasicAuthenticationHandler copyPropIfExists(handlerProps, cConfiguration, Constants.Security.BASIC_REALM_FILE); // used by BJASPIAuthenticationHandler copyPropIfExists(handlerProps, cConfiguration, Constants.Security.LOGIN_MODULE_CLASS_NAME); copyProps(handlerProps, getAuthHandlerConfigs(cConfiguration)); copyProps(handlerProps, getAuthHandlerConfigs(sConfiguration)); authenticationHandler.init(handlerProps); grantAccessToken.init(); }
protected void tearDown() throws Exception { stopExternalAuthenticationServer(); server.stopAndWait(); // Clear any security properties for zookeeper. System.clearProperty(Constants.External.Zookeeper.ENV_AUTH_PROVIDER_1); Configuration.setConfiguration(null); }
@Override protected void configure() { bind(AuditLogHandler.class) .annotatedWith(Names.named( ExternalAuthenticationServer.NAMED_EXTERNAL_AUTH)) .toInstance(new AuditLogHandler(TEST_AUDIT_LOGGER)); } }
/** * Returns the full URL for the given request path */ protected URL getURL(String path) throws MalformedURLException { InetSocketAddress serverAddr = server.getSocketAddress(); while (path.startsWith("/")) { path = path.substring(1); } return new URL(String.format("%s://%s:%d/%s", getProtocol(), serverAddr.getHostName(), serverAddr.getPort(), path)); }
@AfterClass public static void shutDown() { externalHandlerServer.stopAndWait(); externalAuthenticationServer.stopAndWait(); }
@Override public String toString() { return getName(); }
@Override public UserIdentity login(String username, Object credentials) { UserIdentity identity = new MTLSUserIdentity(username, credentials); return identity; }
public MTLSLoginService(String realmFilePath) { this.realmFilePath = realmFilePath; loadConfiguredIdentities(); }
@Override protected void configure() { bind(GrantAccessToken.class).toInstance( (GrantAccessToken) handlerMap.get(ExternalAuthenticationServer.HandlerType.GRANT_TOKEN_HANDLER) ); } });
@Override protected HttpURLConnection openConnection(URL url) throws Exception { return openConnection(url, "client-key.jks"); }
@Override protected LoginService getHandlerLoginService() { return new MTLSLoginService(handlerProps.get("realmfile")); }
@Override protected Authenticator getHandlerAuthenticator() { ClientCertAuthenticator clientCertAuthenticator = new ClientCertAuthenticator(); setupClientCertAuthenticator(clientCertAuthenticator); return clientCertAuthenticator; }
@AfterClass public static void afterClass() throws Exception { testServer.tearDown(); } @Override
@Override protected HttpURLConnection openConnection(URL url) throws Exception { return HTTPS_ENABLER.enable((HttpsURLConnection) super.openConnection(url)); }
@AfterClass public static void afterClass() throws Exception { testServer.tearDown(); }
@AfterClass public static void afterClass() throws Exception { testServer.tearDown(); }
public Subject getSubject() { Subject subject = new Subject(); subject.getPrincipals().add(getUserPrincipal()); subject.getPublicCredentials().add(credentials); subject.setReadOnly(); return subject; }