Requires that the calling Subject be authenticated before allowing access.
544552
def requires_authentication(fn):
        

        @functools.wraps(fn)
        def wrap(*args, **kwargs):
            subject = WebYosai.get_current_subject()

            if not subject.authenticated:
                msg = "The current Subject is not authenticated.  ACCESS DENIED."
                raise WebYosai.get_current_webregistry().raise_unauthorized(msg)

            return fn(*args, **kwargs)
        return wrap
793657
public static boolean isUnauthenticated(Subject subject) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            SibTr.entry(tc, CLASS_NAME + "isUnauthenticated", subject);
        }
        boolean result = subjectHelper.isUnauthenticated(subject);
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            SibTr.exit(tc, CLASS_NAME + "isUnauthenticated", result);
        }
        return result;
    }
1048412
function(req, user){
      req.session.authenticated = true;
      req.session.user = user;
    }
857457
private void verifyPermission(Subject subject, String permission)
            throws UnauthorizedException {
        if (!subject.hasPermission(permission)) {
            throw new UnauthorizedException();
        }
    }
665014
protected void authenticateConnection (AuthingConnection conn)
    {
        Authenticator author = _author;
        for (ChainedAuthenticator cauthor : _authors) {
            if (cauthor.shouldHandleConnection(conn)) {
                author = cauthor;
                break;
            }
        }

        author.authenticateConnection(_authInvoker, conn, new ResultListener<AuthingConnection>() {
            public void requestCompleted (AuthingConnection conn) {
                _authq.append(conn);
            }
            public void requestFailed (Exception cause) {
                // this never happens
            }
        });
    }
1107536
def http_auth_required(realm):
    """"""

    def decorator(fn):
        @wraps(fn)
        def wrapper(*args, **kwargs):
            if _check_http_auth():
                return fn(*args, **kwargs)
            if _security._unauthorized_callback:
                return _security._unauthorized_callback()
            else:
                r = _security.default_http_auth_realm \
                    if callable(realm) else realm
                h = {'WWW-Authenticate': 'Basic realm="%s"' % r}
                return _get_unauthorized_response(headers=h)
        return wrapper

    if callable(realm):
        return decorator(realm)
    return decorator
909502
private boolean setUnauthenticatedSubjectIfNeeded(Subject invokedSubject, Subject receivedSubject) {
        if ((invokedSubject == null) && (receivedSubject == null)) {
            // create the unauthenticated subject and set as the invocation subject
            subjectManager.setInvocationSubject(unauthenticatedSubjectServiceRef.getService().getUnauthenticatedSubject());
            return true;
        }
        return false;
    }
796931
private Subject authenticateWithCertificateChain(SSLSession session) throws SSLPeerUnverifiedException, AuthenticationException, CredentialExpiredException, CredentialDestroyedException {
        Subject transportSubject = null;
        if (session != null) {
            Certificate[] certificateChain = session.getPeerCertificates();
            transportSubject = authenticator.authenticate((X509Certificate[]) certificateChain);
            /* Here we need to get the WSCredential from the subject. We will use the subject manager for the same. */
            SubjectHelper subjectHelper = new SubjectHelper();
            WSCredential wsCredential = subjectHelper.getWSCredential(transportSubject);
            /*
             * First we tell the WSCredential that the identity token is in the form of a certificate chain. This is
             * done by setting the property "wssecurity.identity_name" to "ClientCertificate"
             */
            wsCredential.set(Constants.IDENTITY_NAME, Constants.ClientCertificate);
            /*
             * Now we need to put the certificate chain into the WScredential object. By doing this, we
             * make sure that, the authenticated certificates are indeed part of the credential. This credential
             * can be used further down the CSIv2 flow. The certificate is set as a name value pair, with the name
             * "wssecurity.identity_value"
             */
            wsCredential.set(Constants.IDENTITY_VALUE, certificateChain);
        }
        return transportSubject;
    }
306405
def requires_api_auth(fn):
    """"""
    def wrapper(self, *args, **kwargs):
        self.auth_context = HAPI.auth_context_hapi
        return fn(self, *args, **kwargs)
    return wrapper
593760
private void throwAuthzException() throws SecurityException {
        SubjectManager subjectManager = new SubjectManager();
        String name = "UNAUTHENTICATED";
        if (subjectManager.getInvocationSubject() != null) {
            name = subjectManager.getInvocationSubject().getPrincipals().iterator().next().getName();
        }
        Tr.audit(tc, "MANAGEMENT_SECURITY_AUTHZ_FAILED", name, "MBeanAccess", requiredRoles);
        String message = Tr.formatMessage(tc, "MANAGEMENT_SECURITY_AUTHZ_FAILED", name, "MBeanAccess", requiredRoles);
        throw new SecurityException(message);
    }
1003625
private String authenticate(Credentials credentials, URI requestURI) throws AuthenticationException {
        if (!(credentials instanceof SpnegoCredentials)) {
            throw new AuthenticationException("Invalid credentials type provided to " + this.getClass().getName() + "." +
                    "Expected " + SpnegoCredentials.class.getName() + " but got " + credentials.getClass().getName());
        }
        final SpnegoCredentials spnegoCredentials = (SpnegoCredentials) credentials;
        try {
            initializeNegotiator(requestURI, spnegoCredentials);
            return getNegotiateToken();
        } catch (GSSException e) {
            throw new AuthenticationException("Could not authenticate", e);
        } catch (UnknownHostException e) {
            throw new AuthenticationException("Could not authenticate", e);
        }
    }
1223905
public boolean authenticate(HttpServletRequest pRequest) {
        String auth = pRequest.getHeader("Authorization");
        if (auth == null) {
            return false;
        }
        AuthorizationHeaderParser.Result authInfo = AuthorizationHeaderParser.parse(auth);
        return authInfo.isValid() && doAuthenticate(pRequest, authInfo);
    }
663072
function (context, authenticationRequest, callback) {
            //
            var authProvider = this.getAuthenticationProviderForRequest(authenticationRequest);

            if (authProvider) {
                flow()
                    .seq("authentication", function (cb) {
                        // authenticate
                        authProvider.authenticate(authenticationRequest, cb);
                    })
                    .seq(function (cb) {
                        // init authentication
                        this.vars.authentication.init(cb);
                    })
                    .exec(function (err, results) {
                        var authentication = results.authentication;
                        if (!err && authentication) {
                            context.user.addAuthentication(authentication);
                        }
                        // return authentication with user id
                        callback(err, authentication);
                    })
            } else {
                callback(AuthenticationError.NO_PROVIDER_FOUND, null);
            }
        }
420713
def authenticate(self, provider=None, identifier=None):
        ""
        provider_q = Q(provider__name=provider)
        if isinstance(provider, Provider):
            provider_q = Q(provider=provider)
        try:
            access = AccountAccess.objects.filter(
                provider_q, identifier=identifier
            ).select_related('user')[0]
        except IndexError:
            return None
        else:
            return access.user
811682
private void requestAuthorization(HttpServletResponse resp) throws IOException {

        // Authorisation is required for the requested action.
        resp.setHeader(CmsRequestUtil.HEADER_WWW_AUTHENTICATE, "Basic realm=\"" + BASIC_REALM + "\"");

        resp.sendError(HttpServletResponse.SC_UNAUTHORIZED);
    }
1212074
public boolean isUnauthenticated(Subject subject) {
        if (subject == null) {
            return true;
        }

        WSCredential wsCred = getWSCredential(subject);
        if (wsCred == null) {
            return true;
        } else {
            return wsCred.isUnauthenticated();
        }
    }
804825
@Override
    public Object preInvoke() throws SecurityViolationException {
        Subject invokedSubject = subjectManager.getInvocationSubject();
        Subject receivedSubject = subjectManager.getCallerSubject();

        subjectManager.clearSubjects();

        return null;
    }