Create a {@link Genomics} stub using a credential.

@param credential The credential to be used for requests.
@return The new {@code Genomics} stub
184118
public Genomics fromCredential(Credential credential) {
    Preconditions.checkNotNull(credential);
    return fromCredential(getGenomicsBuilder(), credential).build();
  }
552421
private StandardCredentials createCredentials(@Nonnull String serverAPIUrl,
                                                  final StandardCredentials credentials) {
        URI serverUri = URI.create(defaultIfBlank(serverAPIUrl, GITHUB_URL));

        List<DomainSpecification> specifications = asList(
                new SchemeSpecification(serverUri.getScheme()),
                new HostnameSpecification(serverUri.getHost(), null)
        );

        final Domain domain = new Domain(serverUri.getHost(), "GitHub domain (autogenerated)", specifications);
        ACL.impersonate(ACL.SYSTEM, new Runnable() { // do it with system rights
            @Override
            public void run() {
                try {
                    new SystemCredentialsProvider.StoreImpl().addDomain(domain, credentials);
                } catch (IOException e) {
                    LOGGER.error("Can't add creds for domain", e);
                }
            }
        });

        return credentials;
    }
779003
public static Credential getServiceAccountCredential(String serviceAccountId,
      String privateKeyFile) throws GeneralSecurityException, IOException {
    return getServiceAccountCredential(serviceAccountId, privateKeyFile, DatastoreOptions.SCOPES);
  }
884484
public static Credential credential(
      AccessTokenProviderClassFromConfigFactory providerClassFactory,
      Configuration config,
      Collection<String> scopes)
      throws IOException, GeneralSecurityException {
    Class<? extends AccessTokenProvider> clazz =
        providerClassFactory.getAccessTokenProviderClass(config);
    if (clazz != null) {
      logger.atFine().log("Using AccessTokenProvider (%s)", clazz.getName());
      try {
        AccessTokenProvider accessTokenProvider = clazz.getDeclaredConstructor().newInstance();
        accessTokenProvider.setConf(config);
        return getCredentialFromAccessTokenProvider(accessTokenProvider, scopes);
      } catch (ReflectiveOperationException ex) {
        throw new IOException("Can't instantiate " + clazz.getName(), ex);
      }
    }
    return null;
  }
531314
private MongoCredential createCredentail(String userName, String database, String password) {
		if (StrUtil.hasEmpty(userName, database, database)) {
			return null;
		}
		return MongoCredential.createCredential(userName, database, password.toCharArray());
	}
1044262
def create_credentials(credentials_file=None,
                       service_email=None,
                       service_key=None,
                       scope='https://www.googleapis.com/auth/androidpublisher'):
    
    credentials = None
    if service_email is None and service_key is None:
        print(credentials_file)
        if credentials_file is None:
            # try load file from env
            key = 'PLAY_DELIVER_CREDENTIALS'
            if key in os.environ:
                credentials_file = os.environ[key]

        if credentials_file is None:
            # try to find the file in home
            path = os.path.expanduser('~/.playdeliver/credentials.json')
            if os.path.exists(path):
                credentials_file = path

        if credentials_file is not None:
            credentials = client.GoogleCredentials.from_stream(
                credentials_file)
            credentials = credentials.create_scoped(scope)
        else:
            sys.exit("no credentials")
    else:
        credentials = client.SignedJwtAssertionCredentials(
            service_email, _load_key(service_key), scope=scope)
    return credentials
1104511
public OvhApplication api_credential_credentialId_application_GET(Long credentialId) throws IOException {
		String qPath = "/me/api/credential/{credentialId}/application";
		StringBuilder sb = path(qPath, credentialId);
		String resp = exec(qPath, "GET", sb.toString(), null);
		return convertTo(resp, OvhApplication.class);
	}
336639
public X509Credential createCredential(X509Certificate[] certs, PrivateKey privateKey, int bits, int lifetime,
        GSIConstants.CertificateType certType) throws GeneralSecurityException {
        return createCredential(certs, privateKey, bits, lifetime, certType, (X509ExtensionSet) null, null);
    }
370502
public static OAuth2Credentials createOAuth2Credentials(SessionConfiguration sessionConfiguration) throws Exception {




        // Store the users OAuth2 credentials in their home directory.
        File credentialDirectory =
                new File(System.getProperty("user.home") + File.separator + ".uber_credentials");
        credentialDirectory.setReadable(true, true);
        credentialDirectory.setWritable(true, true);
        // If you'd like to store them in memory or in a DB, any DataStoreFactory can be used.
        AbstractDataStoreFactory dataStoreFactory = new FileDataStoreFactory(credentialDirectory);

        // Build an OAuth2Credentials object with your secrets.
        return new OAuth2Credentials.Builder()
                .setCredentialDataStoreFactory(dataStoreFactory)
                .setRedirectUri(sessionConfiguration.getRedirectUri())
                .setClientSecrets(sessionConfiguration.getClientId(), sessionConfiguration.getClientSecret())
                .build();
    }
361826
public static StubTransformer fixedCredentialsStubTransformer(final CallCredentials credentials) {
        requireNonNull(credentials, "credentials");
        return (name, stub) -> stub.withCallCredentials(credentials);
    }
340637
public CredentialResolver build() throws IOException, GeneralSecurityException {
        final KeyStore ks = KeyStore.getInstance(type);
        try (InputStream is = open()) {
            ks.load(is, password != null ? password.toCharArray() : null);
        }
        return new KeyStoreCredentialResolver(ks, keyPasswords);
    }
502406
public Authentication build(final UserProfile profile,
                                final OAuthRegisteredService registeredService,
                                final J2EContext context,
                                final Service service) {

        val profileAttributes = CoreAuthenticationUtils.convertAttributeValuesToMultiValuedObjects(profile.getAttributes());
        val newPrincipal = this.principalFactory.createPrincipal(profile.getId(), profileAttributes);
        LOGGER.debug("Created final principal [{}] after filtering attributes based on [{}]", newPrincipal, registeredService);

        val authenticator = profile.getClass().getCanonicalName();
        val metadata = new BasicCredentialMetaData(new BasicIdentifiableCredential(profile.getId()));
        val handlerResult = new DefaultAuthenticationHandlerExecutionResult(authenticator, metadata, newPrincipal, new ArrayList<>());
        val scopes = CollectionUtils.toCollection(context.getRequest().getParameterValues(OAuth20Constants.SCOPE));

        val state = StringUtils.defaultIfBlank(context.getRequestParameter(OAuth20Constants.STATE), StringUtils.EMPTY);
        val nonce = StringUtils.defaultIfBlank(context.getRequestParameter(OAuth20Constants.NONCE), StringUtils.EMPTY);
        LOGGER.debug("OAuth [{}] is [{}], and [{}] is [{}]", OAuth20Constants.STATE, state, OAuth20Constants.NONCE, nonce);

        /*
         * pac4j UserProfile.getPermissions() and getRoles() returns UnmodifiableSet which Jackson Serializer
         * happily serializes to json but is unable to deserialize.
         * We have to transform those to HashSet to avoid such a problem
         */
        return DefaultAuthenticationBuilder.newInstance()
            .addAttribute("permissions", new LinkedHashSet<>(profile.getPermissions()))
            .addAttribute("roles", new LinkedHashSet<>(profile.getRoles()))
            .addAttribute("scopes", scopes)
            .addAttribute(OAuth20Constants.STATE, state)
            .addAttribute(OAuth20Constants.NONCE, nonce)
            .addAttribute(OAuth20Constants.CLIENT_ID, registeredService.getClientId())
            .addCredential(metadata)
            .setPrincipal(newPrincipal)
            .setAuthenticationDate(ZonedDateTime.now(ZoneOffset.UTC))
            .addSuccess(profile.getClass().getCanonicalName(), handlerResult)
            .build();
    }
1151461
func (api *CloudAPI) Credential(args params.Entities) (params.CloudCredentialResults, error) {
	results := params.CloudCredentialResults{
		Results: make([]params.CloudCredentialResult, len(args.Entities)),
	}
	authFunc, err := api.getCredentialsAuthFunc()
	if err != nil {
		return results, err
	}

	for i, arg := range args.Entities {
		credentialTag, err := names.ParseCloudCredentialTag(arg.Tag)
		if err != nil {
			results.Results[i].Error = common.ServerError(err)
			continue
		}
		if !authFunc(credentialTag.Owner()) {
			results.Results[i].Error = common.ServerError(common.ErrPerm)
			continue
		}

		// Helper to look up and cache credential schemas for clouds.
		schemaCache := make(map[string]map[cloud.AuthType]cloud.CredentialSchema)
		credentialSchemas := func() (map[cloud.AuthType]cloud.CredentialSchema, error) {
			cloudName := credentialTag.Cloud().Id()
			if s, ok := schemaCache[cloudName]; ok {
				return s, nil
			}
			aCloud, err := api.backend.Cloud(cloudName)
			if err != nil {
				return nil, err
			}
			provider, err := environs.Provider(aCloud.Type)
			if err != nil {
				return nil, err
			}
			schema := provider.CredentialSchemas()
			schemaCache[cloudName] = schema
			return schema, nil
		}
		cloudCredentials, err := api.backend.CloudCredentials(credentialTag.Owner(), credentialTag.Cloud().Id())
		if err != nil {
			results.Results[i].Error = common.ServerError(err)
			continue
		}

		cred, ok := cloudCredentials[credentialTag.Id()]
		if !ok {
			results.Results[i].Error = common.ServerError(errors.NotFoundf("credential %q", credentialTag.Name()))
			continue
		}

		schemas, err := credentialSchemas()
		if err != nil {
			results.Results[i].Error = common.ServerError(err)
			continue
		}

		attrs := cred.Attributes
		var redacted []string
		// Mask out the secrets.
		if s, ok := schemas[cloud.AuthType(cred.AuthType)]; ok {
			for _, attr := range s {
				if attr.Hidden {
					delete(attrs, attr.Name)
					redacted = append(redacted, attr.Name)
				}
			}
		}
		results.Results[i].Result = &params.CloudCredential{
			AuthType:   cred.AuthType,
			Attributes: attrs,
			Redacted:   redacted,
		}
	}
	return results, nil
}
831437
@Override
    public Subject createHashtableInSubject(String username) throws AuthenticationException {
        CallerOnlyCredential credential = new CallerOnlyCredential(username);
        return createHashtableInSubject(credential);
    }
1252545
public ICredentialRepository getCredentialRepository()
    {
        if (this.credentialRepositorySearched) return this.credentialRepository;

        this.credentialRepositorySearched = true;

        ServiceLoader<ICredentialRepository> loader =
                ServiceLoader.load(ICredentialRepository.class);

        //noinspection LoopStatementThatDoesntLoop
        for (ICredentialRepository repository : loader)
        {
            this.credentialRepository = repository;
            break;
        }

        return this.credentialRepository;
    }
889123
private void setCredential(Subject subject, WSPrincipal principal) throws CredentialException {
        String securityName = principal.getName();
        Hashtable<String, ?> customProperties = getUniqueIdHashtableFromSubject(subject);
        if (customProperties == null || customProperties.isEmpty()) {
            UserRegistryService urService = userRegistryServiceRef.getService();
            if (urService != null) {
                String urType = urService.getUserRegistryType();
                if ("WIM".equalsIgnoreCase(urType) || "LDAP".equalsIgnoreCase(urType)) {
                    try {
                        securityName = urService.getUserRegistry().getUserDisplayName(securityName);
                    } catch (Exception e) {
                        //do nothing
                    }
                }
            }
        }
        if (securityName == null || securityName.length() == 0) {
            securityName = principal.getName();
        }
        String accessId = principal.getAccessId();

        String customRealm = null;
        String realm = null;
        String uniqueName = null;

        if (customProperties != null) {
            customRealm = (String) customProperties.get(AttributeNameConstants.WSCREDENTIAL_REALM);
        }

        if (customRealm != null) {
            realm = customRealm;
            String[] parts = accessId.split(realm + "/");
            if (parts != null && parts.length == 2)
                uniqueName = parts[1];
        } else {
            realm = AccessIdUtil.getRealm(accessId);
            uniqueName = AccessIdUtil.getUniqueId(accessId);
        }
        if (AccessIdUtil.isServerAccessId(accessId)) {
            // Create a server WSCredential
            setCredential(null, subject, realm, securityName, uniqueName, null, accessId, null, null);
        } else {
            CredentialsService cs = credentialsServiceRef.getService();
            String unauthenticatedUserid = cs.getUnauthenticatedUserid();

            if (securityName != null && unauthenticatedUserid != null &&
                securityName.equals(unauthenticatedUserid)) {
                // Create an unauthenticated WSCredential
                setCredential(unauthenticatedUserid, subject, realm, securityName, uniqueName, null, null, null, null);
            } else if (AccessIdUtil.isUserAccessId(accessId)) {
                // Create a user WSCredential
                createUserWSCredential(subject, securityName, accessId, realm, uniqueName, unauthenticatedUserid);
            }
        }
    }
580631
public Genomics fromApiKey(String apiKey) {
    Preconditions.checkNotNull(apiKey);
    return fromApiKey(getGenomicsBuilder(), apiKey).build();
  }