Example usage for javax.servlet.http HttpServletRequest isSecure

List of usage examples for javax.servlet.http HttpServletRequest isSecure

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletRequest isSecure.

Prototype

public boolean isSecure();

Source Link

Document

Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.

Usage

From source file:net.sf.sze.frontend.zeugnis.PdfController.java

/**
 * Entscheidung ob es sich um einen Remote-Call handelt oder nicht.
 * @param request der Request.// www  .j a  v  a  2s  . c  o m
 * @return true - wenn es sich um einen Remotecall handelt.
 */
@ModelAttribute(MODELL_ATTRIBUTE_IS_REMOTE_CALL)
public boolean isRemoteCall(HttpServletRequest request) {
    return request.isSecure();
}

From source file:com.acc.storefront.security.impl.DefaultGUIDCookieStrategy.java

@Override
public void deleteCookie(final HttpServletRequest request, final HttpServletResponse response) {
    if (!request.isSecure()) {
        LOG.error(/*w  w w  .j  a  v a  2  s  .  c om*/
                "Cannot remove secure GUIDCookie during an insecure request. I should have been called from a secure page.");
    } else {
        // Its a secure page, we can delete the cookie
        getCookieGenerator().removeCookie(response);
    }
}

From source file:com.acc.storefront.security.impl.DefaultGUIDCookieStrategy.java

@Override
public void setCookie(final HttpServletRequest request, final HttpServletResponse response) {
    if (!request.isSecure()) {
        // We must not generate the cookie for insecure requests, otherwise there is not point doing this at all
        throw new IllegalStateException("Cannot set GUIDCookie on an insecure request!");
    }//from w w w.ja v  a  2 s.c o  m

    final String guid = createGUID();

    getCookieGenerator().addCookie(response, guid);
    request.getSession().setAttribute(RequireHardLoginBeforeControllerHandler.SECURE_GUID_SESSION_KEY, guid);

    if (LOG.isInfoEnabled()) {
        LOG.info("Setting guid cookie and session attribute: " + guid);
    }
}

From source file:br.com.insula.spring.security.janrain.Janrain.java

public String getEngageJsUrl(HttpServletRequest request, String applicationName) {
    Assert.notNull(request, "'request' cannot be null");
    if (request.isSecure()) {
        return String.format("https://rpxnow.com/js/lib/%s/engage.js", applicationName);
    } else {//ww w .j  a v  a 2 s. c  o  m
        return String.format("http://widget-cdn.rpxnow.com/js/lib/%s/engage.js", applicationName);
    }
}

From source file:de.hybris.platform.ytelcoacceleratorstorefront.security.impl.DefaultGUIDCookieStrategy.java

@Override
public void setCookie(final HttpServletRequest request, final HttpServletResponse response) {
    if (!request.isSecure()) {
        // We must not generate the cookie for insecure requests, otherwise there is not point doing this at all
        throw new IllegalStateException("Cannot set GUIDCookie on an insecure request!");
    }//from   w  w  w  . ja  v a 2s .  co m

    final String guid = createGUID();

    getCookieGenerator().addCookie(response, guid);
    request.getSession().setAttribute(SecureRequestCookieCheckBeforeControllerHandler.SECURE_GUID_SESSION_KEY,
            guid);

    if (LOG.isInfoEnabled()) {
        LOG.info("Setting guid cookie and session attribute: " + guid);
    }
}

From source file:com.epam.cme.storefront.security.impl.DefaultGUIDCookieStrategy.java

@Override
public void setCookie(final HttpServletRequest request, final HttpServletResponse response) {
    if (!request.isSecure()) {
        // We must not generate the cookie for insecure requests, otherwise there is not point
        // doing this at all
        throw new IllegalStateException("Cannot set GUIDCookie on an insecure request!");
    }/*from w  ww  . j a  v a 2  s .  c  o m*/

    final String guid = createGUID();

    getCookieGenerator().addCookie(response, guid);
    request.getSession().setAttribute(SecureRequestCookieCheckBeforeControllerHandler.SECURE_GUID_SESSION_KEY,
            guid);

    if (LOG.isInfoEnabled()) {
        LOG.info("Setting guid cookie and session attribute: " + guid);
    }
}

From source file:game.com.LoginServlet.java

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    if (AppConfig.isLive) {
        if (!request.isSecure()) {
            doGet(request, response);//  w ww .j  a  va  2 s .  c om
            logger.info("!request.isSecure()");
            //                return;
        }
    }
    String username = request.getParameter("username");
    String password = request.getParameter("password");

    if (StringUtils.isBlank(username) || StringUtils.isBlank(password)) {
        doGet(request, response);
        logger.info("username=" + username + ",password=" + password);
        return;
    }
    HttpSession session = request.getSession();
    session.setAttribute("user", "hihi");
    response.sendRedirect("/");
}

From source file:com.acc.storefront.filters.AnonymousCheckoutFilter.java

@Override
protected void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response,
        final FilterChain filterChain) throws ServletException, IOException {
    if (!request.isSecure()
            && Boolean.TRUE.equals(getSessionService().getAttribute(WebConstants.ANONYMOUS_CHECKOUT))
            && getCheckoutCustomerStrategy().isAnonymousCheckout()) {
        final CartModel cartModel = getCartService().getSessionCart();
        cartModel.setDeliveryAddress(null);
        cartModel.setDeliveryMode(null);
        cartModel.setPaymentInfo(null);/*www  . ja  va 2 s  .c  o  m*/
        getCartService().saveOrder(cartModel);
        getSessionService().removeAttribute(WebConstants.ANONYMOUS_CHECKOUT);
        getSessionService().removeAttribute(WebConstants.ANONYMOUS_CHECKOUT_GUID);
    }

    filterChain.doFilter(request, response);
}

From source file:com.mondospider.spiderlocationapi.SetSpiderStatus.java

public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {

    if (!req.isSecure()) {
        resp.getWriter()/*w ww .  ja  v  a 2 s  .  c  o m*/
                .println("{\"result:error\", \"reason\":\"SSL secured connection required for updates.\"}");
        return;
    }

    if (req.getParameter("status") == null) {
        //Display Error&Help
        try {
            req.getRequestDispatcher("/index.html").forward(req, resp);
        } catch (ServletException e) {
            resp.getWriter().println("{\"result:error\", \"reason\":\"Forward failed\"}");
            e.printStackTrace();
            return;
        }
    }

    // Permission Check
    String key = req.getParameter("pwd");
    if (!isSecretKeyTrue(key)) {
        // accessDenied
        resp.getWriter().println("{\"result:error\", \"reason\":\"Wrong Key\"}");
        return;
    }

    try {

        String status = req.getParameter("status");

        // Update Position
        updateStatus(status);

        responseResp.put("result", "success");
        responseResp.put("updated_on", new Date());

        resp.setContentType("text/plain");

        resp.getWriter().println(responseResp.toString(2));
        return;

    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    resp.sendRedirect("/index.html");

}