Package com.alu.e3.prov.restapi.model

Examples of com.alu.e3.prov.restapi.model.Error


  }

  private static final DynamicTdr fromDataModel(TdrDynamicRule tdrDynamicRule) {
    if (tdrDynamicRule==null) throw new IllegalArgumentException("tdrDynamicRule must not be null");

    DynamicTdr s = new DynamicTdr();
    s.setHttpHeaderName      (tdrDynamicRule.getHttpHeaderName());
    s.setTdrPropName      (tdrDynamicRule.getTdrPropName());
    s.setExtractFrom      (tdrDynamicRule.getExtractFrom());

    TdrType tdrType = new TdrType();
    s.setTypes          (tdrType);
    tdrType.getType().addAll  (tdrDynamicRule.getTypes());

    return s;
  }
View Full Code Here


    TdrData tdrData = new TdrData();

    TdrType tdrType = new TdrType();
    tdrType.getType().add("apiRateLimit");

    DynamicTdr dt = new DynamicTdr();
    dt.setHttpHeaderName("HTTP_HEADER");
    dt.setTdrPropName("propname");
    dt.setTypes(tdrType);

    tdrData.getDynamic().add(dt);

    StaticTdr st = new StaticTdr();
    st.setValue("staticValue");
View Full Code Here

      }
    };
  }

  private Error validate(Auth auth) {
    com.alu.e3.prov.restapi.model.Error error = new Error();
    error.setErrorText("");
    boolean inError = false;

    // Do some validation
    AuthType authType = auth.getType();
    if(authType == null){
      inError = true;
      error.setErrorText("Could not determine auth-type from request.");     
    } else {
      if(authType.equals(AuthType.BASIC)){
        BasicAuth basicAuth = auth.getBasicAuth();
        if(basicAuth == null){
          inError = true;
          error.setErrorText("Request did not contain BasicAuth info.");
        } else {
          if(basicAuth.getUsername() == null || basicAuth.getUsername().isEmpty()){
            inError = true;
            error.setErrorText("Username must not be empty for Basic authentication type.");
          }
          if(basicAuth.getPassword() == null || basicAuth.getPassword().length <= 0){
            inError = true;
            error.setErrorText(error.getErrorText()+" Password must not be empty for Basic authentication type.");
          }
        }
      }
      else if(authType.equals(AuthType.WSSE)){
        WSSEAuth basicAuth = auth.getWsseAuth();
        if(basicAuth == null){
          inError = true;
          error.setErrorText("Request did not contain WsseAuth info.");
        } else {
          if(basicAuth.getUsername() == null || basicAuth.getUsername().isEmpty()){
            inError = true;
            error.setErrorText("Username must not be empty for WSSE authentication type.");
          }
          if(basicAuth.getPassword() == null || basicAuth.getPassword().length <= 0){
            inError = true;
            error.setErrorText(error.getErrorText()+" Passowrd must not be empty for WSSE authentication type.");
          }
        }
      }
      else if(authType.equals(AuthType.AUTHKEY)){
        AuthKeyAuth authKeyAuth = auth.getAuthKeyAuth();
        if(authKeyAuth == null) {
          inError = true;
          error.setErrorText("Request did not contain AuthKeyAuth info.");         
        } else {
          if(authKeyAuth.getKeyValue()== null || authKeyAuth.getKeyValue().isEmpty()){
            inError = true;
            error.setErrorText("authKey must not be empty for AuthKey authentication type.")
          }
        }
      }
      else if(authType.equals(AuthType.IP_WHITE_LIST)){
        IpWhiteList ipWhiteListAuth = auth.getIpWhiteListAuth();
        if(ipWhiteListAuth == null) {
          inError = true;
          error.setErrorText("Request did not contain ipWhiteListAuth info.");             
        } else {
          // We don't check for null ipList here, but could ....
          List<String> ipList = ipWhiteListAuth.getIp();
          // Check for duplicate white-list ips by adding all members of list to a Set
          Set<String> testSet = new HashSet<String>();
          for (String ip : ipList) {
            if (testSet.contains(ip)) {
              if(LOG.isDebugEnabled())
                LOG.debug("Found duplicate whitelist ip: {}", ip);
              inError = true;
              error.setErrorText("Duplicate ip in white-list: " + ip);
              break;
            }
            testSet.add(ip);
          }
        }
View Full Code Here

    int applicationErrorCode = 0;
    int status;
    Throwable cause = ex;

    BasicResponse resp = new BasicResponse(BasicResponse.FAILURE);
    resp.setError(new Error());

    if (ex instanceof AccessDeniedException) {
      // 403 FORBIDDEN
      status = 403;
View Full Code Here

    env.setTargetHosts(Arrays.asList(th, th2));
    api.setTdrEnabled(new TdrEnabled());
    api.getTdrEnabled().setEnabled("true");

    HTTPSType httpsType = new HTTPSType();
    httpsType.setEnabled(true);
    api.setHttps(httpsType);

    TdrData tdrData = new TdrData();

    TdrType tdrType = new TdrType();
View Full Code Here

    return b;
  }

  private static IpWhiteList fromDataModelToIpWhiteListAuth(AuthDetail authDetail) {
    if (authDetail==null) throw new IllegalArgumentException("authDetail must not be null");
    IpWhiteList i = new IpWhiteList();
    i.getIp().addAll  (authDetail.getWhiteListedIps());
    return i;
  }
View Full Code Here

    return i;
  }

  private static IpWhiteList fromDataModelToIpWhiteListApi(Api apiDetail) {
    if (apiDetail==null) throw new IllegalArgumentException("apiDetail must not be null");
    IpWhiteList i = new IpWhiteList();
    i.getIp().addAll  (apiDetail.getWhiteListedIps());
    return i;
  }
View Full Code Here

    provisionData.setTdrOnLimitReached    (api.getTdrOnLimitReached());
    provisionData.setStatus          (fromDataModel(api.getApiDetail().getStatus()));
    provisionData.setHttps          (fromDataModel(api.getApiDetail().getHttps()));

    for(String keyname : api.getProperties().keySet()){
      Key k = new Key();
      k.setName(keyname);
      k.setValue(api.getProperties().get(keyname));
      provisionData.getProperties().add(k);
    }

    provisionData.setHeaderTransformations  (BeanConverterUtil.<com.alu.e3.prov.restapi.model.HeaderTransformation,HeaderTransformation>fromDataModels(api.getHeaderTransformations()));
View Full Code Here

    a.setType            (fromDataModel(auth.getAuthDetail().getType()));
    a.setTdr            (fromDataModel(auth.getTdrGenerationRule()));
    a.setHeaderTransformations  (BeanConverterUtil.<com.alu.e3.prov.restapi.model.HeaderTransformation,HeaderTransformation>fromDataModels(auth.getHeaderTransformations()));

    for(String keyname : auth.getProperties().keySet()){
      Key k = new Key();
      k.setName(keyname);
      k.setValue(auth.getProperties().get(keyname));
      a.getProperties().add(k);
    }

    switch(auth.getAuthDetail().getType()) {
    case AUTHKEY:
View Full Code Here

    p.setTdrOnLimitReached    (policy.getTdrOnLimitReached());
    p.setHeaderTransformations  (BeanConverterUtil.<com.alu.e3.prov.restapi.model.HeaderTransformation,HeaderTransformation>fromDataModels(policy.getHeaderTransformations()));


    for(String keyname : policy.getProperties().keySet()){
      Key k = new Key();
      k.setName(keyname);
      k.setValue(policy.getProperties().get(keyname));
      p.getProperties().add(k);
    }

    return p;
  }
View Full Code Here

TOP

Related Classes of com.alu.e3.prov.restapi.model.Error

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.