All Downloads are FREE. Search and download functionalities are using the official Maven repository.

csip.PayloadRequest Maven / Gradle / Ivy

Go to download

The Cloud Services Integration Platform is a SoA implementation to offer a Model-as-a-Service framework, Application Programming Interface, deployment infrastructure, and service implementations for environmental modeling.

There is a newer version: 2.6.30
Show newest version
/*
 * $Id: PayloadRequest.java c5b2c5efd001 2019-05-16 od $
 *
 * This file is part of the Cloud Services Integration Platform (CSIP),
 * a Model-as-a-Service framework, API and application suite.
 *
 * 2012-2019, Olaf David and others, OMSLab, Colorado State University.
 *
 * OMSLab licenses this file to you under the MIT license.
 * See the LICENSE file in the project root for more information.
 */
package csip;

/**
 * Payload Request Access.
 *
 * @author od
 */
public class PayloadRequest {

  String reqRemoteIp;
  String reqUrl;
  String reqHost;
  String reqContext;
  String reqScheme;
  String reqAuth;
  ModelDataService mds;


  PayloadRequest(String reqRemoteIp, String reqUrl,
      String reqHost, String reqContext, String reqScheme, String reqAuth,
      ModelDataService mds) {
    this.reqRemoteIp = reqRemoteIp;
    this.reqUrl = reqUrl;
    this.reqHost = reqHost;
    this.reqContext = reqContext;
    this.reqScheme = reqScheme;
    this.reqAuth = reqAuth;
    this.mds = mds;
  }


  /**
   * The request ip.
   * @return the request ip
   */
  public String getRemoteAddr() {
    return reqRemoteIp;
  }


  /**
   * Get the codebase without the model service path.
   * @return the codebase of the URL as String
   */
  public String getCodebase() {
    String m = mds.service().getPath();
    String u = getURL();
    return u.substring(0, u.indexOf(m));
  }


  /**
   * Get the complete request URL.
   * @return the full request URL
   */
  public String getURL() {
    return reqUrl;
  }


  /**
   * Get the request Host.
   * @return the request host (IP)
   */
  public String getHost() {
    return reqHost;
  }


  /**
   * Get the webapp context name.
   * @return the context name
   */
  public String getContext() {
    return reqContext;
  }


  /**
   * Get the webapp context name.
   * @return the context name
   */
  public String getScheme() {
    return reqScheme;
  }


  /**
   * Get the request authorization token.
   * @return The token or null if there is none.
   */
  public String getAuthToken() {
    if (reqAuth == null
        || !Config.getTokenAuthentication().isTokenBasedAuthentication(reqAuth)) {
      return null;
    }
    return Config.getTokenAuthentication().getToken(reqAuth);
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy