/** * Convenience method that uses a ServletPrincipalExtractor. * * @param request The HTTP Request. * @return a Subject with all available request content * @see #getSubject(PrincipalExtractor) */ public static Subject getSubject(final HttpServletRequest request) { return getSubject(new ServletPrincipalExtractor(request)); }
/** * Create a subject with the specified certificate chain and private key. * This method constructs an X509CertificateChain and then calls * getSubject(X509CertificateChain). * * @param certs a non-null and non-empty certificate chain * @param key optional private key * @return a Subject */ public static Subject getSubject(X509Certificate[] certs, PrivateKey key) { final X509CertificateChain chain = new X509CertificateChain(certs, key); return getSubject(chain); }
public static Subject createSubject(File certKeyFile) { try { X509CertificateChain certKey = readPemCertificateAndKey(certKeyFile); return AuthenticationUtil.getSubject(certKey); } catch (InvalidKeySpecException ex) { throw new RuntimeException("failed to read RSA private key from " + certKeyFile, ex); } catch (NoSuchAlgorithmException ex) { throw new RuntimeException("BUG: failed to create empty KeyStore", ex); } catch (IOException ex) { throw new RuntimeException("failed to read certificate file " + certKeyFile, ex); } catch (CertificateException ex) { throw new RuntimeException("failed to load certificate from file " + certKeyFile, ex); } }
Subject subject = AuthenticationUtil.getSubject(request); if (subject == null)
public static Subject createSubject(File certFile, File keyFile) { try { PrivateKey pk = readPrivateKey(keyFile); X509Certificate[] chain = readCertificateChain(certFile); return AuthenticationUtil.getSubject(chain, pk); } catch (InvalidKeySpecException ex) { throw new RuntimeException("failed to read RSA private key from " + keyFile, ex); } catch (NoSuchAlgorithmException ex) { throw new RuntimeException("BUG: failed to create empty KeyStore", ex); } catch (FileNotFoundException ex) { throw new RuntimeException("failed to find certificate and/or key file " + certFile + "," + keyFile, ex); } catch (IOException ex) { throw new RuntimeException("failed to read certificate file " + certFile, ex); } catch (CertificateException ex) { throw new RuntimeException("failed to load certificate from file " + certFile, ex); } }
Subject subject = AuthenticationUtil.getSubject(request); logger.debug(subject.toString());
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { WebServiceLogInfo logInfo = new ServletLogInfo(request); long start = System.currentTimeMillis(); try { Subject subject = AuthenticationUtil.getSubject(request); logInfo.setSubject(subject); log.info(logInfo.start()); Class wsClass = Class.forName(pluginClassName); WebService ws = (WebService) wsClass.newInstance(); if (ws instanceof AvailabilityPlugin) { AvailabilityPlugin ap = (AvailabilityPlugin) ws; ap.setAppName(appName); } Subject.doAs(subject, new ChangeServiceState(ws, request)); response.sendRedirect(request.getRequestURL().toString()); logInfo.setSuccess(true); } catch (Throwable t) { log.error("BUG", t); response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, t.getMessage()); logInfo.setSuccess(false); logInfo.setMessage(t.toString()); } finally { logInfo.setElapsedTime(System.currentTimeMillis() - start); log.info(logInfo.end()); } }
throws IOException { final Subject subject = AuthenticationUtil.getSubject(principalExtractor); final Set<SSOCookieCredential> cookieCredentials = subject.getPublicCredentials(SSOCookieCredential.class);
Subject subject = AuthenticationUtil.getSubject(request); logInfo.setSubject(subject); log.info(logInfo.start());
Subject subject = AuthenticationUtil.getSubject(request); logInfo.setSubject(subject);
long start = System.currentTimeMillis(); try { Subject subject = AuthenticationUtil.getSubject(request); logInfo.setSubject(subject); log.info(logInfo.start());
this.subject = AuthenticationUtil.getSubject(new NetrcAuthenticator(true)); } else if (argMap.isSet("cert")) {
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { WebServiceLogInfo logInfo = new ServletLogInfo(request); long start = System.currentTimeMillis(); try { Subject subject = AuthenticationUtil.getSubject(request); logInfo.setSubject(subject); log.info(logInfo.start()); if (doTransform) { StringReader sr = new StringReader(capTemplate); CapabilitiesParser cp = new CapabilitiesParser(false); Document doc = cp.parse(sr); transformCapabilities(doc, request); doOutput(doc, response); } else { doOutput(capTemplate, response); } } catch (JDOMException ex) { logInfo.setSuccess(false); logInfo.setMessage(ex.toString()); log.error("BUG: failed to rewrite hostname in accessURL elements", ex); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ex.getMessage()); } finally { logInfo.setElapsedTime(System.currentTimeMillis() - start); log.info(logInfo.end()); } }