congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
Username.isAnonymous
Code IndexAdd Tabnine to your IDE (free)

How to use
isAnonymous
method
in
com.thoughtworks.go.server.domain.Username

Best Java code snippets using com.thoughtworks.go.server.domain.Username.isAnonymous (Showing top 3 results out of 315)

origin: gocd/gocd

public void checkNonAnonymousUser(Request req, Response res) {
  if (currentUsername().isAnonymous()) {
    throw renderForbiddenResponse();
  }
}
origin: gocd/gocd

  @Override
  protected void doFilterInternal(HttpServletRequest request,
                  HttpServletResponse response,
                  FilterChain filterChain) throws ServletException, IOException {
    final AuthenticationToken<?> authentication = SessionUtils.getAuthenticationToken(request);
    final Set<GrantedAuthority> authorities = authentication.getUser().getAuthorities();

    if (authorityVerifier.hasAnyAuthorityMatching(authorities)) {
      LOGGER.debug("User {} authorized to access {}", authentication.getUser().getUsername(), request.getRequestURI());
      filterChain.doFilter(request, response);
    } else {
      LOGGER.debug("User {} not authorized to access {}: has authorities {}", authentication.getUser().getUsername(), request.getRequestURI(), authentication.getUser().getAuthorities());
      if (SessionUtils.getCurrentUser().asUsernameObject().isAnonymous()) {
        requestHandler.handle(request, response, SC_UNAUTHORIZED, "You are not authenticated!");
      } else {
        requestHandler.handle(request, response, SC_FORBIDDEN, "You are not authorized to access this resource!");
      }
    }
  }
}
origin: gocd/gocd

  private User getUser(HttpServletRequest request) {
    Long userId = SessionUtils.getUserId(request);
    if (userId == null) {
      final GoUserPrinciple currentUser = SessionUtils.getCurrentUser();

      Username userName = new Username(currentUser.getUsername());

      if (userName.isAnonymous() || userName.isGoAgentUser()) {
        return new NullUser();
      }

      return userService.findUserByName(CaseInsensitiveString.str(userName.getUsername()));
    } else {
      return userService.load(userId);
    }
  }
}
com.thoughtworks.go.server.domainUsernameisAnonymous

Popular methods of Username

  • getUsername
  • <init>
  • equals
  • getDisplayName
  • valueOf
  • hashCode
  • isGoAgentUser

Popular in Java

  • Updating database using SQL prepared statement
  • setScale (BigDecimal)
  • runOnUiThread (Activity)
  • onRequestPermissionsResult (Fragment)
  • InputStreamReader (java.io)
    A class for turning a byte stream into a character stream. Data read from the source input stream is
  • DecimalFormat (java.text)
    A concrete subclass of NumberFormat that formats decimal numbers. It has a variety of features desig
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • Runner (org.openjdk.jmh.runner)
  • 14 Best Plugins for Eclipse
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