All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.yubico.webauthn.CredentialRepositoryV1ToV2Adapter Maven / Gradle / Ivy

The newest version!
package com.yubico.webauthn;

import com.yubico.webauthn.data.ByteArray;
import java.util.Collections;
import java.util.Optional;
import java.util.Set;
import lombok.AllArgsConstructor;

@AllArgsConstructor
class CredentialRepositoryV1ToV2Adapter
    implements CredentialRepositoryV2, UsernameRepository {

  private final CredentialRepository inner;

  @Override
  public Set getCredentialDescriptorsForUserHandle(
      ByteArray userHandle) {
    return inner
        .getUsernameForUserHandle(userHandle)
        .map(inner::getCredentialIdsForUsername)
        .orElseGet(Collections::emptySet);
  }

  @Override
  public Optional lookup(ByteArray credentialId, ByteArray userHandle) {
    return inner.lookup(credentialId, userHandle);
  }

  @Override
  public boolean credentialIdExists(ByteArray credentialId) {
    return !inner.lookupAll(credentialId).isEmpty();
  }

  @Override
  public Optional getUserHandleForUsername(String username) {
    return inner.getUserHandleForUsername(username);
  }

  @Override
  public Optional getUsernameForUserHandle(ByteArray userHandle) {
    return inner.getUsernameForUserHandle(userHandle);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy