Examples of WebException


Examples of br.net.woodstock.rockframework.web.WebException

  protected boolean validateReferer(final HttpServletRequest request) {
    if (this.regex == null) {
      this.regex = this.getInitParameter(RegexRefererFilter.REGEX_PARAMETER);
    }
    if (Conditions.isEmpty(this.regex)) {
      throw new WebException("Parameter '" + RegexRefererFilter.REGEX_PARAMETER + "' must be set");
    }
    if (super.validateReferer(request)) {
      String referer = HttpServletRequests.getReferer(request);
      if (Pattern.matches(this.regex, referer)) {
        return true;
View Full Code Here

Examples of br.net.woodstock.rockframework.web.WebException

    try {
      XmlDocument document = XmlDocument.read(new ByteArrayInputStream(bytes));
      String xml = document.toString();
      return xml;
    } catch (SAXException e) {
      throw new WebException(e);
    }
  }
View Full Code Here

Examples of br.net.woodstock.rockframework.web.WebException

      String clazzName = this.getInitParameter(ParameterizedResourceFilter.RESOURCE_MANAGER_PARAMETER);
      Class clazz = Class.forName(clazzName);
      ResourceManager resourceManager = (ResourceManager) clazz.newInstance();
      this.setResourceManager(resourceManager);
    } catch (Exception e) {
      throw new WebException(e);
    }
  }
View Full Code Here

Examples of com.cumulocity.me.http.WebException

    private WebResponse buildResponse() throws IOException {
        WebResponseImpl response = new WebResponseImpl(connection);
        if (response.isSuccessful()) {
            return response;
        } else {
            throw new WebException(response);
        }
    }
View Full Code Here

Examples of com.firefly.mvc.web.support.exception.WebException

    this.object = object;
    try {
      this.proxy = ReflectUtils.getMethodProxy(method);
    } catch (Throwable e) {
      log.error("handler init error", e);
      throw new WebException("handler invoke error");
    }
    this.methodParam = new byte[method.getParameterTypes().length];
  }
View Full Code Here

Examples of restx.WebException

        return value;
    }

    public void handleIn(RestxRequest req, RestxResponse resp) {
        if (req.getHeader("If-None-Match").equals(Optional.of(value))) {
            throw new WebException(HttpStatus.NOT_MODIFIED);
        } else {
            cacheControl.writeTo(resp);
            resp.setHeader("ETag", value);
        }
    }
View Full Code Here

Examples of restx.WebException

        try {
            mapper.acceptJsonFormatVisitor(mapper.constructType(Class.forName(fqcn)), visitor);
        } catch (JsonMappingException e) {
            throw new IllegalStateException(e);
        } catch (ClassNotFoundException e) {
            throw new WebException(HttpStatus.NOT_FOUND);
        }
        try {
            return mapper.writerWithDefaultPrettyPrinter()
                    .writeValueAsString(visitor.finalSchema());
        } catch (JsonProcessingException e) {
View Full Code Here

Examples of restx.WebException

*/
@RestxResource @Component
public class WebExceptionResource {
    @GET("/core/webexception/redirect")
    public void redirect() {
        throw new WebException(HttpStatus.FOUND) {
            @Override
            public void writeTo(RestxRequest restxRequest, RestxResponse restxResponse) throws IOException {
                restxResponse
                        .setStatus(getStatus())
                        .setHeader("Location", "/api/core/hello?who=restx");
View Full Code Here

Examples of restx.WebException

        RestxSession.current().clearPrincipal();
        RestxSession.current().define(String.class, Session.SESSION_DEF_KEY, null);

        Map<String, ?> principal = getPrincipal(session);
        if (principal == null) {
            throw new WebException(HttpStatus.UNAUTHORIZED);
        }

        String name = (String) principal.get("name");
        String passwordHash = (String) principal.get("passwordHash");

        Optional<? extends RestxPrincipal> principalOptional = authenticator.authenticate(
                name, passwordHash, ImmutableMap.copyOf(principal));

        if (principalOptional.isPresent()) {
            String sessionKey = uuidGenerator.doGenerate();
            RestxSession.current().authenticateAs(principalOptional.get());
            RestxSession.current().define(String.class, Session.SESSION_DEF_KEY, sessionKey);
            return new Session(sessionKey, principalOptional.get());
        } else {
            throw new WebException(HttpStatus.UNAUTHORIZED);
        }
    }
View Full Code Here

Examples of restx.WebException

                        principalOptional = RestxSession.getValue(
                                sessionDefinition, RestxPrincipal.class, RestxPrincipal.SESSION_DEF_KEY, principalName);
                        logger.info("restx-admin sudoing request with {}", su.get());
                    } catch (Exception e) {
                        logger.warn("restx-admin tried sudoing request with {}, but it failed: {}", su.get(), e.toString());
                        throw new WebException(HttpStatus.BAD_REQUEST, "invalid su session '" + su.get() + "': " + e.toString());
                    }
                }
            }
            return new RestxSession(sessionDefinition, valueidsByKey, principalOptional, expiration);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.