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

How to use
AuthenticationException
in
ca.uhn.fhir.rest.server.exceptions

Best Java code snippets using ca.uhn.fhir.rest.server.exceptions.AuthenticationException (Showing top 6 results out of 315)

origin: jamesagnew/hapi-fhir

public void basicAuthInterceptorRealm() {
 //START SNIPPET: basicAuthInterceptorRealm
 AuthenticationException ex = new AuthenticationException();
 ex.addAuthenticateHeaderForRealm("myRealm");
 throw ex;
 //END SNIPPET: basicAuthInterceptorRealm
}
origin: jamesagnew/hapi-fhir

/**
 * Adds a <code>WWW-Authenticate</code> header to the response, of the form:<br/>
 * <code>WWW-Authenticate: Basic realm="theRealm"</code> 
 * 
 * @return Returns a reference to <code>this</code> for easy method chaining
 */
public AuthenticationException addAuthenticateHeaderForRealm(String theRealm) {
  addResponseHeader("WWW-Authenticate", "Basic realm=\"" + theRealm + "\"");
  return this;
}
origin: jamesagnew/hapi-fhir

throw new AuthenticationException("Missing or invalid Authorization header");
throw new AuthenticationException("Invalid username or password");
origin: jamesagnew/hapi-fhir

/**
 * This method must be overridden to provide the list of compartments
 * and/or resources that the current user should have access to
 */
@Override
protected AuthorizedList buildAuthorizedList(RequestDetails theRequestDetails) {
  // Process authorization header - The following is a fake
  // implementation. Obviously we'd want something more real
  // for a production scenario.
  //
  // In this basic example we have two hardcoded bearer tokens,
  // one which is for a user that has access to one patient, and
  // another that has full access.
  String authHeader = theRequestDetails.getHeader("Authorization");
  if ("Bearer dfw98h38r".equals(authHeader)) {
    // This user will have access to two compartments
    return new AuthorizedList()
      .addCompartment("Patient/123")
      .addCompartment("Patient/456");
  } else if ("Bearer 39ff939jgg".equals(authHeader)) {
    // This user has access to everything
    return new AuthorizedList();
  } else {
    throw new AuthenticationException("Unknown bearer token");
  }
}
origin: jamesagnew/hapi-fhir

} else {
 throw new AuthenticationException("Missing or invalid Authorization header value");
origin: ca.uhn.hapi.fhir/hapi-fhir-base

/**
 * Adds a <code>WWW-Authenticate</code> header to the response, of the form:<br/>
 * <code>WWW-Authenticate: Basic realm="theRealm"</code> 
 * 
 * @return Returns a reference to <code>this</code> for easy method chaining
 */
public AuthenticationException addAuthenticateHeaderForRealm(String theRealm) {
  addResponseHeader("WWW-Authenticate", "Basic realm=\"" + theRealm + "\"");
  return this;
}
ca.uhn.fhir.rest.server.exceptionsAuthenticationException

Javadoc

Represents an HTTP 401 Client Unauthorized response, which means that the client needs to provide credentials, or has provided invalid credentials.

For security failures, you should use AuthenticationException if you want to indicate that the user could not be authenticated (e.g. credential failures), also known as an authentication failure. You should use ForbiddenOperationException if you want to indicate that the authenticated user does not have permission to perform the requested operation, also known as an authorization failure.

Note that a complete list of RESTful exceptions is available in the Package Summary.

Most used methods

  • <init>
  • addAuthenticateHeaderForRealm
    Adds a WWW-Authenticate header to the response, of the form: WWW-Authenticate: Basic realm="theRealm
  • addResponseHeader

Popular in Java

  • Updating database using SQL prepared statement
  • compareTo (BigDecimal)
  • getExternalFilesDir (Context)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • Pattern (java.util.regex)
    Patterns are compiled regular expressions. In many cases, convenience methods such as String#matches
  • IOUtils (org.apache.commons.io)
    General IO stream manipulation utilities. This class provides static utility methods for input/outpu
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • Github Copilot alternatives
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