Check if the connection has the required credentials to use
the given destination
481536
public final void checkPermission( Destination destination , String action ) throws JMSException
    {
    	if (securityContext == null)
            return; // Security is disabled
    	
    	DestinationRef destinationRef = DestinationTools.asRef(destination);
    	securityContext.checkPermission(destinationRef.getResourceName(), action);        
    }
1356263
async def verify_credentials(self):
        """"""
        _, public_key = self.srp.initialize()

        msg = messages.crypto_pairing({
            tlv8.TLV_SEQ_NO: b'\x01',
            tlv8.TLV_PUBLIC_KEY: public_key})
        resp = await self.protocol.send_and_receive(
            msg, generate_identifier=False)

        resp = _get_pairing_data(resp)
        session_pub_key = resp[tlv8.TLV_PUBLIC_KEY]
        encrypted = resp[tlv8.TLV_ENCRYPTED_DATA]
        log_binary(_LOGGER,
                   'Device',
                   Public=self.credentials.ltpk,
                   Encrypted=encrypted)

        encrypted_data = self.srp.verify1(
            self.credentials, session_pub_key, encrypted)
        msg = messages.crypto_pairing({
            tlv8.TLV_SEQ_NO: b'\x03',
            tlv8.TLV_ENCRYPTED_DATA: encrypted_data})
        resp = await self.protocol.send_and_receive(
            msg, generate_identifier=False)

        # TODO: check status code

        self._output_key, self._input_key = self.srp.verify2()
156814
def check_credentials(self):
        '''  '''
        req = requests.get(self.api_server + '/api/ad',
                           auth=(self.access_key, self.secret_key))
        # Not sure 500 server error should be included here
        if req.status_code in [401, 403, 500]:
            return False
        else:
            return True
981671
def check_path(path, credentials=None):
    
    from thunder.readers import get_file_reader
    reader = get_file_reader(path)(credentials=credentials)
    existing = reader.list(path, directories=True)
    if existing:
        raise ValueError('Path %s appears to already exist. Specify a new directory, '
                         'or call with overwrite=True to overwrite.' % path)
175301
private boolean checkDestinationAccess(
    DestinationHandler destination,
    String discriminator,
    String userId)
    throws SIDiscriminatorSyntaxException {
    if (tc.isEntryEnabled())
      SibTr.entry(
        tc,
        "checkDestinationAccess",
        new Object[] { destination, discriminator, userId });

    boolean allowed = true;

    // Map a null userid to an empty string
    if (userId == null) {
      userId = ""; // Empty string means those users that have not
      // been authenticated, but who are still, of course,
      // members of EVERYONE. 
    }

    // We use the userid flavour of security context as we need
    // to drive the userid flavour of the sib.security checkDestinationAccess
    // which is attuned for access checks for messages from foreign buses.
    SecurityContext secContext = new SecurityContext(userId, discriminator);

    // Check authority to access the destination    
    if (!destination
      .checkDestinationAccess(secContext, OperationType.RECEIVE)) 
    {
      if (tc.isDebugEnabled())
        SibTr.debug(
          tc,
          "checkDestinationAccess",
          "not authorized to produce to this destination");

      // Build the message for the Exception and the Notification
      String nlsMessage = 
      nls_cwsik.getFormattedMessage("DELIVERY_ERROR_SIRC_18", // USER_NOT_AUTH_SEND_ERROR_CWSIP0306
                                    new Object[] { destination.getName(), 
                                                   userId },
                                    null); 
                                    
      // Fire a Notification if Eventing is enabled
      iProxyHandler.
        getMessageProcessor().
        getAccessChecker().
        fireDestinationAccessNotAuthorizedEvent(destination.getName(),
                                        userId,
                                        OperationType.RECEIVE,
                                        nlsMessage);

      // sib.security will audit this
      allowed = false;
    }

    // Check authority to produce to discriminator
    if (allowed) {
      // If the discriminator is non-wildcarded, we can check authority to consume on
      // the discriminator.
      if (discriminator != null
        && !iProxyHandler
          .getMessageProcessor()
          .getMessageProcessorMatching()
          .isWildCarded(discriminator)) 
      {
        if (!destination
          .checkDiscriminatorAccess(secContext, OperationType.RECEIVE)) 
        {
          if (tc.isDebugEnabled())
            SibTr.debug(
              tc,
              "checkDestinationAccess",
              "not authorized to produce to this discriminator");

          // Write an audit record if access is denied
          SibTr
            .audit(
              tc,
              nls_cwsik
                .getFormattedMessage("DELIVERY_ERROR_SIRC_20",
          // USER_NOT_AUTH_SEND_ERROR_CWSIP0308
          new Object[] {
            destination.getName(),
            discriminator,
            userId },
            null));

          allowed = false;
        }
      }
    }

    if (tc.isEntryEnabled())
      SibTr.exit(tc, "checkDestinationAccess", new Boolean(allowed));
    return allowed;
  }
141277
def has_frames(self, destination):
        
        session = meta.Session()
        sel = select([model.frames_table.c.message_id]).where(
            model.frames_table.c.destination == destination)
        result = session.execute(sel)

        first = result.fetchone()
        return first is not None
36979
private void checkInquireAuthority(DestinationHandler destination,
                                       String destinationName,
                                       String busName,
                                       SecurityContext secContext,
                                       boolean temporary)
                    throws SINotAuthorizedException
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(
                        tc,
                        "checkInquireAuthority",
                        new Object[] { destination,
                                      destinationName,
                                      busName,
                                      secContext,
                                      Boolean.valueOf(temporary) });

        // Check authority to inquire on the destination

        if (!temporary) // Non-temorary destination access check
        {
            if (!destination.checkDestinationAccess(secContext,
                                                    OperationType.INQUIRE))
            {
                if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                    SibTr.exit(tc, "checkInquireAuthority", "not authorized to inquire on this destination");

                // Get the username
                String userName = secContext.getUserName(true);

                //Messaging varies dependent on bus versus destination access check
                String nlsMessage;
                if (destinationName != null)
                {
                    // Build the message for the Exception and the Notification
                    nlsMessage =
                                    nls.getFormattedMessage("USER_NOT_AUTH_INQUIRE_ERROR_CWSIP0314",
                                                            new Object[] { destinationName,
                                                                          userName },
                                                            null);

                    // Fire a Notification if Eventing is enabled
                    _accessChecker.
                                    fireDestinationAccessNotAuthorizedEvent(destinationName,
                                                                            userName,
                                                                            OperationType.INQUIRE,
                                                                            nlsMessage);
                }
                else // foreign bus access
                {
                    // Build the message for the Exception and the Notification
                    nlsMessage =
                                    nls.getFormattedMessage("USER_NOT_AUTH_INQUIRE_FB_ERROR_CWSIP0315",
                                                            new Object[] { busName,
                                                                          userName },
                                                            null);

                    // Fire a Notification if Eventing is enabled
                    _accessChecker.
                                    fireDestinationAccessNotAuthorizedEvent(busName,
                                                                            userName,
                                                                            OperationType.INQUIRE,
                                                                            nlsMessage);
                }

                // Thrown if user denied access to destination
                throw new SINotAuthorizedException(nlsMessage);
            }
        }
        else // Check authority to inquire on temp topic
        {
            // get the temp prefix from the destination name
            String destinationPrefix = SIMPUtils.parseTempPrefix(destinationName);
            if (!_accessChecker.checkTemporaryDestinationAccess(secContext,
                                                                destinationName, // name of destination
                                                                (destinationPrefix == null) ? "" : destinationPrefix, // sib.security wants empty string if prefix is null
                                                                OperationType.INQUIRE))
            {
                if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                    SibTr.exit(tc, "checkInquireAuthority", "not authorized to inquire on temporary destination");

                // Get the username
                String userName = secContext.getUserName(true);
                // Build the message for the Exception and the Notification
                String nlsMessage =
                                nls.getFormattedMessage("USER_NOT_AUTH_INQUIRE_ERROR_CWSIP0314",
                                                        new Object[] { destinationPrefix,
                                                                      userName },
                                                        null);

                // Fire a Notification if Eventing is enabled
                _accessChecker.
                                fireDestinationAccessNotAuthorizedEvent(destinationPrefix,
                                                                        userName,
                                                                        OperationType.INQUIRE,
                                                                        nlsMessage);

                // Thrown if user denied access to destination
                throw new SINotAuthorizedException(nlsMessage);
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "checkInquireAuthority");
    }
1259546
private boolean checkGoogleCredentials(UnderFileSystemConfiguration conf) {
    return conf.isSet(PropertyKey.GCS_ACCESS_KEY)
        && conf.isSet(PropertyKey.GCS_SECRET_KEY);
  }
264965
private void checkDestinationAccess(DestinationHandler destination,
                                        SecurityContext secContext) throws SIDiscriminatorSyntaxException, SINotAuthorizedException
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(
                        tc,
                        "checkDestinationAccess",
                        new Object[] { destination, secContext });

        // Check authority to access the destination
        if (!destination.
                        checkDestinationAccess(secContext,
                                               OperationType.SEND))
        {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.exit(tc, "checkDestinationAccess", "not authorized to produce to this destination");

            // Get the username
            String userName = secContext.getUserName(true);

            // Build the message for the Exception and the Notification
            String nlsMessage =
                            nls_cwsik.getFormattedMessage("DELIVERY_ERROR_SIRC_18", // USER_NOT_AUTH_SEND_ERROR_CWSIP0306
                                                          new Object[] { destination.getName(),
                                                                        userName },
                                                          null);

            // Fire a Notification if Eventing is enabled
            _messageProcessor.
                            getAccessChecker().
                            fireDestinationAccessNotAuthorizedEvent(destination.getName(),
                                                                    userName,
                                                                    OperationType.SEND,
                                                                    nlsMessage);

            // Thrown if user denied access to destination
            SIMPNotAuthorizedException e = new SIMPNotAuthorizedException(nlsMessage);

            e.setExceptionReason(SIRCConstants.SIRC0018_USER_NOT_AUTH_SEND_ERROR);
            e.setExceptionInserts(new String[] { destination.getName(),
                                                secContext.getUserName(true) });
            throw e;
        }

        // Check authority to produce to discriminator
        if (!destination.
                        checkDiscriminatorAccess(secContext,
                                                 OperationType.SEND))
        {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.exit(tc, "checkDestinationAccess", "not authorized to produce to this discriminator");

            // Write an audit record if access is denied
            SibTr.audit(tc, nls_cwsik.getFormattedMessage(
                                                          "DELIVERY_ERROR_SIRC_20", // USER_NOT_AUTH_SEND_ERROR_CWSIP0308
                                                          new Object[] { destination.getName(),
                                                                        secContext.getDiscriminator(),
                                                                        secContext.getUserName(true) },
                                                          null));

            // Thrown if user denied access to discriminator
            SIMPNotAuthorizedException e = new SIMPNotAuthorizedException(
                            nls_cwsik.getFormattedMessage(
                                                          "DELIVERY_ERROR_SIRC_20", // USER_NOT_AUTH_SEND_ERROR_CWSIP0308
                                                          new Object[] { destination.getName(),
                                                                        secContext.getDiscriminator(),
                                                                        secContext.getUserName(true) },
                                                          null));

            e.setExceptionReason(SIRCConstants.SIRC0020_USER_NOT_AUTH_SEND_ERROR);
            e.setExceptionInserts(new String[] { destination.getName(),
                                                secContext.getDiscriminator(),
                                                secContext.getUserName(true) });
            throw e;
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "checkDestinationAccess");
    }
445457
public boolean destinationExists(String destinationName)
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) 
      SibTr.entry(tc, "destinationExists", destinationName);

    boolean returnVal = false;
    
    try
    {
      returnVal = 
        destinationManager.destinationExists(destinationName, 
                                             messageProcessor.getMessagingEngineBus());
    }
    catch (SIMPNullParameterException e)
    {
      // No FFDC code needed
    }
     
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) 
      SibTr.exit(tc, "destinationExists", new Boolean(returnVal));
      
    return returnVal;
  }
795293
def check(self, radl):
        """"""

        SIMPLE_FEATURES = {
            "host": (str, None),
            "credentials.username": (str, None),
            "credentials.password": (str, None),
            "credentials.private_key": (str, None)
        }
        self.check_simple(SIMPLE_FEATURES, radl)

        if not self.getHost():
            raise RADLParseException("Ansible host must have a host", line=self.line)
        (username, password, private_key) = self.getCredentialValues()
        if not username:
            raise RADLParseException("Ansible host must have a credentials.username", line=self.line)
        if not password and not private_key:
            raise RADLParseException("Ansible host must have a credentials.password or credentials.private_key",
                                     line=self.line)
17958
boolean checkCredentials() {


		if(!httpPut)
		{
			if (token.equals(CONFIG_TOKEN) || token.equals(""))
			{
				//Check if set in an environment variable, used with PaaS providers
				String envToken = getEnvVar( CONFIG_TOKEN);

				if (envToken == ""){
					dbg(INVALID_TOKEN);
					return false;
				}

				this.setToken(envToken);
			}

			return checkValidUUID(this.getToken());
		}else{
			if ( !checkValidUUID(this.getKey()) || this.getLocation().equals(""))
				return false;

			return true;
		}
	}
1060255
def ssl_credentials
      return :this_port_is_insecure unless options.fetch(:use_ssl, Gruf.use_ssl)

      private_key = File.read(options.fetch(:ssl_key_file, Gruf.ssl_key_file))
      cert_chain = File.read(options.fetch(:ssl_crt_file, Gruf.ssl_crt_file))
      certs = [nil, [{ private_key: private_key, cert_chain: cert_chain }], false]
      GRPC::Core::ServerCredentials.new(*certs)
    end
153241
def _connectionEstablished(self, transport):
        ''''''
        self.transport = transport
        self.transport.writeOpen()
        self.heartbeater.schedule()
1177843
def ensure_local_destination(creds, spec, dry_run):
        # type: (blobxfer.operations.azure.StorageCredentials,
        #        blobxfer.models.download.Specification, bool) -> None
        
        # ensure destination path is writable given the source
        if len(spec.sources) < 1:
            raise RuntimeError('no sources to download from specified')
        # set is_dir for destination
        spec.destination.is_dir = True
        if len(spec.sources) == 1:
            # we need to query the source to see if this is a directory
            rpath = str(spec.sources[0].paths[0])
            cont, dir = blobxfer.util.explode_azure_path(rpath)
            if not blobxfer.util.is_none_or_empty(dir):
                sa = creds.get_storage_account(
                    spec.sources[0].lookup_storage_account(rpath))
                # ensure at least read permissions
                if not sa.can_read_object:
                    raise RuntimeError(
                        'unable to prepare for remote path {} as credential '
                        'for storage account {} does not permit read '
                        'access'.format(rpath, sa.name))
                if (spec.options.mode ==
                        blobxfer.models.azure.StorageModes.File):
                    if (blobxfer.operations.azure.file.check_if_single_file(
                            sa.file_client, cont, dir)[0] and
                            spec.options.rename):
                        spec.destination.is_dir = False
                else:
                    if (blobxfer.operations.azure.blob.check_if_single_blob(
                            sa.block_blob_client, cont, dir) and
                            spec.options.rename):
                        spec.destination.is_dir = False
        logger.debug('dest is_dir={} for {} specs'.format(
            spec.destination.is_dir, len(spec.sources)))
        # ensure destination path
        if not dry_run:
            spec.destination.ensure_path_exists()
689014
def _ensure_connection(self):
        """"""
        conn = self.connect()
        if conn.recycle and conn.recycle < time.time():
            logger.debug('Client session expired after %is. Recycling.', self._recycle)
            self.close()
            conn = self.connect()
        return conn
570321
private boolean validate(PooledTransport transport) {
        try {
            Response response = transport.execute(validationRequest);
            return response.hasSucceeded();
        } catch (IOException ioe) {
            log.warn("Could not validate pooled connection on lease. Releasing pooled connection and trying again...", ioe);
            return false;
        }
    }