class RestAuthX509CallbackHandler extends AbstractRestAuthCallbackHandler<X509CertificateCallback> {

    public boolean updateCallbackFromRequest(HttpServletRequest request,
            HttpServletResponse response, X509CertificateCallback callback) {

        X509Certificate[] certificates = (X509Certificate[]) request.getAttribute(
                "javax.servlet.request.X509Certificate");

        if (certificates != null && certificates.length > 0) {
            callback.setCertificate(certificates[0]);
        }

        return true;
    }

}