congrats Icon
New! Announcing our next generation AI code completions
Read here
Tabnine Logo
DefaultUGIProvider
Code IndexAdd Tabnine to your IDE (free)

How to use
DefaultUGIProvider
in
co.cask.cdap.security.impersonation

Best Java code snippets using co.cask.cdap.security.impersonation.DefaultUGIProvider (Showing top 4 results out of 315)

origin: cdapio/cdap

private void verifyCaching(DefaultUGIProvider provider, ImpersonationRequest aliceImpRequest,
              ImpersonationRequest bobImpRequest, UGIWithPrincipal aliceUGIWithPrincipal,
              UGIWithPrincipal bobUGIWithPrincipal) throws IOException {
 // Fetch the bob UGI again, it should still return the valid one
 Assert.assertSame(bobUGIWithPrincipal, provider.getConfiguredUGI(bobImpRequest));
 // Invalid the cache, getting of Alice UGI should pass, while getting of Bob should fails
 provider.invalidCache();
 Assert.assertNotSame(aliceUGIWithPrincipal, provider.getConfiguredUGI(aliceImpRequest));
 try {
  provider.getConfiguredUGI(bobImpRequest);
  Assert.fail("Expected IOException when getting UGI for " + bobImpRequest);
 } catch (IOException e) {
  // Expected
 }
}
origin: cdapio/cdap

 new File(keytabURI.getPath()) : localizeKeytab(locationFactory.create(keytabURI));
try {
 String expandedPrincipal = SecurityUtil.expandPrincipal(impersonationRequest.getPrincipal());
origin: cdapio/cdap

DefaultUGIProvider provider = new DefaultUGIProvider(cConf, locationFactory, ownerAdmin, namespaceClient);
UGIWithPrincipal eveUGIWithPrincipal = provider.getConfiguredUGI(bobImpRequest);
Assert.assertEquals(UserGroupInformation.AuthenticationMethod.KERBEROS,
          eveUGIWithPrincipal.getUGI().getAuthenticationMethod());
origin: cdapio/cdap

@Test
public void testDefaultUGIProviderWithHDFSFiles() throws Exception {
 // create a location on hdfs for keytabs
 Location hdfsKeytabDir = locationFactory.create("keytabs");
 // set in the cConf so that later it can be used to fetch the keytabs for the given principal
 setKeytabDir(hdfsKeytabDir.toURI().toString());
 Location aliceRemoteKeytabFile = copyFileToHDFS(hdfsKeytabDir, aliceKeytabFile);
 Location bobRemoteKeytabFile = copyFileToHDFS(hdfsKeytabDir, bobKeytabFile);
 OwnerAdmin ownerAdmin = getOwnerAdmin();
 DefaultUGIProvider provider = new DefaultUGIProvider(cConf, locationFactory, ownerAdmin, namespaceClient);
 // add some entity owners
 ownerAdmin.add(aliceEntity, aliceKerberosPrincipalId);
 ownerAdmin.add(bobEntity, bobKerberosPrincipalId);
 // Try with keytab file on hdfs
 ImpersonationRequest aliceImpRequest = new ImpersonationRequest(aliceEntity, ImpersonatedOpType.OTHER);
 ImpersonationRequest bobImpRequest = new ImpersonationRequest(bobEntity, ImpersonatedOpType.OTHER);
 UGIWithPrincipal aliceUGIWithPrincipal = verifyAndGetUGI(provider, aliceKerberosPrincipalId, aliceImpRequest);
 UGIWithPrincipal bobUGIWithPrincipal = verifyAndGetUGI(provider, bobKerberosPrincipalId, bobImpRequest);
 // delete bob's keytab file on hdfs
 Assert.assertTrue(bobRemoteKeytabFile.delete());
 // verify caching by ensuring that we are able to fetch bob's ugi even after delete but not after invalidating the
 // cache
 verifyCaching(provider, aliceImpRequest, bobImpRequest, aliceUGIWithPrincipal, bobUGIWithPrincipal);
 // cleanup
 ownerAdmin.delete(aliceEntity);
 ownerAdmin.delete(bobEntity);
}
co.cask.cdap.security.impersonationDefaultUGIProvider

Javadoc

Provides a UGI by logging in with a keytab file for that user.

Most used methods

  • <init>
  • getConfiguredUGI
  • invalidCache
  • localizeKeytab
    Returns the path to a keytab file, after copying it to the local file system, if necessary

Popular in Java

  • Start an intent from android
  • scheduleAtFixedRate (Timer)
  • onCreateOptionsMenu (Activity)
  • getResourceAsStream (ClassLoader)
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • TimerTask (java.util)
    The TimerTask class represents a task to run at a specified time. The task may be run once or repeat
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
  • Top 17 PhpStorm Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now