Skip to content

Commit c4b09d8

Browse files
committed
Add Optional UserID to DefectDojo Config
1 parent 1e4f033 commit c4b09d8

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/main/java/io/securecodebox/persistence/defectdojo/config/DefectDojoConfig.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import lombok.AllArgsConstructor;
2121
import lombok.Getter;
2222

23+
import java.util.Optional;
24+
2325
@AllArgsConstructor
2426
public class DefectDojoConfig {
2527
@Getter
@@ -37,15 +39,28 @@ public class DefectDojoConfig {
3739
@Getter
3840
private final int maxPageCountForGets;
3941

42+
/**
43+
* If not null, the id should be used instead of the username.
44+
*/
45+
@Getter
46+
private final Integer userId;
47+
48+
public DefectDojoConfig(String url, String apiKey, String username, int maxPageCountForGets) {
49+
this(url,apiKey,username, maxPageCountForGets, null);
50+
}
51+
4052
public static DefectDojoConfig fromEnv(){
4153
String url = System.getenv("DEFECTDOJO_URL");
4254
String username = System.getenv("DEFECTDOJO_USERNAME");
4355
String apiKey = System.getenv("DEFECTDOJO_APIKEY");
56+
Integer userId = Optional.ofNullable(System.getenv("DEFECTDOJO_USER_ID"))
57+
.map(Integer::parseInt)
58+
.orElse(null);
4459

4560
int maxPageCountForGets = 100;
4661
if (System.getenv("DEFECTDOJO_MAX_PAGE_COUNT_FOR_GETS") != null) {
4762
maxPageCountForGets = Integer.parseInt(System.getenv("DEFECTDOJO_MAX_PAGE_COUNT_FOR_GETS"));
4863
}
49-
return new DefectDojoConfig(url, apiKey, username, maxPageCountForGets);
64+
return new DefectDojoConfig(url, apiKey, username, maxPageCountForGets, userId);
5065
}
5166
}

0 commit comments

Comments
 (0)