Creates an instance of Azure.Authenticated that exposes subscription, tenant, and authorization API entry points.

@param credentials the credentials to use
@return the Azure.Authenticated
181160
public static Authenticated authenticate(AzureTokenCredentials credentials) {
        return new AuthenticatedImpl(new RestClient.Builder()
                .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER)
                .withCredentials(credentials)
                .withSerializerAdapter(new AzureJacksonAdapter())
                .withResponseBuilderFactory(new AzureResponseBuilder.Factory())
                .build());
    }
125505
public void setCredentials(String tenant, String username, String userpassword) {
        Credentials credentials = new Credentials(tenant, username, userpassword);
        restClient.setCredentials(credentials);
    }
507534
static ClientAssertion buildJwt(final AsymmetricKeyCredential credential,
            final String jwtAudience) throws AuthenticationException {
        if (credential == null) {
            throw new IllegalArgumentException("credential is null");
        }

        final long time = System.currentTimeMillis();

        final JWTClaimsSet claimsSet = new JWTClaimsSet.Builder()
                .audience(Collections.singletonList(jwtAudience))
                .issuer(credential.getClientId())
                .jwtID(UUID.randomUUID().toString())
                .notBeforeTime(new Date(time))
                .expirationTime(new Date(time
                                + AuthenticationConstants.AAD_JWT_TOKEN_LIFETIME_SECONDS
                                * 1000))
                .subject(credential.getClientId())
                .build();

        SignedJWT jwt;
        try {
            JWSHeader.Builder builder = new Builder(JWSAlgorithm.RS256);
            List<Base64> certs = new ArrayList<Base64>();
            certs.add(new Base64(credential.getPublicCertificate()));
            builder.x509CertChain(certs);
            builder.x509CertThumbprint(new Base64URL(credential
                    .getPublicCertificateHash()));
            jwt = new SignedJWT(builder.build(), claimsSet);
            final RSASSASigner signer = new RSASSASigner(credential.getKey());

            jwt.sign(signer);
        }
        catch (final Exception e) {
            throw new AuthenticationException(e);
        }

        return new ClientAssertion(jwt.serialize());
    }
668670
public AuthenticationBuilder setCredentials(final @NonNull List<CredentialMetaData> credentials) {
        this.credentials.clear();
        this.credentials.addAll(credentials);
        return this;
    }
433911
public static Properties readPropertiesFromCredentials(String credentials) {
        Properties props = new Properties();
        File propFD = new File(credentials);
        if (!propFD.exists() || !propFD.isFile() || !propFD.canRead()) {
            throw new IllegalArgumentException("Credentials file " + credentials + " is not a read accessible file");
        } else {
            FileReader fr = null;
            try {
                fr = new FileReader(credentials);
                props.load(fr);
            } catch (IOException e) {
                throw new IllegalArgumentException("Credential file not found or permission denied.");
            }
        }
        return props;
    }
31074
private static BasicCredentials createServiceCredentials(AuthleteConfiguration configuration)
    {
        // API key and API secret of a Service.
        String key    = configuration.getServiceApiKey();
        String secret = configuration.getServiceApiSecret();

        return new BasicCredentials(key, secret);
    }
738448
protected OAuthProviderToken createOAuthToken(ConsumerAuthentication authentication) {
    return getTokenServices().createUnauthorizedRequestToken(authentication.getConsumerDetails().getConsumerKey(),
                                                             authentication.getOAuthParameters().get(OAuthConsumerParameter.oauth_callback.toString()));
  }
798753
public static ContentModeratorClient authenticate(AzureRegionBaseUrl baseUrl, ServiceClientCredentials credentials) {
        return authenticate("https://{baseUrl}/", credentials)
                .withBaseUrl(baseUrl);
    }
336199
protected AuthenticationHandlerExecutionResult createAuthenticatedSubjectResult(final Credential credential, final Subject currentUser) {
        val username = currentUser.getPrincipal().toString();
        return createHandlerResult(credential, this.principalFactory.createPrincipal(username));
    }
684219
public Session login(Credentials credentials) throws LoginException, NoSuchWorkspaceException, RepositoryException
   {
      return delegatee.login(credentials);
   }
755068
public static Credentials getInputStreamCredential(InputStream inputStream) throws IOException {
    GoogleCredentials credentials = GoogleCredentials.fromStream(inputStream, getHttpTransportFactory());

    if (credentials instanceof ServiceAccountCredentials) {
      return getJwtToken((ServiceAccountCredentials)credentials);
    }
    return credentials.createScoped(CLOUD_BIGTABLE_ALL_SCOPES);
  }
1003625
private String authenticate(Credentials credentials, URI requestURI) throws AuthenticationException {
        if (!(credentials instanceof SpnegoCredentials)) {
            throw new AuthenticationException("Invalid credentials type provided to " + this.getClass().getName() + "." +
                    "Expected " + SpnegoCredentials.class.getName() + " but got " + credentials.getClass().getName());
        }
        final SpnegoCredentials spnegoCredentials = (SpnegoCredentials) credentials;
        try {
            initializeNegotiator(requestURI, spnegoCredentials);
            return getNegotiateToken();
        } catch (GSSException e) {
            throw new AuthenticationException("Could not authenticate", e);
        } catch (UnknownHostException e) {
            throw new AuthenticationException("Could not authenticate", e);
        }
    }
687889
@Override
   public Credential getPrefillCredential()
   {
      if (this.prefillCredential == null)
      {
         if (cm.getSubjectFactory() == null || cm.getConnectionManagerConfiguration().getSecurityDomain() == null)
         {
            prefillCredential = new Credential(null, null);
         }
         else
         {
            prefillCredential =
               new Credential(SecurityActions.createSubject(cm.getSubjectFactory(),
                                                            cm.getConnectionManagerConfiguration().getSecurityDomain(),
                                                            cm.getManagedConnectionFactory()),
                              null);
         }
      }
      return this.prefillCredential;
   }
831398
public static CredentialsProvider newProxyCredentialsProvider
    (HttpClientSettings settings) {
        final CredentialsProvider provider = new BasicCredentialsProvider();
        provider.setCredentials(newAuthScope(settings), newNTCredentials(settings));
        return provider;
    }
803170
public static Authentication login(String username, String password) {
        return new AuthenticationImpl(username, password, AuthMode.Login);
    }
1334241
public static Map<String, String> createBasicAuthenticationProperty(final String username, final String password) {
        Map<String, String> map = new TreeMap<String, String>();
        try {
            String base64Binary = DatatypeConverter.printBase64Binary((username + ":" + password).getBytes("US-ASCII"));
            map.put("Authorization", "Basic " + base64Binary);
        } catch (UnsupportedEncodingException e) {
            // unreachable code
            throw new RuntimeException(e);
        }
        return map;
    }
1240420
public static LuisRuntimeAPI authenticate(EndpointAPI endpointAPI, ServiceClientCredentials credentials) {
        return authenticate(String.format("https://%s/luis/v2.0/", endpointAPI.toString()), credentials)
            .withEndpoint(endpointAPI.toString());
    }