code: public static boolean isValidAuthentication(Authentication authentication) {
      if (authentication == null) {
        return false;
      }
  
      // if UserDetails are set then it must be of Class OwncloudUserDetails
      if (authentication.getDetails() != null && !ClassUtils.isAssignable(authentication.getPrincipal().getClass(), OwncloudUserDetails.class)) {
        return false;
      }
  
      if (authentication.getCredentials() != null) {
        // if Credentials are available then these must be of Class CharSequence and not empty
        return CharSequence.class.isAssignableFrom(authentication.getCredentials().getClass()) &&
            StringUtils.isNotBlank((CharSequence) authentication.getCredentials());
      }
  
      if (authentication.getPrincipal() != null) {
        // Password of the UserDetails must not be empty
        UserDetails userDetails = (UserDetails) authentication.getPrincipal();
        return StringUtils.isNotBlank(userDetails.getPassword());
      }
  
      return false;
    }
docs: Checks, if the given Authentication Object is authenticated
  by the Owncloud{Rest|Local}AuthenticationProvider
  @param authentication Authentication Object
  @return is authenticated by the Owncloud{Rest|Local}AuthenticationProvider