-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce the amount of converter injections in controllers (#514)
- Reimplements the way converters are injected into beans using converter registries - Simplifies controller implementations by using new base controller classes - Merges backup models into a single version per entity type (cert/key/secret) - Updates affected test cases Resolves #506 {minor} Signed-off-by: Esta Nagy <[email protected]>
- Loading branch information
Showing
144 changed files
with
2,933 additions
and
1,726 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
lowkey-vault-app/src/main/java/com/github/nagyesta/lowkeyvault/context/ApiVersionAware.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.github.nagyesta.lowkeyvault.context; | ||
|
||
import com.github.nagyesta.lowkeyvault.model.common.ApiConstants; | ||
|
||
import java.util.Set; | ||
import java.util.SortedSet; | ||
import java.util.TreeSet; | ||
|
||
public interface ApiVersionAware { | ||
|
||
/** | ||
* Supported API version collection containing only 7.2. | ||
*/ | ||
SortedSet<String> V7_2 = new TreeSet<>(Set.of(ApiConstants.V_7_2)); | ||
/** | ||
* Supported API version collection containing only 7.3. | ||
*/ | ||
SortedSet<String> V7_3 = new TreeSet<>(Set.of(ApiConstants.V_7_3)); | ||
/** | ||
* Supported API version collection containing both 7.2 and 7.3. | ||
*/ | ||
SortedSet<String> V7_2_AND_V7_3 = new TreeSet<>(Set.of(ApiConstants.V_7_2, ApiConstants.V_7_3)); | ||
|
||
SortedSet<String> supportedVersions(); | ||
} |
59 changes: 59 additions & 0 deletions
59
.../main/java/com/github/nagyesta/lowkeyvault/context/CertificateConverterConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.github.nagyesta.lowkeyvault.context; | ||
|
||
import com.github.nagyesta.lowkeyvault.mapper.common.registry.CertificateConverterRegistry; | ||
import com.github.nagyesta.lowkeyvault.mapper.v7_3.certificate.*; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.DependsOn; | ||
|
||
@Configuration | ||
public class CertificateConverterConfiguration { | ||
|
||
@Bean | ||
public CertificateConverterRegistry certificateConverterRegistry() { | ||
return new CertificateConverterRegistry(); | ||
} | ||
|
||
@Bean | ||
public CertificateEntityToV73PropertiesModelConverter certificatePropertiesConverter() { | ||
return new CertificateEntityToV73PropertiesModelConverter(certificateConverterRegistry()); | ||
} | ||
|
||
@Bean | ||
@DependsOn("certificatePropertiesConverter") | ||
public CertificateEntityToV73ModelConverter certificateModelConverter() { | ||
return new CertificateEntityToV73ModelConverter(certificateConverterRegistry()); | ||
} | ||
|
||
@Bean | ||
@DependsOn("certificatePropertiesConverter") | ||
public CertificateEntityToV73CertificateItemModelConverter certificateItemConverter() { | ||
return new CertificateEntityToV73CertificateItemModelConverter(certificateConverterRegistry()); | ||
} | ||
|
||
@Bean | ||
@DependsOn("certificatePropertiesConverter") | ||
public CertificateEntityToV73CertificateVersionItemModelConverter certificateVersionedItemConverter() { | ||
return new CertificateEntityToV73CertificateVersionItemModelConverter(certificateConverterRegistry()); | ||
} | ||
|
||
@Bean | ||
public CertificateEntityToV73PolicyModelConverter certificatePolicyConverter() { | ||
return new CertificateEntityToV73PolicyModelConverter(certificateConverterRegistry()); | ||
} | ||
|
||
@Bean | ||
public CertificateEntityToV73IssuancePolicyModelConverter certificateIssuancePolicyConverter() { | ||
return new CertificateEntityToV73IssuancePolicyModelConverter(certificateConverterRegistry()); | ||
} | ||
|
||
@Bean | ||
public CertificateEntityToV73PendingCertificateOperationModelConverter certificatePendingOperationConverter() { | ||
return new CertificateEntityToV73PendingCertificateOperationModelConverter(certificateConverterRegistry()); | ||
} | ||
|
||
@Bean | ||
public CertificateLifetimeActionsPolicyToV73ModelConverter certificateLifetimeActionConverter() { | ||
return new CertificateLifetimeActionsPolicyToV73ModelConverter(certificateConverterRegistry()); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
...-app/src/main/java/com/github/nagyesta/lowkeyvault/context/KeyConverterConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.github.nagyesta.lowkeyvault.context; | ||
|
||
import com.github.nagyesta.lowkeyvault.mapper.common.registry.KeyConverterRegistry; | ||
import com.github.nagyesta.lowkeyvault.mapper.v7_2.key.*; | ||
import com.github.nagyesta.lowkeyvault.mapper.v7_3.key.KeyRotationPolicyToV73ModelConverter; | ||
import com.github.nagyesta.lowkeyvault.mapper.v7_3.key.KeyRotationPolicyV73ModelToEntityConverter; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.DependsOn; | ||
|
||
@Configuration | ||
public class KeyConverterConfiguration { | ||
|
||
@Bean | ||
public KeyConverterRegistry keyConverterRegistry() { | ||
return new KeyConverterRegistry(); | ||
} | ||
|
||
@Bean | ||
public KeyEntityToV72PropertiesModelConverter keyPropertiesConverter() { | ||
return new KeyEntityToV72PropertiesModelConverter(keyConverterRegistry()); | ||
} | ||
|
||
@Bean | ||
@DependsOn("keyPropertiesConverter") | ||
public KeyEntityToV72ModelConverter keyModelConverter() { | ||
return new KeyEntityToV72ModelConverter(keyConverterRegistry()); | ||
} | ||
|
||
@Bean | ||
@DependsOn("keyPropertiesConverter") | ||
public KeyEntityToV72KeyItemModelConverter keyItemConverter() { | ||
return new KeyEntityToV72KeyItemModelConverter(keyConverterRegistry()); | ||
} | ||
|
||
@Bean | ||
@DependsOn("keyPropertiesConverter") | ||
public KeyEntityToV72KeyVersionItemModelConverter keyVersionedItemConverter() { | ||
return new KeyEntityToV72KeyVersionItemModelConverter(keyConverterRegistry()); | ||
} | ||
|
||
@Bean | ||
@DependsOn("keyPropertiesConverter") | ||
public KeyEntityToV72BackupConverter keyBackupConverter() { | ||
return new KeyEntityToV72BackupConverter(keyConverterRegistry()); | ||
} | ||
|
||
@Bean | ||
public KeyRotationPolicyToV73ModelConverter keyRotationPolicyModelConverter() { | ||
return new KeyRotationPolicyToV73ModelConverter(keyConverterRegistry()); | ||
} | ||
|
||
@Bean | ||
public KeyRotationPolicyV73ModelToEntityConverter keyRotationPolicyEntityConverter() { | ||
return new KeyRotationPolicyV73ModelToEntityConverter(keyConverterRegistry()); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
...p/src/main/java/com/github/nagyesta/lowkeyvault/context/SecretConverterConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.github.nagyesta.lowkeyvault.context; | ||
|
||
import com.github.nagyesta.lowkeyvault.mapper.common.registry.SecretConverterRegistry; | ||
import com.github.nagyesta.lowkeyvault.mapper.v7_2.secret.*; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.DependsOn; | ||
|
||
@Configuration | ||
public class SecretConverterConfiguration { | ||
|
||
@Bean | ||
public SecretConverterRegistry secretConverterRegistry() { | ||
return new SecretConverterRegistry(); | ||
} | ||
|
||
@Bean | ||
public SecretEntityToV72PropertiesModelConverter secretPropertiesConverter() { | ||
return new SecretEntityToV72PropertiesModelConverter(secretConverterRegistry()); | ||
} | ||
|
||
@Bean | ||
@DependsOn("secretPropertiesConverter") | ||
public SecretEntityToV72ModelConverter secretModelConverter() { | ||
return new SecretEntityToV72ModelConverter(secretConverterRegistry()); | ||
} | ||
|
||
@Bean | ||
@DependsOn("secretPropertiesConverter") | ||
public SecretEntityToV72SecretItemModelConverter secretItemConverter() { | ||
return new SecretEntityToV72SecretItemModelConverter(secretConverterRegistry()); | ||
} | ||
|
||
@Bean | ||
@DependsOn("secretPropertiesConverter") | ||
public SecretEntityToV72SecretVersionItemModelConverter secretVersionedItemConverter() { | ||
return new SecretEntityToV72SecretVersionItemModelConverter(secretConverterRegistry()); | ||
} | ||
|
||
@Bean | ||
@DependsOn("secretPropertiesConverter") | ||
public SecretEntityToV72BackupConverter secretBackupConverter() { | ||
return new SecretEntityToV72BackupConverter(secretConverterRegistry()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.