コード例 #1
0
  /**
   * Returns the authentication data sent by client to the target according to the a list of
   * properties. By default, this method returns checks the variable "challengeScheme", "login",
   * "password" in order to build the ChallengeResponse object. It can be overriden.
   *
   * @param resolver The resolver.
   * @return The target challengeResponse object.
   * @throws ResourceException
   */
  protected ChallengeResponse getTargetChallengeResponse(Resolver<String> resolver)
      throws ResourceException {
    final ChallengeScheme challengeScheme =
        ChallengeScheme.valueOf(resolver.resolve("challengeScheme"));
    final String login = resolver.resolve("login");
    final String password = resolver.resolve("password");

    ChallengeResponse result = null;
    if ((challengeScheme != null) && (login != null) && (password != null)) {
      result = new ChallengeResponse(challengeScheme, login, password);
    }

    return result;
  }
コード例 #2
0
  /**
   * Returns the target method according to a list of properties.
   *
   * @param resolver The resolver.
   * @return The target method.
   */
  protected Method getTargetMethod(Resolver<String> resolver) {
    Method method = Method.valueOf(resolver.resolve("method"));
    if (method == null) {
      method = getTargetMethod();
    }

    return method;
  }
コード例 #3
0
  /**
   * Creates the FreeMarker data model for a given call. By default, it will create a {@link
   * TemplateHashModel} based on the result of {@link Resolver#createResolver(Request, Response)}.
   * If the {@link #getDataModel()} method has a non null value, it will be used.
   *
   * @param request The handled request.
   * @param response The handled response.
   * @return The FreeMarker data model for the given call.
   */
  protected Object createDataModel(Request request, Response response) {
    Object result = null;

    if (this.dataModel == null) {
      result = new ResolverHashModel(Resolver.createResolver(request, response));
    } else {
      result = this.dataModel;
    }

    return result;
  }
 /**
  * Sets the template's data model from a request/response pair. This default implementation uses a
  * Resolver.
  *
  * @see Resolver
  * @see Resolver#createResolver(Request, Response)
  * @param request The request where data are located.
  * @param response The response where data are located.
  */
 public void setDataModel(Request request, Response response) {
   setContext(new ResolverContext(Resolver.createResolver(request, response)));
 }
コード例 #5
0
 /**
  * Returns the entity sent to the target. By default, it sends the mail message.
  *
  * @param resolver the resolver.
  * @return The entity to be sent to the target.
  */
 protected Representation getTargetEntity(Resolver<String> resolver) {
   return new StringRepresentation(resolver.resolve("message"));
 }