com.yubico.webauthn.CredentialRepositoryV1ToV2Adapter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of webauthn-server-core Show documentation
Show all versions of webauthn-server-core Show documentation
Yubico WebAuthn server core API
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 extends ToPublicKeyCredentialDescriptor> 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);
}
}