Package info.openurl.oom

Examples of info.openurl.oom.OpenURLRequest


   */
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException {
        try {
            // Try each Transport until someone takes responsibility
            OpenURLRequest openURLRequest = null;
            for (int i=0; openURLRequest == null && i<transports.length; ++i) {
                openURLRequest = transports[i].toOpenURLRequest(processor, req);
            }
           
            if (openURLRequest == null) {
                resp.sendError(HttpServletResponse.SC_BAD_REQUEST,
                        "Invalid Request");
                return;
            }
            // 2009-05-06: rchute Add AccessManager Support
            if (am != null) {
              try {
                String url = ((java.net.URIopenURLRequest.getContextObjects()[0].getReferent().getDescriptors()[0]).toASCIIString();
                if (url.startsWith("http") || url.startsWith("ftp")) {
                  if (!am.checkAccess(new URL(url).getHost())){
                    int status = HttpServletResponse.SC_FORBIDDEN;
                    resp.sendError(status);
                    return;
                  }
                }
              } catch (Exception e) {
                logger.error(e);
              }
            
            }
           
            // rchute: Add referrer for possible extension processing
            if (req.getHeader("referer") != null)
                openURLRequest.getContextObjects()[0].getReferringEntities()[0].addDescriptor(req.getHeader("referer"));
            // rchute: Add requester for possible extension processing
            openURLRequest.getContextObjects()[0].getRequesters()[0].addDescriptor(req.getRemoteAddr());
            // Process the ContextObjects
            OpenURLResponse result = processor.resolve(openURLRequest);
           
            // See if anyone handled the request
            int status;
View Full Code Here


    @Override
    protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException {
        try {
            // Try each Transport until someone takes responsibility
            OpenURLRequest openURLRequest = null;
            for (int i = 0; openURLRequest == null && i < transports.length; ++i) {
                openURLRequest = transports[i].toOpenURLRequest(processor, req);
            }

            if (openURLRequest == null) {
View Full Code Here

     */
    @Override
    protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException {
        try {
            // Try each Transport until someone takes responsibility
            OpenURLRequest openURLRequest = null;

            for (int i = 0; openURLRequest == null && i < transports.length; ++i) {
                openURLRequest = transports[i].toOpenURLRequest(processor, req);
            }

            if (openURLRequest == null) {
                resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Invalid Request");
                return;
            }

            // 2009-05-06: rchute Add AccessManager Support
            if (am != null) {
                if (LOGGER.isDebugEnabled()) {
                    LOGGER.debug("OpenURLServlet using AccessManager");
                }

                try {
                    final String url =
                            ((java.net.URI) openURLRequest.getContextObjects()[0].getReferent().getDescriptors()[0])
                                    .toASCIIString();

                    if (url.startsWith("http") || url.startsWith("ftp")) {
                        if (!am.checkAccess(new URL(url).getHost())) {
                            final int status = HttpServletResponse.SC_FORBIDDEN;
                            resp.sendError(status);
                            return;
                        }
                    }
                } catch (final Exception e) {
                    LOGGER.error(e.getMessage(), e);
                }
            }

            // rchute: Add referrer for possible extension processing
            if (req.getHeader("referer") != null) {
                final ContextObject[] coa = openURLRequest.getContextObjects();
                final ReferringEntity[] rea = coa[0].getReferringEntities();
                rea[0].addDescriptor(req.getHeader("referer"));
            }

            // rchute: Add requester for possible extension processing
            final ContextObject[] coa = openURLRequest.getContextObjects();
            coa[0].getRequesters()[0].addDescriptor(req.getRemoteAddr());

            // Process the ContextObjects
            final OpenURLResponse result = processor.resolve(openURLRequest);

View Full Code Here

TOP

Related Classes of info.openurl.oom.OpenURLRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.