public HttpPrincipal extract(URLConnection connection) { return new HttpPrincipal("",realm); } }
/** * returns the same string as getName() */ public String toString() { return getName(); } }
/** * Returns a String containing the name of the current authenticated user. If the user has not been authenticated, * the method returns null. * @return a String containing the name of the user making this request; null if the user has not been authenticated. */ public String getPrincipal() { HttpPrincipal principal = _exchange.getPrincipal(); return principal == null ? null : principal.getUsername(); }
@Override public HttpPrincipal extract(URLConnection connection) throws IOException, ParseException { Object payload = new JSONParser().parse(new InputStreamReader(connection.getInputStream())); Stack<String> pathElements = EscapeUtil.extractElementsFromPath(path); Object result = payload; while (!pathElements.isEmpty()) { if (result == null) { throw new IllegalArgumentException("No path '" + path + "' found in " + payload.toString()); } String key = pathElements.pop(); result = extractValue(result, key); } return new HttpPrincipal(result.toString(),realm); }
@Override public Result authenticate(HttpExchange httpExchange) { if( !(httpExchange instanceof HttpsExchange) ) { return new Failure(500); } try { HttpsExchange httpsExchange = (HttpsExchange) httpExchange; X509Certificate certificate = getClientCert(httpsExchange); if (certificate == null) { return new Failure(401); } checkCertForClientUsage(certificate); checkCertForAllowedPrincipals(httpsExchange); String name=""; try { name = httpsExchange.getSSLSession().getPeerPrincipal().getName(); } catch (SSLPeerUnverifiedException ignore) { } return new Success(new HttpPrincipal(name, "ssl")); } catch (SecurityException e) { return new Failure(403); } }
public HttpPrincipal extract(URLConnection connection) { return new HttpPrincipal("",realm); } }
/** * Handles the {@link Result} in case of authorization success. * * * * @param aHttpExchange The {@link com.sun.net.httpserver.HttpExchange} * which's "WWW-Authenticate" header is to be modified. * * @return the {@link Result} of type {@link Authenticator.Success}. */ private Authenticator.Success toBasicOutSuccess( String aIdentity ) { return new Authenticator.Success( new HttpPrincipal( aIdentity, getRealm() ) ); }
@Override public HttpPrincipal extract(URLConnection connection) throws IOException, ParseException { Object payload = new JSONParser().parse(new InputStreamReader(connection.getInputStream())); Stack<String> pathElements = EscapeUtil.extractElementsFromPath(path); Object result = payload; while (!pathElements.isEmpty()) { if (result == null) { throw new IllegalArgumentException("No path '" + path + "' found in " + payload.toString()); } String key = pathElements.pop(); result = extractValue(result, key); } return new HttpPrincipal(result.toString(),realm); }
new HttpPrincipal ( uname, realm
@Override public Result authenticate(HttpExchange httpExchange) { if( !(httpExchange instanceof HttpsExchange) ) { return new Failure(500); } try { HttpsExchange httpsExchange = (HttpsExchange) httpExchange; X509Certificate certificate = getClientCert(httpsExchange); if (certificate == null) { return new Failure(401); } checkCertForClientUsage(certificate); checkCertForAllowedPrincipals(httpsExchange); String name=""; try { name = httpsExchange.getSSLSession().getPeerPrincipal().getName(); } catch (SSLPeerUnverifiedException ignore) { } return new Success(new HttpPrincipal(name, "ssl")); } catch (SecurityException e) { return new Failure(403); } }
return toBasicAuthRequired( aHttpExchange ); return new Authenticator.Success( new HttpPrincipal( ANONYMOUS, getRealm() ) );