/** * If the specified URL does not support SPNEGO authentication, a fallback {@link Authenticator} will be used. * <p> * This implementation returns a {@link PseudoAuthenticator}. * * @return the fallback {@link Authenticator}. */ protected Authenticator getFallBackAuthenticator() { Authenticator auth = new PseudoAuthenticator(); if (connConfigurator != null) { auth.setConnectionConfigurator(connConfigurator); } return auth; }
@Test public void testGetUserName() throws Exception { PseudoAuthenticator authenticator = new PseudoAuthenticator(); Assert.assertEquals(System.getProperty("user.name"), authenticator.getUserName()); }
@Override public void authenticate(URL url, AuthenticatedURL.Token token) throws IOException, AuthenticationException { USED = true; super.authenticate(url, token); } }
/** * Performs simple authentication against the specified URL. * <p> * If a token is given it does a NOP and returns the given token. * <p> * If no token is given, it will perform an HTTP <code>OPTIONS</code> request injecting an additional * parameter {@link #USER_NAME} in the query string with the value returned by the {@link #getUserName()} * method. * <p> * If the response is successful it will update the authentication token. * * @param url the URl to authenticate against. * @param token the authentication token being used for the user. * * @throws IOException if an IO error occurred. * @throws AuthenticationException if an authentication error occurred. */ @Override public void authenticate(URL url, AuthenticatedURL.Token token) throws IOException, AuthenticationException { String strUrl = url.toString(); String paramSeparator = (strUrl.contains("?")) ? "&" : "?"; strUrl += paramSeparator + USER_NAME_EQ + getUserName(); url = new URL(strUrl); HttpURLConnection conn = token.openConnection(url, connConfigurator); conn.setRequestMethod("OPTIONS"); conn.connect(); AuthenticatedURL.extractToken(conn, token); }
String strUrl = url.toString(); String paramSeparator = (strUrl.contains("?")) ? "&" : "?"; strUrl += paramSeparator + USER_NAME_EQ + getUserName(); url = new URL(strUrl); HttpURLConnection conn = (HttpURLConnection) url.openConnection();
/** * If the specified URL does not support SPNEGO authentication, a fallback {@link Authenticator} will be used. * <p> * This implementation returns a {@link PseudoAuthenticator}. * * @return the fallback {@link Authenticator}. */ protected Authenticator getFallBackAuthenticator() { Authenticator auth = new PseudoAuthenticator(); if (connConfigurator != null) { auth.setConnectionConfigurator(connConfigurator); } return auth; }
@Test public void testGetUserName() throws Exception { PseudoAuthenticator authenticator = new PseudoAuthenticator(); Assert.assertEquals(System.getProperty("user.name"), authenticator.getUserName()); }
String strUrl = url.toString(); String paramSeparator = (strUrl.contains("?")) ? "&" : "?"; strUrl += paramSeparator + USER_NAME_EQ + getUserName(); url = new URL(strUrl); HttpURLConnection conn = (HttpURLConnection) url.openConnection();
/** * If the specified URL does not support SPNEGO authentication, a fallback {@link Authenticator} will be used. * <p> * This implementation returns a {@link PseudoAuthenticator}. * * @return the fallback {@link Authenticator}. */ protected Authenticator getFallBackAuthenticator() { Authenticator auth = new PseudoAuthenticator(); if (connConfigurator != null) { auth.setConnectionConfigurator(connConfigurator); } return auth; }
@Test public void testGetUserName() throws Exception { PseudoAuthenticator authenticator = new PseudoAuthenticator(); Assert.assertEquals(System.getProperty("user.name"), authenticator.getUserName()); }
String strUrl = url.toString(); String paramSeparator = (strUrl.contains("?")) ? "&" : "?"; strUrl += paramSeparator + USER_NAME_EQ + getUserName(); url = new URL(strUrl); HttpURLConnection conn = (HttpURLConnection) url.openConnection();
/** * If the specified URL does not support SPNEGO authentication, a fallback {@link Authenticator} will be used. * <p> * This implementation returns a {@link PseudoAuthenticator}. * * @return the fallback {@link Authenticator}. */ protected Authenticator getFallBackAuthenticator() { Authenticator auth = new PseudoAuthenticator(); if (connConfigurator != null) { auth.setConnectionConfigurator(connConfigurator); } return auth; }
String strUrl = url.toString(); String paramSeparator = (strUrl.contains("?")) ? "&" : "?"; strUrl += paramSeparator + USER_NAME_EQ + getUserName(); url = new URL(strUrl); HttpURLConnection conn = (HttpURLConnection) url.openConnection();
/** * If the specified URL does not support SPNEGO authentication, a fallback {@link Authenticator} will be used. * <p> * This implementation returns a {@link PseudoAuthenticator}. * * @return the fallback {@link Authenticator}. */ protected Authenticator getFallBackAuthenticator() { Authenticator auth = new PseudoAuthenticator(); if (connConfigurator != null) { auth.setConnectionConfigurator(connConfigurator); } return auth; }
String strUrl = url.toString(); String paramSeparator = (strUrl.contains("?")) ? "&" : "?"; strUrl += paramSeparator + USER_NAME_EQ + getUserName(); url = new URL(strUrl); HttpURLConnection conn = (HttpURLConnection) url.openConnection();
/** * If the specified URL does not support SPNEGO authentication, a fallback {@link Authenticator} will be used. * <p/> * This implementation returns a {@link PseudoAuthenticator}. * * @return the fallback {@link Authenticator}. */ protected Authenticator getFallBackAuthenticator() { Authenticator auth = new PseudoAuthenticator(); if (connConfigurator != null) { auth.setConnectionConfigurator(connConfigurator); } return auth; }
@Test public void testAuthenticationAnonymousDisallowed() throws Exception { AuthenticatorTestCase auth = new AuthenticatorTestCase(); AuthenticatorTestCase.setAuthenticationHandlerConfig( getAuthenticationHandlerConfiguration(false)); auth._testAuthentication(new PseudoAuthenticator(), false); }
@Test public void testAuthenticationAnonymousDisallowedWithPost() throws Exception { AuthenticatorTestCase auth = new AuthenticatorTestCase(); AuthenticatorTestCase.setAuthenticationHandlerConfig( getAuthenticationHandlerConfiguration(false)); auth._testAuthentication(new PseudoAuthenticator(), true); }
@Test public void testAuthenticationAnonymousDisallowed() throws Exception { AuthenticatorTestCase auth = new AuthenticatorTestCase(); AuthenticatorTestCase.setAuthenticationHandlerConfig( getAuthenticationHandlerConfiguration(false)); auth._testAuthentication(new PseudoAuthenticator(), false); }
@Test public void testAuthenticationAnonymousDisallowedWithPost() throws Exception { AuthenticatorTestCase auth = new AuthenticatorTestCase(); AuthenticatorTestCase.setAuthenticationHandlerConfig( getAuthenticationHandlerConfiguration(false)); auth._testAuthentication(new PseudoAuthenticator(), true); }