org.acegisecurity.Authentication.getName()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(84)

本文整理了Java中org.acegisecurity.Authentication.getName()方法的一些代码示例,展示了Authentication.getName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Authentication.getName()方法的具体详情如下:
包路径:org.acegisecurity.Authentication
类名称:Authentication
方法名:getName

Authentication.getName介绍

暂无

代码示例

代码示例来源:origin: jenkinsci/jenkins

public AccessDeniedException2(Throwable t, Authentication authentication, Permission permission) {
  super(Messages.AccessDeniedException2_MissingPermission(authentication.getName(),
      permission.group.title+"/"+permission.name), t);
  this.authentication = authentication;
  this.permission = permission;
}

代码示例来源:origin: jenkinsci/jenkins

private CLIUserDetails(Authentication auth) {
    super(auth.getName(), "", true, true, true, true, auth.getAuthorities());
  }
}

代码示例来源:origin: jenkinsci/jenkins

private UserCause(String userId, String message) {
  super(hudson.slaves.Messages._SlaveComputer_DisconnectedBy(userId != null ? userId : Jenkins.ANONYMOUS.getName(), message));
  this.userId = userId;
}

代码示例来源:origin: jenkinsci/jenkins

public RestartJenkinsJob(UpdateSite site) {
  super(site);
  this.authentication = Jenkins.getAuthentication().getName();
}

代码示例来源:origin: jenkinsci/jenkins

public UserCause() {
  this.authenticationName = Jenkins.getAuthentication().getName();
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Gets the {@link User} object representing the supplied {@link Authentication} or
 * {@code null} if the supplied {@link Authentication} is either anonymous or {@code null}
 *
 * @param a the supplied {@link Authentication} .
 * @return a {@link User} object for the supplied {@link Authentication} or {@code null}
 * @since 1.609
 */
public static @CheckForNull
User get(@CheckForNull Authentication a) {
  if (a == null || a instanceof AnonymousAuthenticationToken)
    return null;
  // Since we already know this is a name, we can just call getOrCreateById with the name directly.
  return getById(a.getName(), true);
}

代码示例来源:origin: jenkinsci/jenkins

protected int run() {
    Authentication a = Jenkins.getAuthentication();
    stdout.println("Authenticated as: "+a.getName());
    stdout.println("Authorities:");
    for (GrantedAuthority ga : a.getAuthorities()) {
      stdout.println("  "+ga.getAuthority());
    }
    return 0;
  }
}

代码示例来源:origin: jenkinsci/jenkins

@Exported
public String getName() {
  return auth().getName();
}

代码示例来源:origin: jenkinsci/jenkins

@Override
  public void run() {
    try {
      ACL.impersonate(ACL.SYSTEM);
      LOGGER.info(String.format("Shutting down VM as requested by %s from %s",
          getAuthentication().getName(), req != null ? req.getRemoteAddr() : "???"));
      cleanUp();
      System.exit(0);
    } catch (Exception e) {
      LOGGER.log(Level.WARNING, "Failed to shut down Jenkins", e);
    }
  }
}.start();

代码示例来源:origin: jenkinsci/jenkins

/**
 * Leave the information about login failure.
 *
 * <p>
 * Otherwise it seems like Acegi doesn't really leave the detail of the failure anywhere.
 */
@Override
protected void onUnsuccessfulAuthentication(HttpServletRequest request, HttpServletResponse response, AuthenticationException failed) throws IOException {
  super.onUnsuccessfulAuthentication(request, response, failed);
  LOGGER.log(Level.FINE, "Login attempt failed", failed);
  Authentication auth = failed.getAuthentication();
  if (auth != null) {
    SecurityListener.fireFailedToLogIn(auth.getName());
  }
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Logs out the user.
 */
public void doLogout( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
  String user = getAuthentication().getName();
  securityRealm.doLogout(req, rsp);
  SecurityListener.fireLoggedOut(user);
}

代码示例来源:origin: jenkinsci/jenkins

private void interrupt(Result result, boolean forShutdown) {
  Authentication a = Jenkins.getAuthentication();
  if (a == ACL.SYSTEM)
    interrupt(result, forShutdown, new CauseOfInterruption[0]);
  else {
    // worth recording who did it
    // avoid using User.get() to avoid deadlock.
    interrupt(result, forShutdown, new UserInterruption(a.getName()));
  }
}

代码示例来源:origin: jenkinsci/jenkins

@Override
public void run() {
  try {
    LOGGER.info("Starting the downgrade of "+getName()+" on behalf of "+getUser().getName());
    _run();
    LOGGER.info("Downgrade successful: "+getName());
    status = new Success();
    onSuccess();
  } catch (Throwable e) {
    LOGGER.log(Level.SEVERE, "Failed to downgrade "+getName(),e);
    status = new Failure(e);
    error = e;
  }
}

代码示例来源:origin: jenkinsci/jenkins

@Override
public void run() {
  try {
    LOGGER.info("Starting the downgrade of "+getName()+" on behalf of "+getUser().getName());
    _run();
    LOGGER.info("Downgrading successful: "+getName());
    status = new Success();
    onSuccess();
  } catch (Throwable e) {
    LOGGER.log(Level.SEVERE, "Failed to downgrade "+getName(),e);
    status = new Failure(e);
    error = e;
  }
}

代码示例来源:origin: jenkinsci/jenkins

@Override
  protected int run() throws Exception {
    ClientAuthenticationCache store = new ClientAuthenticationCache(checkChannel());

    Authentication auth = store.get();

    store.remove();

    SecurityListener.fireLoggedOut(auth.getName());

    return 0;
  }
}

代码示例来源:origin: jenkinsci/jenkins

@Override
@Nonnull
public ACL getACL() {
  ACL base = Jenkins.get().getAuthorizationStrategy().getACL(this);
  // always allow a non-anonymous user full control of himself.
  return ACL.lambda((a, permission) -> (idStrategy().equals(a.getName(), id) && !(a instanceof AnonymousAuthenticationToken))
      || base.hasPermission(a, permission));
}

代码示例来源:origin: jenkinsci/jenkins

@Override
  public boolean shouldTriggerBuild(AbstractBuild build, TaskListener listener,
                   List<Action> actions) {
    AbstractProject downstream = getDownstreamProject();
    if (Jenkins.getInstance().getItemByFullName(downstream.getFullName()) != downstream) { // this checks Item.READ also on parent folders
      LOGGER.log(Level.WARNING, "Running as {0} cannot even see {1} for trigger from {2}", new Object[] {Jenkins.getAuthentication().getName(), downstream, getUpstreamProject()});
      return false; // do not even issue a warning to build log
    }
    if (!downstream.hasPermission(Item.BUILD)) {
      listener.getLogger().println(Messages.BuildTrigger_you_have_no_permission_to_build_(ModelHyperlinkNote.encodeTo(downstream)));
      return false;
    }
    return build.getResult().isBetterOrEqualTo(threshold);
  }
});

代码示例来源:origin: jenkinsci/jenkins

@Override
protected int run() throws Exception {
  Authentication a = Jenkins.getAuthentication();
  if (a== Jenkins.ANONYMOUS)
    throw new CmdLineException("No credentials specified."); // this causes CLI to show the command line options.
  ClientAuthenticationCache store = new ClientAuthenticationCache(checkChannel());
  store.set(a);
  SecurityListener.fireLoggedIn(a.getName());
  return 0;
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * With ADMINISTER permission, can delete users with persisted data but can't delete self.
 */
public boolean canDelete() {
  final IdStrategy strategy = idStrategy();
  return hasPermission(Jenkins.ADMINISTER) && !strategy.equals(id, Jenkins.getAuthentication().getName())
      && UserIdMapper.getInstance().isMapped(id);
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Deletes this user from Hudson.
 */
@RequirePOST
public void doDoDelete(StaplerRequest req, StaplerResponse rsp) throws IOException {
  checkPermission(Jenkins.ADMINISTER);
  if (idStrategy().equals(id, Jenkins.getAuthentication().getName())) {
    rsp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Cannot delete self");
    return;
  }
  delete();
  rsp.sendRedirect2("../..");
}

相关文章