org.kohsuke.stapler.StaplerRequest.getUserPrincipal()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(62)

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

StaplerRequest.getUserPrincipal介绍

暂无

代码示例

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

/**
 * Called once the user logs in. Just forward to the top page.
 * Used only by {@link LegacySecurityRealm}.
 */
public void doLoginEntry( StaplerRequest req, StaplerResponse rsp ) throws IOException {
  if(req.getUserPrincipal()==null) {
    rsp.sendRedirect2("noPrincipal");
    return;
  }
  // TODO fire something in SecurityListener?
  String from = req.getParameter("from");
  if(from!=null && from.startsWith("/") && !from.equals("/loginError")) {
    rsp.sendRedirect2(from);    // I'm bit uncomfortable letting users redirected to other sites, make sure the URL falls into this domain
    return;
  }
  String url = AbstractProcessingFilter.obtainFullRequestUrl(req);
  if(url!=null) {
    // if the login redirect is initiated by Acegi
    // this should send the user back to where s/he was from.
    rsp.sendRedirect2(url);
    return;
  }
  rsp.sendRedirect2(".");
}

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

/**
 * Checks if the user was successfully authenticated.
 *
 * @see BasicAuthenticationFilter
 */
public void doSecured( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
  // TODO fire something in SecurityListener? (seems to be used only for REST calls when LegacySecurityRealm is active)
  if(req.getUserPrincipal()==null) {
    // authentication must have failed
    rsp.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
    return;
  }
  // the user is now authenticated, so send him back to the target
  String path = req.getContextPath()+req.getOriginalRestOfPath();
  String q = req.getQueryString();
  if(q!=null)
    path += '?'+q;
  rsp.sendRedirect2(path);
}

代码示例来源:origin: org.eclipse.hudson/hudson-core

/**
   * Called once the user logs in. Just forward to the top page.
   */
  public void doLoginEntry(StaplerRequest req, StaplerResponse rsp) throws IOException {
    if (req.getUserPrincipal() == null) {
      rsp.sendRedirect2("noPrincipal");
      return;
    }

    String from = req.getParameter("from");
    if (from != null && from.startsWith("/") && !from.equals("/loginError")) {
      rsp.sendRedirect2(from);    // I'm bit uncomfortable letting users redircted to other sites, make sure the URL falls into this domain
      return;
    }

    // Spring security 3.x will handle the URL redirect
//        String url = AbstractAuthenticationProcessingFilter.obtainFullSavedRequestUrl(req);
//        if (url != null) {
//            // if the login redirect is initiated by Spring Security
//            // this should send the user back to where s/he was from.
//            rsp.sendRedirect2(url);
//            return;
//        }
    rsp.sendRedirect2(".");
  }

代码示例来源:origin: hudson/hudson-2.x

/**
 * Called once the user logs in. Just forward to the top page.
 */
public void doLoginEntry(StaplerRequest req, StaplerResponse rsp) throws IOException {
  if (req.getUserPrincipal() == null) {
    rsp.sendRedirect2("noPrincipal");
    return;
  }
  String from = req.getParameter("from");
  if (from != null && from.startsWith("/") && !from.equals("/loginError")) {
    rsp.sendRedirect2(from);    // I'm bit uncomfortable letting users redircted to other sites, make sure the URL falls into this domain
    return;
  }
  String url = AbstractProcessingFilter.obtainFullRequestUrl(req);
  if (url != null) {
    // if the login redirect is initiated by Acegi
    // this should send the user back to where s/he was from.
    rsp.sendRedirect2(url);
    return;
  }
  rsp.sendRedirect2(".");
}

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

/**
 * Called once the user logs in. Just forward to the top page.
 */
public void doLoginEntry(StaplerRequest req, StaplerResponse rsp) throws IOException {
  if (req.getUserPrincipal() == null) {
    rsp.sendRedirect2("noPrincipal");
    return;
  }
  String from = req.getParameter("from");
  if (from != null && from.startsWith("/") && !from.equals("/loginError")) {
    rsp.sendRedirect2(from);    // I'm bit uncomfortable letting users redircted to other sites, make sure the URL falls into this domain
    return;
  }
  String url = AbstractProcessingFilter.obtainFullRequestUrl(req);
  if (url != null) {
    // if the login redirect is initiated by Acegi
    // this should send the user back to where s/he was from.
    rsp.sendRedirect2(url);
    return;
  }
  rsp.sendRedirect2(".");
}

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

/**
 * Called once the user logs in. Just forward to the top page.
 */
public void doLoginEntry(StaplerRequest req, StaplerResponse rsp) throws IOException {
  if (req.getUserPrincipal() == null) {
    rsp.sendRedirect2("noPrincipal");
    return;
  }
  String from = req.getParameter("from");
  if (from != null && from.startsWith("/") && !from.equals("/loginError")) {
    rsp.sendRedirect2(from);    // I'm bit uncomfortable letting users redircted to other sites, make sure the URL falls into this domain
    return;
  }
  String url = AbstractProcessingFilter.obtainFullSavedRequestUrl(req);
  if (url != null) {
    // if the login redirect is initiated by Spring Security
    // this should send the user back to where s/he was from.
    rsp.sendRedirect2(url);
    return;
  }
  rsp.sendRedirect2(".");
}

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

/**
 * Called once the user logs in. Just forward to the top page.
 * Used only by {@link LegacySecurityRealm}.
 */
public void doLoginEntry( StaplerRequest req, StaplerResponse rsp ) throws IOException {
  if(req.getUserPrincipal()==null) {
    rsp.sendRedirect2("noPrincipal");
    return;
  }
  // TODO fire something in SecurityListener?
  String from = req.getParameter("from");
  if(from!=null && from.startsWith("/") && !from.equals("/loginError")) {
    rsp.sendRedirect2(from);    // I'm bit uncomfortable letting users redirected to other sites, make sure the URL falls into this domain
    return;
  }
  String url = AbstractProcessingFilter.obtainFullRequestUrl(req);
  if(url!=null) {
    // if the login redirect is initiated by Acegi
    // this should send the user back to where s/he was from.
    rsp.sendRedirect2(url);
    return;
  }
  rsp.sendRedirect2(".");
}

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

/**
 * Checks if the user was successfully authenticated.
 *
 * @see BasicAuthenticationFilter
 */
public void doSecured( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
  // TODO fire something in SecurityListener? (seems to be used only for REST calls when LegacySecurityRealm is active)
  if(req.getUserPrincipal()==null) {
    // authentication must have failed
    rsp.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
    return;
  }
  // the user is now authenticated, so send him back to the target
  String path = req.getContextPath()+req.getOriginalRestOfPath();
  String q = req.getQueryString();
  if(q!=null)
    path += '?'+q;
  rsp.sendRedirect2(path);
}

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

/**
 * Checks if the user was successfully authenticated.
 *
 * @see BasicAuthenticationFilter
 */
public void doSecured(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
  if (req.getUserPrincipal() == null) {
    // authentication must have failed
    rsp.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
    return;
  }
  // the user is now authenticated, so send him back to the target
  String path = req.getContextPath() + req.getOriginalRestOfPath();
  String q = req.getQueryString();
  if (q != null) {
    path += '?' + q;
  }
  rsp.sendRedirect2(path);
}

代码示例来源:origin: hudson/hudson-2.x

/**
 * Checks if the user was successfully authenticated.
 *
 * @see BasicAuthenticationFilter
 */
public void doSecured(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
  if (req.getUserPrincipal() == null) {
    // authentication must have failed
    rsp.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
    return;
  }
  // the user is now authenticated, so send him back to the target
  String path = req.getContextPath() + req.getOriginalRestOfPath();
  String q = req.getQueryString();
  if (q != null) {
    path += '?' + q;
  }
  rsp.sendRedirect2(path);
}

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

/**
 * Checks if the user was successfully authenticated.
 *
 * @see BasicAuthenticationFilter
 */
public void doSecured(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
  if (req.getUserPrincipal() == null) {
    // authentication must have failed
    rsp.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
    return;
  }
  // the user is now authenticated, so send him back to the target
  String path = req.getContextPath() + req.getOriginalRestOfPath();
  String q = req.getQueryString();
  if (q != null) {
    path += '?' + q;
  }
  rsp.sendRedirect2(path);
}

代码示例来源:origin: org.eclipse.hudson/hudson-core

/**
 * Checks if the user was successfully authenticated.
 *
 * @see BasicAuthenticationFilter
 */
public void doSecured(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
  if (req.getUserPrincipal() == null) {
    // authentication must have failed
    rsp.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
    return;
  }
  // the user is now authenticated, so send him back to the target
  String path = req.getContextPath() + req.getOriginalRestOfPath();
  String q = req.getQueryString();
  if (q != null) {
    path += '?' + q;
  }
  rsp.sendRedirect2(path);
}

相关文章

微信公众号

最新文章

更多

StaplerRequest类方法