private <T> T fromPolicyContext(Class<T> type) { try { return (T) PolicyContext.getContext(type.getName()); } catch (Exception e) { // } return null; }
@Override public Subject getContextSubject() { try { return (Subject) PolicyContext.getContext(SUBJECT_CONTEXT_KEY); } catch (PolicyContextException e) { throw new HibernateException( "Unable to access JACC PolicyContext in order to locate calling Subject", e); } }
public HttpUserInfo(boolean enableDNSLookups) { try { HttpServletRequest rq = (HttpServletRequest) PolicyContext.getContext(WEB_REQUEST_KEY); init(rq, enableDNSLookups); } catch (PolicyContextException e) { userId = "UNKNOWN_USER"; } catch (NullPointerException e) { // Thrown when mbean method is invoked by MDB userId = "SYSTEM"; } }
/** * Get the {@link HttpServletRequest} from the {@link MessageContext} * * @param msgContext * @return */ private HttpServletRequest getHttpRequest(MessageContext msgContext) { HttpServletRequest request = (HttpServletRequest) msgContext.get(MessageContext.SERVLET_REQUEST); if (request == null) { try { request = (HttpServletRequest) PolicyContext.getContext("javax.servlet.http.HttpServletRequest"); } catch (PolicyContextException e) { throw new RuntimeException(e); } } return request; }
public void validateCertificateChain(List<X509Certificate> certificateChain) throws SecurityException { LOG.debug("validate certificate chain: " + certificateChain); HttpServletRequest httpServletRequest; try { httpServletRequest = (HttpServletRequest) PolicyContext.getContext("javax.servlet.http.HttpServletRequest"); } catch (PolicyContextException e) { throw new RuntimeException("JACC error: " + e.getMessage()); } HttpSession httpSession = httpServletRequest.getSession(); httpSession.setAttribute("authenticationCertificateChain", certificateChain); }
public void checkNationalRegistrationCertificate(List<X509Certificate> certificateChain) throws SecurityException { LOG.debug("checking national registry certificate..."); HttpServletRequest httpServletRequest; try { httpServletRequest = (HttpServletRequest) PolicyContext.getContext("javax.servlet.http.HttpServletRequest"); } catch (PolicyContextException e) { throw new RuntimeException("JACC error: " + e.getMessage()); } HttpSession httpSession = httpServletRequest.getSession(); X509Certificate certificate = certificateChain.get(0); httpSession.setAttribute("NationalRegistryCertificate", certificate); }