validate

Always Respond with a NullTafResp, which declares it is unauthenticated, and unauthorized
196840
public TafResp validate(LifeForm reading, HttpServletRequest req, HttpServletResponse resp) {
		return NullTafResp.singleton();
	}
493783
function validate(entityAspect, validator, value, context) {
    var ve = validator.validate(value, context);
    if (ve) {
      entityAspect._addValidationError(ve);
      return false;
    } else {
      var key = ValidationError.getKey(validator, context ? context.propertyName : null);
      entityAspect._removeValidationError(key);
      return true;
    }
  }
1209724
public static void validate(final Module module) {
        if (null == module) {
            throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST)
                .entity("Module cannot be null!")
                .build());
        }
        if(module.getName() == null ||
                module.getName().isEmpty()){
            throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST)
                    .entity("Module name cannot be null or empty!")
                    .build());
        }
        if(module.getVersion()== null ||
                module.getVersion().isEmpty()){
            throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST)
                    .entity("Module version cannot be null or empty!")
                    .build());
        }

        // Check artifacts
        for(final Artifact artifact: DataUtils.getAllArtifacts(module)){
            validate(artifact);
        }

        // Check dependencies
        for(final Dependency dependency: DataUtils.getAllDependencies(module)){
            validate(dependency.getTarget());
        }
    }
1189972
private void validateInput(AuthenticationService authenticationService, String username) throws AuthenticationException {
        if (authenticationService == null) {
            throw new AuthenticationException("authenticationService cannot be null.");
        } else if (username == null) {
            throw new AuthenticationException("username cannot be null.");
        }
    }
57010
function validateData(data, schema, fn) {
        debug('Schema:', schema);
        debug('Data:', data);

        if (!tv4.validate(data, schema)) {
            return fn(tv4.error);
        }

        return fn(null, true);
    }
727267
function validate(values) {
    var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
    var s = this;

    var _tv4$validateMultiple = tv4.validateMultiple(values, s),
        valid = _tv4$validateMultiple.valid,
        errors = _tv4$validateMultiple.errors;

    if (valid) {
      return null;
    }

    var assign = options.assign,
        _options$name = options.name,
        name = _options$name === void 0 ? 'SchemaError' : _options$name;
    var _s$schema = s.schema,
        schema = _s$schema === void 0 ? {} : _s$schema;
    var error = new Error("Validation failed with schema: ".concat(schema.title || schema.id || schema.description));
    return Object.assign(error, {
      id: uuid.v4(),
      name: name,
      errors: errors,
      schema: schema,
      values: values,
      engine: 'tv4'
    }, assign);
  }
351672
public static final <T extends JavaScriptObject> T checkNull(T js) {
    if (!GWT.isProdMode() && js == null) {
      throw new NullPointerException();
    }
    return js;
  }
192025
@Override
    public void validateDefault(InputProblemReporter rep, boolean normalize)
        throws XMLStreamException
    {
        String normStr = validateDefaultName(rep, normalize);
        if (normalize) {
            mDefValue.setValue(normStr);
        }

        // Ok, but was it declared?

        /* 03-Dec-2004, TSa: This is rather ugly -- need to know we
         *   actually really get a DTD reader, and DTD reader needs
         *   to expose a special method... but it gets things done.
         */
        EntityDecl ent = ((MinimalDTDReader) rep).findEntity(normStr);
        checkEntity(rep, normStr, ent);
    }
240592
public void validateNonce(ConsumerDetails consumerDetails, long timestamp, String nonce) throws AuthenticationException {
    long nowSeconds = (System.currentTimeMillis() / 1000);
    if ((nowSeconds - timestamp) > getValidityWindowSeconds()) {
      throw new CredentialsExpiredException("Expired timestamp.");
    }
  }
903712
function authenticate(tenantOrSupertenantId, logmetToken, isSuperTenant) {
    // Identification frame:
    // 1 | I | id_size | id
    var idFrameTypeAndVersion = '1I';
    var clientIdString = 'standalone_dlms_data_client_v0.0.1_' + os.hostname();
    logger.info('Identifying the Logmet client: ' + clientIdString);

    var idDataBuffer = new Buffer(idFrameTypeAndVersion.length + 1 + clientIdString.length);

    idDataBuffer.write(idFrameTypeAndVersion, 0 , idFrameTypeAndVersion.length);

    idDataBuffer.writeUIntBE(clientIdString.length, idFrameTypeAndVersion.length, 1);
    idDataBuffer.write(clientIdString, idFrameTypeAndVersion.length + 1, clientIdString.length);

    // Send the identification frame to Logmet
    tlsSocket.write(idDataBuffer);

    // Authentication frame:
    // 2 | S or T | tenant_id_size | tenant_id | token_size | token
    var authFrameTypeAndVersion = isSuperTenant ? '2S' : '2T';
    logger.info('Authenticating with Logmet with frame type: ' + authFrameTypeAndVersion[1]);

    var bufferSize = authFrameTypeAndVersion.length + tenantOrSupertenantId.length + logmetToken.length + 2;
    var authDataBuffer = new Buffer(bufferSize);

    authDataBuffer.write(authFrameTypeAndVersion, 0, authFrameTypeAndVersion.length);

    authDataBuffer.writeUIntBE(tenantOrSupertenantId.length, authFrameTypeAndVersion.length, 1);
    authDataBuffer.write(tenantOrSupertenantId, authFrameTypeAndVersion.length + 1, tenantOrSupertenantId.length);

    authDataBuffer.writeUIntBE(logmetToken.length, authFrameTypeAndVersion.length + 1 + tenantOrSupertenantId.length, 1);
    authDataBuffer.write(logmetToken, authFrameTypeAndVersion.length + 1 + tenantOrSupertenantId.length + 1, logmetToken.length);

    // Send the authentication frame to Logmet
    tlsSocket.write(authDataBuffer);
}
138529
@Override
    public void validate(String host, int port, String path, boolean secure, Cookie cookie) throws MalformedCookieException {
        LOG.trace("enter CookieSpecBase.validate("
            + "String, port, path, boolean, Cookie)");
        if (host == null) {
            throw new IllegalArgumentException(
                "Host of origin may not be null");
        }
        if (host.trim().equals("")) {
            throw new IllegalArgumentException(
                "Host of origin may not be blank");
        }
        if (port < 0) {
            throw new IllegalArgumentException("Invalid port: " + port);
        }
        if (path == null) {
            throw new IllegalArgumentException(
                "Path of origin may not be null.");
        }
        host = host.toLowerCase();
        // check version
        if (cookie.getVersion() < 0) {
            throw new MalformedCookieException ("Illegal version number " 
                + cookie.getValue());
        }

        // security check... we musn't allow the server to give us an
        // invalid domain scope

        // Validate the cookies domain attribute.  NOTE:  Domains without 
        // any dots are allowed to support hosts on private LANs that don't 
        // have DNS names.  Since they have no dots, to domain-match the 
        // request-host and domain must be identical for the cookie to sent 
        // back to the origin-server.
        if (host.indexOf(".") >= 0) {
            // Not required to have at least two dots.  RFC 2965.
            // A Set-Cookie2 with Domain=ajax.com will be accepted.

            // domain must match host
            if (!host.endsWith(cookie.getDomain())) {
                String s = cookie.getDomain();
                if (s.startsWith(".")) {
                    s = s.substring(1, s.length());
                }
                if (!host.equals(s)) { 
                    throw new MalformedCookieException(
                        "Illegal domain attribute \"" + cookie.getDomain() 
                        + "\". Domain of origin: \"" + host + "\"");
                }
            }
        } else {
            if (!host.equals(cookie.getDomain())) {
                throw new MalformedCookieException(
                    "Illegal domain attribute \"" + cookie.getDomain() 
                    + "\". Domain of origin: \"" + host + "\"");
            }
        }
    }
835586
private void validateInput(String resourceName, Collection<String> requiredRoles) {
        if (requiredRoles == null) {
            throw new NullPointerException("requiredRoles cannot be null.");
        } else if (resourceName == null) {
            throw new NullPointerException("resourceName cannot be null.");
        }
    }
1145332
def _validate_client(self, request, data):
        
        client = self.get_client(data.get('client_id'))

        if client is None:
            raise OAuthError({
                'error': 'unauthorized_client',
                'error_description': _("An unauthorized client tried to access"
                    " your resources.")
            })

        form = self.get_request_form(client, data)

        if not form.is_valid():
            raise OAuthError(form.errors)

        return client, form.cleaned_data
235381
def get_no_validate(self, key):
    """"""
    x, env = self.get_thunk_env(key)

    # Check if this is a Thunk that needs to be lazily evaluated before we
    # return it.
    if isinstance(x, framework.Thunk):
      x = framework.eval(x, env)

    return x
358840
function _validateMitto(mittoObject) {
  if (!mittoObject) {
    return null;
  }

  if (!mittoObject.hasOwnProperty("name")) {
    throw new Error("\"name\" property is missing from your .mitto and is required.");
  }

  if (mittoObject.hasOwnProperty("required")) {
    for (var key in mittoObject.required) {
      if (mittoObject.required[key].hasOwnProperty("type")) {
        if (DATA_TYPES.indexOf(mittoObject.required[key].type) === -1) {
          throw new Error(mittoObject.required[key].type + " is not a valid data type. Expected: \"undefined\", \"object\", \"boolean\", \"number\", \"string\", \"symbol\", or \"function\"");
        }
      } else {
        throw new Error("\"type\" property is missing from your .mitto's required parameter \"" + key + "\"");
      }

      if (mittoObject.required[key].hasOwnProperty("description") && typeof mittoObject.required[key].description !== "string") {
        throw new Error("\"description\" property of your .mitto's required parameter " + key + " must be of type \"string\"");
      }
    }
  }

  if (mittoObject.hasOwnProperty("optional")) {
    for (var key in mittoObject.optional) {
      if (mittoObject.optional[key].hasOwnProperty("type")) {
        if (DATA_TYPES.indexOf(mittoObject.optional[key].type) === -1) {
          throw new Error(mittoObject.optional[key].type + " is not a valid data type. Expected: \"undefined\", \"object\", \"boolean\", \"number\", \"string\", \"symbol\", or \"function\"");
        }
      } else {
        throw new Error("\"type\" property is missing from your .mitto's optional parameter " + key);
      }

      if (mittoObject.optional[key].hasOwnProperty("description") && typeof mittoObject.optional[key].description !== "string") {
        throw new Error("\"description\" property of your .mitto's optional parameter " + key + " must be of type \"string\"");
      }

      if (mittoObject.optional[key].hasOwnProperty("default") && _typeof(mittoObject.optional[key].default) !== mittoObject.optional[key].type) {
        throw new Error("\"default\" property of your .mitto's optional parameter " + key + " must be a " + mittoObject.optional[key].type + ", as specified by \"type\"");
      } else if (mittoObject.optional[key].hasOwnProperty("default")) {
        mittoObject.hasDefault = true;
      }
    }
  }

  return mittoObject;
}
1291564
function(oData) {
    // Special case null and undefined
    if(!lang.isValue(oData)) {
        return null;
    }
    
    //Convert to string
    var string = oData + "";

    // Validate
    if(lang.isString(string)) {
        return string;
    }
    else {
        return null;
    }
}
88907
public static void validateNull( Object object, String identifier )
        throws PreConditionException
    {
        if( object == null )
        {
            return;
        }
        throw new PreConditionException( identifier + " was NOT NULL." );
    }