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:org.broadleafcommerce.core.web.api.endpoint.catalog.CatalogEndpoint.java

public List<MediaWrapper> findMediaForSku(HttpServletRequest request, Long id) {
    Sku sku = catalogService.findSkuById(id);
    if (sku != null) {
        List<MediaWrapper> medias = new ArrayList<MediaWrapper>();
        if (sku.getSkuMedia() != null && !sku.getSkuMedia().isEmpty()) {
            for (Media media : sku.getSkuMedia().values()) {
                MediaWrapper wrapper = (MediaWrapper) context.getBean(MediaWrapper.class.getName());
                wrapper.wrapSummary(media, request);
                if (wrapper.isAllowOverrideUrl()) {
                    wrapper.setUrl(staticAssetPathService.convertAssetPath(media.getUrl(),
                            request.getContextPath(), request.isSecure()));
                }/*from  w w w.  j a v  a2 s  .co  m*/
                medias.add(wrapper);
            }
        }
        return medias;
    }
    throw BroadleafWebServicesException.build(HttpStatus.NOT_FOUND.value())
            .addMessage(BroadleafWebServicesException.SKU_NOT_FOUND, id);
}

From source file:org.sparkcommerce.core.web.api.endpoint.catalog.CatalogEndpoint.java

public List<MediaWrapper> findMediaForSku(HttpServletRequest request, Long id) {
    Sku sku = catalogService.findSkuById(id);
    if (sku != null) {
        List<MediaWrapper> medias = new ArrayList<MediaWrapper>();
        if (sku.getSkuMedia() != null && !sku.getSkuMedia().isEmpty()) {
            for (Media media : sku.getSkuMedia().values()) {
                MediaWrapper wrapper = (MediaWrapper) context.getBean(MediaWrapper.class.getName());
                wrapper.wrapSummary(media, request);
                if (wrapper.isAllowOverrideUrl()) {
                    wrapper.setUrl(staticAssetPathService.convertAssetPath(media.getUrl(),
                            request.getContextPath(), request.isSecure()));
                }//from   w  w  w. j  av a2  s .  c  o  m
                medias.add(wrapper);
            }
        }
        return medias;
    }
    throw SparkWebServicesException.build(Response.Status.NOT_FOUND.getStatusCode())
            .addMessage(SparkWebServicesException.SKU_NOT_FOUND, id);
}

From source file:com.alfaariss.oa.authentication.remote.saml2.profile.AbstractAuthNMethodSAML2Profile.java

/**
 * Creates a default empty SAML context object.
 *  /*  ww  w  . j  av a2s. com*/
 * TODO -MG: merge with AbstractSAML2Profile.createEncodingContext
 *  
 * @param request Servlet request.
 * @param response Servlet response.
 * @return Default SAML context object.
 */
protected SAMLMessageContext<SignableSAMLObject, SignableSAMLObject, SAMLObject> createEncodingContext(
        HttpServletRequest request, HttpServletResponse response) {
    HTTPInTransport inTransport = new HttpServletRequestAdapter(request);

    HTTPOutTransport outTransport = new HttpServletResponseAdapter(response, request.isSecure());

    SAMLMessageContext<SignableSAMLObject, SignableSAMLObject, SAMLObject> context = new BasicSAMLMessageContext<SignableSAMLObject, SignableSAMLObject, SAMLObject>();

    context.setInboundMessageTransport(inTransport);
    context.setOutboundMessageTransport(outTransport);

    return context;
}

From source file:org.broadleafcommerce.core.web.api.endpoint.catalog.CatalogEndpoint.java

public List<MediaWrapper> findMediaForProduct(HttpServletRequest request, Long id) {
    Product product = catalogService.findProductById(id);
    if (product != null) {
        ArrayList<MediaWrapper> out = new ArrayList<MediaWrapper>();
        Map<String, Media> media = product.getMedia();
        if (media != null) {
            for (Media med : media.values()) {
                MediaWrapper wrapper = (MediaWrapper) context.getBean(MediaWrapper.class.getName());
                wrapper.wrapSummary(med, request);
                if (wrapper.isAllowOverrideUrl()) {
                    wrapper.setUrl(staticAssetPathService.convertAssetPath(med.getUrl(),
                            request.getContextPath(), request.isSecure()));
                }//from   w ww  .j  av a2  s . c om
                out.add(wrapper);
            }
        }
        return out;
    }
    throw BroadleafWebServicesException.build(HttpStatus.NOT_FOUND.value())
            .addMessage(BroadleafWebServicesException.PRODUCT_NOT_FOUND, id);
}

From source file:org.sparkcommerce.core.web.api.endpoint.catalog.CatalogEndpoint.java

public List<MediaWrapper> findMediaForProduct(HttpServletRequest request, Long id) {
    Product product = catalogService.findProductById(id);
    if (product != null) {
        ArrayList<MediaWrapper> out = new ArrayList<MediaWrapper>();
        Map<String, Media> media = product.getMedia();
        if (media != null) {
            for (Media med : media.values()) {
                MediaWrapper wrapper = (MediaWrapper) context.getBean(MediaWrapper.class.getName());
                wrapper.wrapSummary(med, request);
                if (wrapper.isAllowOverrideUrl()) {
                    wrapper.setUrl(staticAssetPathService.convertAssetPath(med.getUrl(),
                            request.getContextPath(), request.isSecure()));
                }/*ww  w . j  a  v a2s . com*/
                out.add(wrapper);
            }
        }
        return out;
    }
    throw SparkWebServicesException.build(Response.Status.NOT_FOUND.getStatusCode())
            .addMessage(SparkWebServicesException.PRODUCT_NOT_FOUND, id);
}

From source file:ru.org.linux.comment.DeleteCommentController.java

@RequestMapping(value = "/delete_comment.jsp", method = RequestMethod.GET)
public ModelAndView showForm(HttpServletRequest request, @RequestParam("msgid") int msgid) throws Exception {
    Map<String, Object> params = new HashMap<>();

    Template tmpl = Template.getTemplate(request);

    if (!tmpl.isSessionAuthorized()) {
        throw new AccessViolationException(" ");
    }/*from w w  w. j  av  a2 s. c  o m*/

    params.put("msgid", msgid);

    Comment comment = commentService.getById(msgid);

    if (comment.isDeleted()) {
        throw new UserErrorException("  ");
    }

    int topicId = comment.getTopicId();

    Topic topic = messageDao.getById(topicId);

    if (topic.isDeleted()) {
        throw new AccessViolationException(" ");
    }

    params.put("topic", topic);

    CommentList comments = commentService.getCommentList(topic, tmpl.isModeratorSession());

    CommentFilter cv = new CommentFilter(comments);

    List<Comment> list = cv.getCommentsSubtree(msgid);

    params.put("commentsPrepared",
            prepareService.prepareCommentList(comments, list, request.isSecure(), tmpl, topic));
    params.put("comments", comments);

    return new ModelAndView("delete_comment", params);
}

From source file:de.innovationgate.wgpublisher.WGPRequestPath.java

private URL enforceSecureAppMode(WGDatabase db, HttpServletRequest req) throws MalformedURLException {

    boolean secureAppMode = db.getBooleanAttribute(WGACore.DBATTRIB_SECURE_APP, false);
    if (secureAppMode && !req.isSecure()) {
        URL currentURL = new URL(req.getRequestURL().toString());

        int redirectPort = 443;
        String defaultPortHTTPS = (String) db.getAttribute(WGACore.DBATTRIB_DEFAULTPORT_HTTPS);
        if (defaultPortHTTPS != null) {
            try {
                redirectPort = Integer.valueOf(defaultPortHTTPS);
            } catch (NumberFormatException e) {
                core.getLog().error("Exception parsing default HTTPS port as integer: " + defaultPortHTTPS
                        + ". Will use 443 instead.");
            }//from w ww .  ja  va 2s  .  c  o m
        }

        URL redirectURL;
        if (redirectPort != 443) {
            redirectURL = new URL("https", currentURL.getHost(), redirectPort, currentURL.getFile());
        } else {
            redirectURL = new URL("https", currentURL.getHost(), currentURL.getFile());
        }
        return redirectURL;
    }

    return null;

}

From source file:ru.org.linux.topic.TagTopicListController.java

@RequestMapping(value = "/tag/{tag}", method = { RequestMethod.GET, RequestMethod.HEAD }, params = "section")
public ModelAndView tagFeed(HttpServletRequest request, HttpServletResponse response, @PathVariable String tag,
        @RequestParam(value = "offset", defaultValue = "0") int offset,
        @RequestParam(value = "section", defaultValue = "0") int sectionId) throws Exception {
    ModelAndView modelAndView = new ModelAndView("tag-topics");

    Section section;//from  w  w w .j  a va2  s  . c  o  m

    if (sectionId != 0) {
        section = sectionService.getSection(sectionId);
        modelAndView.addObject("section", section);
    } else {
        section = null;
    }

    TagName.checkTag(tag);

    Template tmpl = Template.getTemplate(request);

    TopicListController.setExpireHeaders(response, null, null);

    String title = getTitle(tag, section);

    modelAndView.addObject("navtitle", title);
    modelAndView.addObject("ptitle", title);

    offset = topicListService.fixOffset(offset);

    List<Topic> topics = topicListService.getTopicsFeed(section, null, tag, offset, null, null, 20);

    List<PersonalizedPreparedTopic> preparedTopics = prepareService.prepareMessagesForUser(topics,
            request.isSecure(), tmpl.getCurrentUser(), tmpl.getProf(), false);

    modelAndView.addObject("messages", preparedTopics);

    modelAndView.addObject("offsetNavigation", true);

    modelAndView.addObject("tag", tag);
    modelAndView.addObject("section", sectionId);
    modelAndView.addObject("offset", offset);
    modelAndView.addObject("sectionList", sectionService.getSectionList());

    if (tmpl.isSessionAuthorized()) {
        modelAndView.addObject("isShowFavoriteTagButton",
                !userTagService.hasFavoriteTag(tmpl.getCurrentUser(), tag));

        modelAndView.addObject("isShowUnFavoriteTagButton",
                userTagService.hasFavoriteTag(tmpl.getCurrentUser(), tag));

        if (!tmpl.isModeratorSession()) {
            modelAndView.addObject("isShowIgnoreTagButton",
                    !userTagService.hasIgnoreTag(tmpl.getCurrentUser(), tag));
            modelAndView.addObject("isShowUnIgnoreTagButton",
                    userTagService.hasIgnoreTag(tmpl.getCurrentUser(), tag));
        }
    }

    TagInfo tagInfo = tagService.getTagInfo(tag, true);

    modelAndView.addObject("counter", tagInfo.topicCount());

    modelAndView.addObject("url", tagListUrl(tag));
    modelAndView.addObject("favsCount", userTagService.countFavs(tagInfo.id()));

    if (offset < 200 && preparedTopics.size() == 20) {
        modelAndView.addObject("nextLink", buildTagUri(tag, sectionId, offset + 20));
    }

    if (offset >= 20) {
        modelAndView.addObject("prevLink", buildTagUri(tag, sectionId, offset - 20));
    }

    return modelAndView;
}

From source file:ru.org.linux.topic.TopicListController.java

/**
 * @param sectionId//from www .  j  a  v a  2 s  .co m
 * @param request
 * @return
 * @throws Exception
 */
@RequestMapping(value = "/view-all.jsp", method = { RequestMethod.GET, RequestMethod.HEAD })
public ModelAndView viewAll(
        @RequestParam(value = "section", required = false, defaultValue = "0") int sectionId,
        HttpServletRequest request) {
    Template tmpl = Template.getTemplate(request);

    ModelAndView modelAndView = new ModelAndView("view-all");

    Section section = null;
    if (sectionId != 0) {
        section = sectionService.getSection(sectionId);
        modelAndView.addObject("section", section);
    }

    Calendar calendar = Calendar.getInstance();
    calendar.setTime(new Date());
    calendar.add(Calendar.MONTH, -1);

    List<Topic> messages = topicListService.getAllTopicsFeed(section, calendar.getTime());
    modelAndView.addObject("messages", prepareService.prepareMessagesForUser(messages, request.isSecure(),
            tmpl.getCurrentUser(), tmpl.getProf(), false));

    List<TopicListDto.DeletedTopic> deleted = topicListService.getDeletedTopicsFeed(sectionId);

    modelAndView.addObject("deletedTopics", deleted);
    modelAndView.addObject("sections", sectionService.getSectionList());

    return modelAndView;
}