Authenticate with asserted user.

@param assertedUser
@return The authenticated subject.
@throws AuthenticationException
554025
@Override
    public Subject authenticate(String assertedUser) throws AuthenticationException {
        AuthenticateUserHelper authHelper = new AuthenticateUserHelper();
        return authHelper.authenticateUser(authenticationService, assertedUser, jaasEntryName);
    }
589109
@Override
    public Subject authenticate(@Sensitive X509Certificate[] certificateChain) throws AuthenticationException {
        AuthenticationData authenticationData = createAuthenticationData(certificateChain);
        return authenticationService.authenticate(jaasEntryName, authenticationData, null);
    }
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;
    }
1352697
protected Assertion buildCasAssertion(final Authentication authentication,
                                          final Service service,
                                          final RegisteredService registeredService,
                                          final Map<String, List<Object>> attributesToCombine) {
        val attributes = registeredService.getAttributeReleasePolicy().getAttributes(authentication.getPrincipal(), service, registeredService);
        val principalId = registeredService.getUsernameAttributeProvider().resolveUsername(authentication.getPrincipal(), service, registeredService);
        val principal = new AttributePrincipalImpl(principalId, (Map) attributes);
        val authnAttrs = new LinkedHashMap<>(authentication.getAttributes());
        authnAttrs.putAll(attributesToCombine);
        return new AssertionImpl(principal, DateTimeUtils.dateOf(authentication.getAuthenticationDate()),
            null, DateTimeUtils.dateOf(authentication.getAuthenticationDate()),
            (Map) authnAttrs);
    }
256277
@PUT
  @Path("{user}")
  @Consumes(MediaType.TEXT_PLAIN)
  public Response addUser(@PathParam("user") String username, @HeaderParam("Authorization") @DefaultValue("no token") String auth, String message) throws Exception {
    if(!this.isAuth(auth)) {
      throw new Exception("Unauthorized!");
    }
    if( realm != null ){
      AuthenticationManagerRequest req = new AuthenticationManagerRequest();
      req.setAccountName(username);
      req.setPassword(message);
      req.setRequestType(RequestType.ADD);
      
      sendMessage(req);
      return Response.created(new URI("")).build();
    }
    return Response.status(Status.NOT_FOUND).build();
  }
792349
public function authenticate(RequestInterface $request)
    {
        $token = $this->token();

        if (!$token && !$this->findMatchingArea($request)) {
            return $this;
        }

        if (!$token) {
            throw new AuthenticationException('Unable to authenticate, token is missing');
        }

        foreach ($this->providers as $provider) {
            if (!$provider->supportsToken($token)) {
                continue;
            }

            if (!$provider->authenticate($token)) {
                $this->stash()
                     ->destroy();

                throw new AuthenticationException(sprintf('Token could not be authenticated in provider "%s", destroying token', get_class($provider)));
            }

            $this->user = $provider->get($token);

            return $this;
        }

        $this->stash()
             ->destroy();

        throw new AuthenticationException(sprintf('Missing provider supporting token "%s", destroying token', get_class($token)));
    }
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);
        }
    }
1042216
protected Account authenticate(String username, String password) {
        StandardCredentials authenticationToken = new StandardCredentials(username, password);
        Account account = securityManager.authenticate(authenticationToken);
        return account;
    }
738074
@Override
    public Builder subject(String username) throws InvalidClaimException {
        if (username != null && !username.isEmpty()) {

            claims.put(Claims.SUBJECT, username);
        } else {
            String err = Tr.formatMessage(tc, "JWT_INVALID_CLAIM_VALUE_ERR", new Object[] { Claims.SUBJECT, username });
            throw new InvalidClaimException(err);
        }
        return this;
    }
953990
public static Authenticator createPersonaAuthenticator(String assertion) {
        Map<String, String> params = new HashMap<String, String>();
        params.put("assertion", assertion);
        return new TokenAuthenticator("_persona", params);
    }
1253254
protected IAuthorizationPrincipal getPrincipalForUser(final IPerson person) {
        final EntityIdentifier ei = person.getEntityIdentifier();
        return AuthorizationServiceFacade.instance().newPrincipal(ei.getKey(), ei.getType());
    }
1021064
protected SubjectLocality buildSubjectLocality(final Object assertion, final RequestAbstractType authnRequest,
                                                   final SamlRegisteredServiceServiceProviderMetadataFacade adaptor,
                                                   final String binding) throws SamlException {
        val subjectLocality = newSamlObject(SubjectLocality.class);
        val hostAddress = InetAddressUtils.getCasServerHostAddress(casProperties.getServer().getName());
        val issuer = SamlIdPUtils.getIssuerFromSamlObject(authnRequest);
        LOGGER.debug("Built subject locality address [{}] for the saml authentication statement prepped for [{}]", hostAddress, issuer);
        subjectLocality.setAddress(hostAddress);
        return subjectLocality;
    }
1108620
protected function getSubjectFromUser(IUser $user, ICredential $credential) : ISubject
    {
        $userId = $user->getId();
        $roles = $this->roleRepository->getRoleNamesForSubject($userId);

        return new Subject([new Principal(PrincipalTypes::PRIMARY, $userId, $roles)], [$credential]);
    }
643217
public Authorizable getOrCreateUser(JackrabbitSession session, UserManager userManager,
                                        String path, boolean systemUser)
            throws RepositoryException {
        String[] pathAndName = pathAndName(path);
        Authorizable user = userManager.getAuthorizable(pathAndName[1]);
        LOG.debug("user.check: " + pathAndName[1] + " - " + user);
        if (user == null) {
            LOG.info("user.create: " + pathAndName[1]);
            Principal principal = new NamePrincipal(pathAndName[1]);
            if (systemUser) {
                try {
                    // using reflection to create systems users for compatibility to older API versions
                    Method createSystemUser = userManager.getClass().getMethod("createSystemUser", String.class, String.class);
                    user = (User) createSystemUser.invoke(userManager, pathAndName[1], pathAndName[0]);
                } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
                    LOG.error(ex.toString());
                }
            } else {
                user = userManager.createUser(pathAndName[1], pathAndName[1],
                        principal, pathAndName[0]);
            }
        }
        return user;
    }
367852
@Override
    public synchronized void authenticate() throws PortalSecurityException {
        if (this.remoteUser != null) {
            // Set the UID for the principal
            this.myPrincipal.setUID(this.remoteUser);

            // Check that the principal UID matches the remote user
            final String newUid = this.myPrincipal.getUID();

            if (this.remoteUser.equals(newUid)) {
                if (log.isInfoEnabled()) {
                    log.info("Authentication REMOTE_USER(" + this.remoteUser + ").");
                }

                this.isauth = true;
            } else if (log.isInfoEnabled()) {
                log.info(
                        "Authentication failed. REMOTE_USER("
                                + this.remoteUser
                                + ") != user("
                                + newUid
                                + ").");
            }
        } else if (log.isInfoEnabled()) {
            log.info(
                    "Authentication failed. REMOTE_USER not set for("
                            + this.myPrincipal.getUID()
                            + ").");
        }

        super.authenticate();
        return;
    }
452414
private boolean setUnauthenticatedSubjectIfNeeded(Subject invokedSubject, Subject receivedSubject) {
        if ((invokedSubject == null) && (receivedSubject == null)) {
            // create the unauthenticated subject and set as the invocation subject
            SubjectManager sm = new SubjectManager();
            sm.setInvocationSubject(unauthenticatedSubjectService.getUnauthenticatedSubject());
            return true;
        }
        return false;
    }
1284308
@Override
    public Subject createHashtableInSubject(String username, @Sensitive String password) throws AuthenticationException {
        UsernamePasswordCredential credential = new UsernamePasswordCredential(username, password);
        return createHashtableInSubject(credential);
    }