Codota Logo
ServiceAccountJwtAccessCredentials.getPrivateKey
Code IndexAdd Codota to your IDE (free)

How to use
getPrivateKey
method
in
com.google.auth.oauth2.ServiceAccountJwtAccessCredentials

Best Java code snippets using com.google.auth.oauth2.ServiceAccountJwtAccessCredentials.getPrivateKey (Showing top 5 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
FileOutputStream f =
  • Codota IconFile file;new FileOutputStream(file)
  • Codota IconString name;new FileOutputStream(name)
  • Codota IconFile file;new FileOutputStream(file, true)
  • Smart code suggestions by Codota
}
origin: googleapis/google-auth-library-java

@Override
public byte[] sign(byte[] toSign) {
 try {
  Signature signer = Signature.getInstance(OAuth2Utils.SIGNATURE_ALGORITHM);
  signer.initSign(getPrivateKey());
  signer.update(toSign);
  return signer.sign();
 } catch (NoSuchAlgorithmException | InvalidKeyException | SignatureException ex) {
  throw new ServiceAccountSigner.SigningException("Failed to sign the provided bytes", ex);
 }
}
origin: googleapis/gax-java

@Test
public void serviceAccountReplacedWithJwtTokens() throws Exception {
 ServiceAccountCredentials serviceAccountCredentials =
   ServiceAccountCredentials.newBuilder()
     .setClientId("fake-client-id")
     .setClientEmail("fake@example.com")
     .setPrivateKeyId("fake-private-key")
     .setPrivateKey(Mockito.mock(PrivateKey.class))
     .build();
 PowerMockito.mockStatic(GoogleCredentials.class);
 Mockito.when(GoogleCredentials.getApplicationDefault()).thenReturn(serviceAccountCredentials);
 GoogleCredentialsProvider provider =
   GoogleCredentialsProvider.newBuilder()
     .setScopesToApply(ImmutableList.of("scope1", "scope2"))
     .setJwtEnabledScopes(ImmutableList.of("scope1"))
     .build();
 Credentials credentials = provider.getCredentials();
 assertThat(credentials).isInstanceOf(ServiceAccountJwtAccessCredentials.class);
 ServiceAccountJwtAccessCredentials jwtCreds = (ServiceAccountJwtAccessCredentials) credentials;
 assertThat(jwtCreds.getClientId()).isEqualTo(serviceAccountCredentials.getClientId());
 assertThat(jwtCreds.getClientEmail()).isEqualTo(serviceAccountCredentials.getClientEmail());
 assertThat(jwtCreds.getPrivateKeyId()).isEqualTo(serviceAccountCredentials.getPrivateKeyId());
 assertThat(jwtCreds.getPrivateKey()).isEqualTo(serviceAccountCredentials.getPrivateKey());
}
origin: googleapis/google-auth-library-java

@Test 
public void constructor_allParameters_constructs() throws IOException {
 PrivateKey privateKey = ServiceAccountCredentials.privateKeyFromPkcs8(SA_PRIVATE_KEY_PKCS8);
 ServiceAccountJwtAccessCredentials credentials = ServiceAccountJwtAccessCredentials.newBuilder()
   .setClientId(SA_CLIENT_ID)
   .setClientEmail(SA_CLIENT_EMAIL)
   .setPrivateKey(privateKey)
   .setPrivateKeyId(SA_PRIVATE_KEY_ID)
   .build();
 
 assertEquals(SA_CLIENT_ID, credentials.getClientId());
 assertEquals(SA_CLIENT_EMAIL, credentials.getClientEmail());
 assertEquals(privateKey, credentials.getPrivateKey());
 assertEquals(SA_PRIVATE_KEY_ID, credentials.getPrivateKeyId());
}
origin: com.google.auth/google-auth-library-oauth2-http

@Override
public byte[] sign(byte[] toSign) {
 try {
  Signature signer = Signature.getInstance(OAuth2Utils.SIGNATURE_ALGORITHM);
  signer.initSign(getPrivateKey());
  signer.update(toSign);
  return signer.sign();
 } catch (NoSuchAlgorithmException | InvalidKeyException | SignatureException ex) {
  throw new ServiceAccountSigner.SigningException("Failed to sign the provided bytes", ex);
 }
}
origin: googleapis/google-auth-library-java

@Test
public void sign_sameAs()
  throws IOException, NoSuchAlgorithmException, InvalidKeyException, SignatureException {
 PrivateKey privateKey = ServiceAccountCredentials.privateKeyFromPkcs8(SA_PRIVATE_KEY_PKCS8);
 byte[] toSign = {0xD, 0xE, 0xA, 0xD};
 ServiceAccountJwtAccessCredentials credentials = ServiceAccountJwtAccessCredentials.newBuilder()
   .setClientId(SA_CLIENT_ID)
   .setClientEmail(SA_CLIENT_EMAIL)
   .setPrivateKey(privateKey)
   .setPrivateKeyId(SA_PRIVATE_KEY_ID)
   .build();
 byte[] signedBytes = credentials.sign(toSign);
 Signature signature = Signature.getInstance(OAuth2Utils.SIGNATURE_ALGORITHM);
 signature.initSign(credentials.getPrivateKey());
 signature.update(toSign);
 assertArrayEquals(signature.sign(), signedBytes);
}
com.google.auth.oauth2ServiceAccountJwtAccessCredentialsgetPrivateKey

Popular methods of ServiceAccountJwtAccessCredentials

  • newBuilder
  • getClientEmail
  • fromPkcs8
    Factory using PKCS#8 for the private key.
  • fromStream
    Returns credentials defined by a Service Account key file in JSON format from the Google Developers
  • getClientId
  • getPrivateKeyId
  • <init>
    Constructor with full information.
  • blockingGetToCallback
  • createCache
  • equals
  • fromJson
    Returns service account credentials defined by JSON using the format supported by the Google Develop
  • getAccount
  • fromJson,
  • getAccount,
  • getJwtAccess,
  • getRequestMetadata,
  • hashCode,
  • sign,
  • toString

Popular in Java

  • Reactive rest calls using spring rest template
  • getSharedPreferences (Context)
  • getSupportFragmentManager (FragmentActivity)
  • scheduleAtFixedRate (ScheduledExecutorService)
    Creates and executes a periodic action that becomes enabled first after the given initial delay, and
  • File (java.io)
    An "abstract" representation of a file system entity identified by a pathname. The pathname may be a
  • BitSet (java.util)
    This class implements a vector of bits that grows as needed. Each component of the bit set has a boo
  • PriorityQueue (java.util)
    An unbounded priority Queue based on a priority heap. The elements of the priority queue are ordered
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now