@@ -116,7 +116,6 @@ public static Project convertToProject(final org.cyclonedx.model.Metadata cdxMet
116116 public static Project convertToProject (final org .cyclonedx .model .Component cdxComponent ) {
117117 final var project = new Project ();
118118 project .setBomRef (useOrGenerateRandomBomRef (cdxComponent .getBomRef ()));
119- project .setAuthor (trimToNull (cdxComponent .getAuthor ()));
120119 project .setPublisher (trimToNull (cdxComponent .getPublisher ()));
121120 project .setSupplier (convert (cdxComponent .getSupplier ()));
122121 project .setClassifier (convertClassifier (cdxComponent .getType ()).orElse (Classifier .APPLICATION ));
@@ -126,6 +125,17 @@ public static Project convertToProject(final org.cyclonedx.model.Component cdxCo
126125 project .setDescription (trimToNull (cdxComponent .getDescription ()));
127126 project .setExternalReferences (convertExternalReferences (cdxComponent .getExternalReferences ()));
128127
128+ List <OrganizationalContact > contacts = new ArrayList <>();
129+ if (cdxComponent .getAuthor ()!=null ){
130+ contacts .add (new OrganizationalContact () {{
131+ setName (cdxComponent .getAuthor ());
132+ }});
133+ }
134+ if (cdxComponent .getAuthors ()!=null ){
135+ contacts .addAll (convertCdxContacts (cdxComponent .getAuthors ()));
136+ }
137+ project .setAuthors (contacts );
138+
129139 if (cdxComponent .getPurl () != null ) {
130140 try {
131141 final var purl = new PackageURL (cdxComponent .getPurl ());
@@ -153,7 +163,6 @@ public static List<Component> convertComponents(final List<org.cyclonedx.model.C
153163 public static Component convertComponent (final org .cyclonedx .model .Component cdxComponent ) {
154164 final var component = new Component ();
155165 component .setBomRef (useOrGenerateRandomBomRef (cdxComponent .getBomRef ()));
156- component .setAuthor (trimToNull (cdxComponent .getAuthor ()));
157166 component .setPublisher (trimToNull (cdxComponent .getPublisher ()));
158167 component .setSupplier (convert (cdxComponent .getSupplier ()));
159168 component .setClassifier (convertClassifier (cdxComponent .getType ()).orElse (Classifier .LIBRARY ));
@@ -166,6 +175,17 @@ public static Component convertComponent(final org.cyclonedx.model.Component cdx
166175 component .setExternalReferences (convertExternalReferences (cdxComponent .getExternalReferences ()));
167176 component .setProperties (convertToComponentProperties (cdxComponent .getProperties ()));
168177
178+ List <OrganizationalContact > contacts = new ArrayList <>();
179+ if (cdxComponent .getAuthor ()!=null ){
180+ contacts .add (new OrganizationalContact () {{
181+ setName (cdxComponent .getAuthor ());
182+ }});
183+ }
184+ if (cdxComponent .getAuthors ()!=null ){
185+ contacts .addAll (convertCdxContacts (cdxComponent .getAuthors ()));
186+ }
187+ component .setAuthors (contacts );
188+
169189 if (cdxComponent .getPurl () != null ) {
170190 try {
171191 final var purl = new PackageURL (cdxComponent .getPurl ());
@@ -525,7 +545,7 @@ public static org.cyclonedx.model.Component convert(final QueryManager qm, final
525545 cycloneComponent .setDescription (StringUtils .trimToNull (component .getDescription ()));
526546 cycloneComponent .setCopyright (StringUtils .trimToNull (component .getCopyright ()));
527547 cycloneComponent .setCpe (StringUtils .trimToNull (component .getCpe ()));
528- cycloneComponent .setAuthor (StringUtils .trimToNull (component .getAuthor ( )));
548+ cycloneComponent .setAuthor (StringUtils .trimToNull (convertContactsToString ( component .getAuthors () )));
529549 cycloneComponent .setSupplier (convert (component .getSupplier ()));
530550 cycloneComponent .setProperties (convert (component .getProperties ()));
531551
@@ -654,6 +674,23 @@ private static <T extends IConfigProperty> List<org.cyclonedx.model.Property> co
654674 return cdxProperties ;
655675 }
656676
677+ public static String convertContactsToString (List <OrganizationalContact > authors ) {
678+ if (authors == null || authors .isEmpty ()) {
679+ return "" ;
680+ }
681+ StringBuilder stringBuilder = new StringBuilder ();
682+ for (OrganizationalContact author : authors ) {
683+ if (author != null && author .getName () != null ) {
684+ stringBuilder .append (author .getName ()).append (", " );
685+ }
686+ }
687+ //remove trailing comma and space
688+ if (stringBuilder .length () > 0 ) {
689+ stringBuilder .setLength (stringBuilder .length () - 2 );
690+ }
691+ return stringBuilder .toString ();
692+ }
693+
657694 public static org .cyclonedx .model .Metadata createMetadata (final Project project ) {
658695 final org .cyclonedx .model .Metadata metadata = new org .cyclonedx .model .Metadata ();
659696 final org .cyclonedx .model .Tool tool = new org .cyclonedx .model .Tool ();
@@ -666,7 +703,7 @@ public static org.cyclonedx.model.Metadata createMetadata(final Project project)
666703
667704 final org .cyclonedx .model .Component cycloneComponent = new org .cyclonedx .model .Component ();
668705 cycloneComponent .setBomRef (project .getUuid ().toString ());
669- cycloneComponent .setAuthor (StringUtils .trimToNull (project .getAuthor ( )));
706+ cycloneComponent .setAuthor (StringUtils .trimToNull (convertContactsToString ( project .getAuthors () )));
670707 cycloneComponent .setPublisher (StringUtils .trimToNull (project .getPublisher ()));
671708 cycloneComponent .setGroup (StringUtils .trimToNull (project .getGroup ()));
672709 cycloneComponent .setName (StringUtils .trimToNull (project .getName ()));
@@ -704,6 +741,7 @@ public static org.cyclonedx.model.Metadata createMetadata(final Project project)
704741 cycloneComponent .setExternalReferences (references );
705742 }
706743 cycloneComponent .setSupplier (convert (project .getSupplier ()));
744+ cycloneComponent .setAuthors (convertContacts (project .getAuthors ()));
707745
708746 // NB: Project properties are currently used to configure integrations
709747 // such as Defect Dojo. They can also contain encrypted values that most
0 commit comments