@Override
    public Optional<Credential> getPrimaryCredential() {
        return Objects.requireNonNull(credentials).stream().findFirst();
    }
This is {@link DefaultAuthenticationTransaction}.

@author Misagh Moayyed
@since 4.2.0
core/cas-server-core-authentication-api/src/main/java/org/apereo/cas/authentication/DefaultAuthenticationTransaction.java