congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
HttpMessageContext.responseUnauthorized
Code IndexAdd Tabnine to your IDE (free)

How to use
responseUnauthorized
method
in
javax.security.enterprise.authentication.mechanism.http.HttpMessageContext

Best Java code snippets using javax.security.enterprise.authentication.mechanism.http.HttpMessageContext.responseUnauthorized (Showing top 8 results out of 315)

origin: javax/javaee-web-api

@Override
public AuthenticationStatus responseUnauthorized() {
  return getWrapped().responseUnauthorized();
}
origin: javax.security.enterprise/javax.security.enterprise-api

@Override
public AuthenticationStatus responseUnauthorized() {
  return getWrapped().responseUnauthorized();
}
origin: jakarta.security.enterprise/jakarta.security.enterprise-api

@Override
public AuthenticationStatus responseUnauthorized() {
  return getWrapped().responseUnauthorized();
}
origin: jboss/jboss-javaee-specs

@Override
public AuthenticationStatus responseUnauthorized() {
  return getWrapped().responseUnauthorized();
}
origin: javaee-samples/javaee8-samples

  return context.responseUnauthorized();
} else if (token != null) {
  return context.responseUnauthorized();
origin: javaee-samples/javaee8-samples

/**
 * To validate the JWT token e.g Signature check, JWT claims
 * check(expiration) etc
 *
 * @param token The JWT access tokens
 * @param context
 * @return the AuthenticationStatus to notify the container
 */
private AuthenticationStatus validateToken(String token, HttpMessageContext context) {
  try {
    if (tokenProvider.validateToken(token)) {
      JWTCredential credential = tokenProvider.getCredential(token);
      return context.notifyContainerAboutLogin(credential.getPrincipal(), credential.getAuthorities());
    }
    // if token invalid, response with unauthorized status
    return context.responseUnauthorized();
  } catch (ExpiredJwtException eje) {
    LOGGER.log(Level.INFO, "Security exception for user {0} - {1}", new String[]{eje.getClaims().getSubject(), eje.getMessage()});
    return context.responseUnauthorized();
  }
}
origin: javaee/security-soteria

@Override
public AuthenticationStatus validateRequest(HttpServletRequest request, HttpServletResponse response, HttpMessageContext httpMsgContext) throws AuthenticationException {
  String[] credentials = getCredentials(request);
  if (!isEmpty(credentials)) {
    IdentityStoreHandler identityStoreHandler = CDI.current().select(IdentityStoreHandler.class).get();
    CredentialValidationResult result = identityStoreHandler.validate(
        new UsernamePasswordCredential(credentials[0], new Password(credentials[1])));
    if (result.getStatus() == VALID) {
      return httpMsgContext.notifyContainerAboutLogin(
        result.getCallerPrincipal(), result.getCallerGroups());
    }
  }
  if (httpMsgContext.isProtected()) {
    response.setHeader("WWW-Authenticate", format("Basic realm=\"%s\"", basicAuthenticationMechanismDefinition.realmName()));
    return httpMsgContext.responseUnauthorized();
  }
  return httpMsgContext.doNothing();
}
origin: org.glassfish.soteria/javax.security.enterprise

@Override
public AuthenticationStatus validateRequest(HttpServletRequest request, HttpServletResponse response, HttpMessageContext httpMsgContext) throws AuthenticationException {
  String[] credentials = getCredentials(request);
  if (!isEmpty(credentials)) {
    IdentityStoreHandler identityStoreHandler = CDI.current().select(IdentityStoreHandler.class).get();
    CredentialValidationResult result = identityStoreHandler.validate(
        new UsernamePasswordCredential(credentials[0], new Password(credentials[1])));
    if (result.getStatus() == VALID) {
      return httpMsgContext.notifyContainerAboutLogin(
        result.getCallerPrincipal(), result.getCallerGroups());
    }
  }
  if (httpMsgContext.isProtected()) {
    response.setHeader("WWW-Authenticate", format("Basic realm=\"%s\"", basicAuthenticationMechanismDefinition.realmName()));
    return httpMsgContext.responseUnauthorized();
  }
  return httpMsgContext.doNothing();
}
javax.security.enterprise.authentication.mechanism.httpHttpMessageContextresponseUnauthorized

Javadoc

Sets the response status to 401 (unauthorized).

As a convenience this method returns SEND_FAILURE, so this method can be used in one fluent return statement from an HttpAuthenticationMechanism

Popular methods of HttpMessageContext

  • doNothing
    Instructs the container to "do nothing". When intending to do nothing, a JSR 375 authentication mech
  • getRequest
    Returns the request object associated with the current request.
  • getResponse
    Returns the response object associated with the current request.
  • isProtected
    Checks if the currently requested resource is protected or not. A protected resource is a resource (
  • notifyContainerAboutLogin
    Convenience method intended to pass the CredentialValidationResult result of an identity store direc
  • forward
    Forwards to another resource (servlet, JSP file, or HTML file) on the server. As a convenience this
  • getAuthParameters
    Returns the parameters that were provided with the SecurityContext#authenticate(AuthParameters) call
  • getCallerPrincipal
    Gets the Principal set by a call to notifyContainerAboutLogin().
  • getClientSubject
    Returns the subject for which authentication is to take place.Note: This is a low level object that
  • getGroups
    Gets the groups set by a call to notifyContainerAboutLogin().
  • getHandler
    Returns the low level JSR 196 handler that the runtime provided when creating this HttpMessageContex
  • getMessageInfo
    Returns the the low level JSR 196 message info instance for the current request.Note: This is a low
  • getHandler,
  • getMessageInfo,
  • isAuthenticationRequest,
  • redirect,
  • withRequest,
  • cleanClientSubject,
  • isRegisterSession,
  • responseNotFound,
  • setRegisterSession

Popular in Java

  • Parsing JSON documents to java classes using gson
  • scheduleAtFixedRate (Timer)
  • getResourceAsStream (ClassLoader)
  • startActivity (Activity)
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • Top plugins for WebStorm
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