-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds leia-common module and moved all validation utils
- Loading branch information
Gunda Abhishek
committed
Nov 29, 2024
1 parent
ae6eeff
commit 5da6e95
Showing
26 changed files
with
454 additions
and
233 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
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
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
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,92 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Copyright (c) 2024. Koushik R <[email protected]>. | ||
~ | ||
~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
~ you may not use this file except in compliance with the License. | ||
~ You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
--> | ||
|
||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>com.grookage.leia</groupId> | ||
<artifactId>leia-parent</artifactId> | ||
<version>0.0.1-RC7</version> | ||
<relativePath>../leia-parent</relativePath> | ||
</parent> | ||
|
||
<artifactId>leia-common</artifactId> | ||
|
||
<properties> | ||
<lang3.version>3.11</lang3.version> | ||
<maven.deploy.skip>false</maven.deploy.skip> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<artifactId>lombok</artifactId> | ||
<groupId>org.projectlombok</groupId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.commons</groupId> | ||
<artifactId>commons-lang3</artifactId> | ||
<version>${lang3.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<artifactId>junit-jupiter</artifactId> | ||
<groupId>org.junit.jupiter</groupId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.grookage.leia</groupId> | ||
<artifactId>leia-models</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<artifactId>mockito-core</artifactId> | ||
<groupId>org.mockito</groupId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<artifactId>mockito-junit-jupiter</artifactId> | ||
<groupId>org.mockito</groupId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<artifactId>mockito-inline</artifactId> | ||
<groupId>org.mockito</groupId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.grookage.leia</groupId> | ||
<artifactId>leia-models</artifactId> | ||
<type>test-jar</type> | ||
<exclusions> | ||
<exclusion> | ||
<artifactId>*</artifactId> | ||
<groupId>*</groupId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
|
||
|
||
</dependencies> | ||
|
||
</project> |
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
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
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
55 changes: 55 additions & 0 deletions
55
leia-common/src/main/java/com/grookage/leia/common/utils/QualifierUtils.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,55 @@ | ||
package com.grookage.leia.common.utils; | ||
|
||
import com.grookage.leia.models.annotations.qualifiers.Encrypted; | ||
import com.grookage.leia.models.annotations.qualifiers.PII; | ||
import com.grookage.leia.models.annotations.qualifiers.ShortLived; | ||
import com.grookage.leia.models.qualifiers.EncryptedQualifier; | ||
import com.grookage.leia.models.qualifiers.PIIQualifier; | ||
import com.grookage.leia.models.qualifiers.QualifierInfo; | ||
import com.grookage.leia.models.qualifiers.ShortLivedQualifier; | ||
import lombok.experimental.UtilityClass; | ||
|
||
import java.lang.reflect.Field; | ||
import java.lang.reflect.Type; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
@UtilityClass | ||
public class QualifierUtils { | ||
public Set<QualifierInfo> getQualifierInfo(Type type) { | ||
if (type instanceof Class<?> klass) { | ||
return getQualifierInfo(klass); | ||
} | ||
return new HashSet<>(); | ||
} | ||
|
||
public Set<QualifierInfo> getQualifierInfo(Field field) { | ||
Set<QualifierInfo> qualifierInfos = new HashSet<>(); | ||
if (field.isAnnotationPresent(Encrypted.class)) { | ||
qualifierInfos.add(new EncryptedQualifier()); | ||
} | ||
if (field.isAnnotationPresent(PII.class)) { | ||
qualifierInfos.add(new PIIQualifier()); | ||
} | ||
if (field.isAnnotationPresent(ShortLived.class)) { | ||
final var shortLived = field.getAnnotation(ShortLived.class); | ||
qualifierInfos.add(new ShortLivedQualifier(shortLived.ttlSeconds())); | ||
} | ||
return qualifierInfos; | ||
} | ||
|
||
public Set<QualifierInfo> getQualifierInfo(Class<?> klass) { | ||
Set<QualifierInfo> qualifierInfos = new HashSet<>(); | ||
if (klass.isAnnotationPresent(Encrypted.class)) { | ||
qualifierInfos.add(new EncryptedQualifier()); | ||
} | ||
if (klass.isAnnotationPresent(PII.class)) { | ||
qualifierInfos.add(new PIIQualifier()); | ||
} | ||
if (klass.isAnnotationPresent(ShortLived.class)) { | ||
final var shortLived = klass.getAnnotation(ShortLived.class); | ||
qualifierInfos.add(new ShortLivedQualifier(shortLived.ttlSeconds())); | ||
} | ||
return qualifierInfos; | ||
} | ||
} |
Oops, something went wrong.