com.github.nagyesta.lowkeyvault.mapper.common.registry.KeyConverterRegistry Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lowkey-vault-app Show documentation
Show all versions of lowkey-vault-app Show documentation
Assembled application of Lowkey Vault.
package com.github.nagyesta.lowkeyvault.mapper.common.registry;
import com.github.nagyesta.lowkeyvault.mapper.common.AliasAwareConverter;
import com.github.nagyesta.lowkeyvault.mapper.common.ApiVersionAwareConverter;
import com.github.nagyesta.lowkeyvault.mapper.common.BaseEntityConverterRegistry;
import com.github.nagyesta.lowkeyvault.model.common.backup.KeyBackupList;
import com.github.nagyesta.lowkeyvault.model.common.backup.KeyBackupListItem;
import com.github.nagyesta.lowkeyvault.model.common.backup.KeyBackupModel;
import com.github.nagyesta.lowkeyvault.model.v7_2.key.*;
import com.github.nagyesta.lowkeyvault.model.v7_3.key.KeyRotationPolicyModel;
import com.github.nagyesta.lowkeyvault.service.key.ReadOnlyKeyVaultKeyEntity;
import com.github.nagyesta.lowkeyvault.service.key.ReadOnlyRotationPolicy;
import com.github.nagyesta.lowkeyvault.service.key.RotationPolicy;
import com.github.nagyesta.lowkeyvault.service.key.id.KeyEntityId;
import com.github.nagyesta.lowkeyvault.service.key.id.VersionedKeyEntityId;
import lombok.EqualsAndHashCode;
import java.net.URI;
import java.util.HashMap;
import java.util.Map;
@EqualsAndHashCode(callSuper = true)
public class KeyConverterRegistry extends BaseEntityConverterRegistry {
private final Map> rotationPolicyModelConverters =
new HashMap<>();
private final Map> rotationPolicyEntityConverters =
new HashMap<>();
@Override
public KeyEntityId entityId(final URI baseUri, final String name) {
return new KeyEntityId(baseUri, name);
}
@Override
public VersionedKeyEntityId versionedEntityId(final URI baseUri, final String name, final String version) {
return new VersionedKeyEntityId(baseUri, name, version);
}
public AliasAwareConverter rotationPolicyModelConverter(
final String apiVersion) {
return rotationPolicyModelConverters.get(apiVersion);
}
public void registerRotationPolicyModelConverter(final AliasAwareConverter converter) {
converter.supportedVersions().forEach(v -> rotationPolicyModelConverters.put(v, converter));
}
public ApiVersionAwareConverter rotationPolicyEntityConverter(
final String apiVersion) {
return rotationPolicyEntityConverters.get(apiVersion);
}
public void registerRotationPolicyEntityConverter(final ApiVersionAwareConverter converter) {
converter.supportedVersions().forEach(v -> rotationPolicyEntityConverters.put(v, converter));
}
}