public String getCurrentHttpPrincipalUsername(Subject subject) { final AuthMethod authMethod = AuthenticationUtil.getAuthMethod(subject); String username; if ((authMethod != null) && (authMethod != AuthMethod.ANON)) { final Set curPrincipals = subject.getPrincipals(HttpPrincipal.class); HttpPrincipal[] principalArray = new HttpPrincipal[curPrincipals.size()]; username = ((HttpPrincipal[]) curPrincipals .toArray(principalArray))[0].getName(); } else { username = null; } return username; } }
public AdSchemeHandler() { try { RegistryClient rc = new RegistryClient(); AuthMethod am = AuthenticationUtil.getAuthMethod(AuthenticationUtil.getCurrentSubject()); if (am == null) { am = AuthMethod.ANON; } URL serviceURL = rc.getServiceURL(URI.create(DATA_URI), Standards.DATA_10, am); this.baseURL = serviceURL.toExternalForm(); } catch (Throwable t) { log.error("failed to find CADC data service URL", t); throw new RuntimeException("BUG: failed to find CADC data service URL", t); } log.debug("CADC data service URL: " + baseURL); }
@Override public URL toURL(URI uri) { if (!SCHEME.equals(uri.getScheme())) { throw new IllegalArgumentException("invalid scheme in " + uri); } try { String path = getPath(uri); // check if authMethod has been set AuthMethod am = this.authMethod; if (am == null) { am = AuthenticationUtil.getAuthMethod(AuthenticationUtil.getCurrentSubject()); } if (am == null) { am = AuthMethod.ANON; } RegistryClient rc = new RegistryClient(); URL serviceURL = rc.getServiceURL(new URI(DATA_URI), Standards.DATA_10, am); URL url = this.toURL(serviceURL, path); log.debug(uri + " --> " + url); return url; } catch (MalformedURLException ex) { throw new RuntimeException("BUG", ex); } catch (URISyntaxException bug) { throw new RuntimeException("BUG - failed to create data web service URI", bug); } }
am = AuthenticationUtil.getAuthMethod(AuthenticationUtil.getCurrentSubject());
/** * @param subject * @return the possibly modified subject */ public Subject getSubject(Subject subject) { AuthMethod am = AuthenticationUtil.getAuthMethod(subject); if (am == null || AuthMethod.ANON.equals(am)) { return subject; } if (subject != null && subject.getPrincipals().size() > 0) { Profiler prof = new Profiler(AuthenticatorImpl.class); this.augmentSubject(subject); prof.checkpoint("AuthenticatorImpl.augmentSubject()"); } return subject; }
AuthMethod am = AuthenticationUtil.getAuthMethod(AuthenticationUtil.getCurrentSubject()); if (am == null) { am = AuthMethod.ANON;
logInfo.setSubject(subject); AuthMethod am = AuthenticationUtil.getAuthMethod(subject); if (am != null && !AuthMethod.ANON.equals(am)) {
AuthMethod cur = AuthenticationUtil.getAuthMethod(s); if (cur == null)
throws AccessControlException, CertificateExpiredException, CertificateNotYetValidException AuthMethod am = AuthenticationUtil.getAuthMethod(subject); if (am == null || AuthMethod.ANON.equals(am)) return false;
private void writeJobListing() throws IOException, JobPersistenceException, TransientException { Subject caller = AuthenticationUtil.getCurrentSubject(); AuthMethod am = AuthenticationUtil.getAuthMethod(caller); if (am == null || AuthMethod.ANON.equals(am)) { throw new AccessControlException("anonymous job listing not permitted");