Tabnine Logo
ImpersonationInfo
Code IndexAdd Tabnine to your IDE (free)

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

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

origin: cdapio/cdap

 public Map<String, String> getSystemProperties(Id.Program id) throws IOException, NamespaceNotFoundException {
  Map<String, String> systemArgs = Maps.newHashMap();
  systemArgs.put(Constants.CLUSTER_NAME, cConf.get(Constants.CLUSTER_NAME, ""));
  systemArgs.put(Constants.AppFabric.APP_SCHEDULER_QUEUE, queueResolver.getQueue(id.getNamespace()));
  if (SecurityUtil.isKerberosEnabled(cConf)) {
   ImpersonationInfo impersonationInfo = SecurityUtil.createImpersonationInfo(ownerAdmin, cConf, id.toEntityId());
   systemArgs.put(ProgramOptionConstants.PRINCIPAL, impersonationInfo.getPrincipal());
   systemArgs.put(ProgramOptionConstants.APP_PRINCIPAL_EXISTS,
           String.valueOf(ownerAdmin.exists(id.toEntityId().getParent())));
  }
  return systemArgs;
 }
}
origin: cdapio/cdap

/**
 * This has the logic to construct an impersonation info as follows:
 * <ul>
 * <li>If the ownerAdmin has an owner and a keytab URI, return this information</li>
 * <li>Else the ownerAdmin does not have an owner for this entity.
 * Return the master impersonation info as found in the cConf</li>
 * </ul>
 */
public static ImpersonationInfo createImpersonationInfo(OwnerAdmin ownerAdmin, CConfiguration cConf,
                            NamespacedEntityId entityId) throws IOException {
 ImpersonationInfo impersonationInfo = ownerAdmin.getImpersonationInfo(entityId);
 if (impersonationInfo == null) {
  return new ImpersonationInfo(getMasterPrincipal(cConf), getMasterKeytabURI(cConf));
 }
 return impersonationInfo;
}
origin: cdapio/cdap

@Override
public final UGIWithPrincipal getConfiguredUGI(ImpersonationRequest impersonationRequest) throws IOException {
 try {
  UGIWithPrincipal ugi = impersonationRequest.getImpersonatedOpType().equals(ImpersonatedOpType.EXPLORE) ||
   impersonationRequest.getPrincipal() == null ?
   null : ugiCache.getIfPresent(new UGICacheKey(impersonationRequest));
  if (ugi != null) {
   return ugi;
  }
  boolean isCache = checkExploreAndDetermineCache(impersonationRequest);
  ImpersonationInfo info = getPrincipalForEntity(impersonationRequest);
  ImpersonationRequest newRequest = new ImpersonationRequest(impersonationRequest.getEntityId(),
                                impersonationRequest.getImpersonatedOpType(),
                                info.getPrincipal(), info.getKeytabURI());
  return isCache ? ugiCache.get(new UGICacheKey(newRequest)) : createUGI(newRequest);
 } catch (ExecutionException e) {
  Throwable cause = e.getCause();
  // Propagate if the cause is an IOException or RuntimeException
  Throwables.propagateIfPossible(cause, IOException.class);
  // Otherwise always wrap it with IOException
  throw new IOException(cause);
 }
}
origin: co.cask.cdap/cdap-app-fabric

 public Map<String, String> getSystemProperties(Id.Program id) throws IOException, NamespaceNotFoundException {
  Map<String, String> systemArgs = Maps.newHashMap();
  systemArgs.put(Constants.CLUSTER_NAME, cConf.get(Constants.CLUSTER_NAME, ""));
  systemArgs.put(Constants.AppFabric.APP_SCHEDULER_QUEUE, queueResolver.getQueue(id.getNamespace()));
  if (SecurityUtil.isKerberosEnabled(cConf)) {
   ImpersonationInfo impersonationInfo = SecurityUtil.createImpersonationInfo(ownerAdmin, cConf, id.toEntityId());
   systemArgs.put(ProgramOptionConstants.PRINCIPAL, impersonationInfo.getPrincipal());
   systemArgs.put(ProgramOptionConstants.APP_PRINCIPAL_EXISTS,
           String.valueOf(ownerAdmin.exists(id.toEntityId().getParent())));
  }
  return systemArgs;
 }
}
origin: cdapio/cdap

@Nullable
@Override
public ImpersonationInfo getImpersonationInfo(NamespacedEntityId entityId) throws IOException {
 entityId = getEffectiveEntity(entityId);
 if (!entityId.getEntityType().equals(EntityType.NAMESPACE)) {
  KerberosPrincipalId effectiveOwner = ownerStore.getOwner(entityId);
  if (effectiveOwner != null) {
   return new ImpersonationInfo(effectiveOwner.getPrincipal(),
                  SecurityUtil.getKeytabURIforPrincipal(effectiveOwner.getPrincipal(), cConf));
  }
 }
 // (CDAP-8176) Since no owner was found for the entity return namespace principal if present.
 NamespaceConfig nsConfig = getNamespaceConfig(entityId.getNamespaceId());
 return nsConfig.getPrincipal() == null ? null : new ImpersonationInfo(nsConfig.getPrincipal(),
                                    nsConfig.getKeytabURI());
}
co.cask.cdap.security.impersonationImpersonationInfo

Javadoc

Encapsulates information necessary to impersonate a user - principal and keytab path.

Most used methods

  • getPrincipal
  • <init>
    Creates ImpersonationInfo using the specified principal and keytab path.
  • getKeytabURI

Popular in Java

  • Updating database using SQL prepared statement
  • setRequestProperty (URLConnection)
  • putExtra (Intent)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • JTextField (javax.swing)
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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