Skip to content

Commit 2d89f7b

Browse files
[#905] 404 Error Code While Uploading Platform Certificates (#907)
* v3_issue_905: Finally figured out why we were getting a null pointer exception. Fixed the issue and can now upload plat form certs with unusual components without any hiccups. * v3_issue_905: CI/CD pipeline should be happy now.
1 parent 60cc011 commit 2d89f7b

File tree

4 files changed

+200
-241
lines changed

4 files changed

+200
-241
lines changed

Diff for: HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/attributes/ComponentClass.java

+10-6
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public ComponentClass(final String registryOid,
155155
* @param component string representation of the component ID
156156
* @return the int representation of the component
157157
*/
158-
private static String verifyComponentValue(final String component) {
158+
private String verifyComponentValue(final String component) {
159159
String componentValue = ERROR;
160160

161161
if (component != null) {
@@ -223,7 +223,7 @@ private void findStringValues(final JsonObject categories) {
223223
} else if (componentMask.equals(UNKNOWN)) {
224224
this.componentStr = UNKNOWN_STRING;
225225
} else {
226-
getComponent(componentTypes);
226+
setComponentString(componentTypes);
227227
}
228228
}
229229
}
@@ -247,12 +247,11 @@ public boolean categoryMatch(final String category, final String componentId) {
247247
}
248248

249249
/**
250-
* Getter for the component associated with the component JSON Object mapped
251-
* in the JSON file.
250+
* Sets the component string value based on the provided JSON object's components.
252251
*
253-
* @param components JSON Object for the categories components
252+
* @param components JSON Object components
254253
*/
255-
private void getComponent(final JsonObject components) {
254+
private void setComponentString(final JsonObject components) {
256255
String typeID;
257256

258257
if (components != null) {
@@ -264,5 +263,10 @@ private void getComponent(final JsonObject components) {
264263
}
265264
}
266265
}
266+
267+
// if the component string is still null after doing a lookup
268+
if (componentStr == null) {
269+
componentStr = UNKNOWN_STRING;
270+
}
267271
}
268272
}

Diff for: HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/entity/userdefined/certificate/attributes/ComponentClassTest.java

+27-25
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import java.nio.file.Paths;
77

88
import static org.junit.jupiter.api.Assertions.assertEquals;
9-
import static org.junit.jupiter.api.Assertions.assertNull;
9+
import static org.junit.jupiter.api.Assertions.assertNotNull;
1010

1111
/**
1212
* Tests for the ComponentClassTest class.
@@ -28,8 +28,8 @@ public void testGetComponentNoneUNK() throws URISyntaxException {
2828
componentIdentifier);
2929
String resultCategory = instance.getCategoryStr();
3030
String resultComponent = instance.getComponentStr();
31-
assertEquals(resultComponent, "Unknown");
32-
assertEquals(resultCategory, "None");
31+
assertEquals("Unknown", resultComponent);
32+
assertEquals("None", resultCategory);
3333
}
3434

3535
/**
@@ -44,8 +44,8 @@ public void testGetComponentNoneOther() throws URISyntaxException {
4444
.getResource(JSON_FILE).toURI()), componentIdentifier);
4545
String resultCategory = instance.getCategoryStr();
4646
String resultComponent = instance.getComponentStr();
47-
assertEquals(resultComponent, "Unknown");
48-
assertEquals(resultCategory, "None");
47+
assertEquals("Unknown", resultComponent);
48+
assertEquals("None", resultCategory);
4949
}
5050

5151
/**
@@ -60,8 +60,8 @@ public void testGetComponentBlank() throws URISyntaxException {
6060
.getResource(JSON_FILE).toURI()), componentIdentifier);
6161
String resultCategory = instance.getCategoryStr();
6262
String resultComponent = instance.getComponentStr();
63-
assertEquals(resultComponent, "Unknown");
64-
assertEquals(resultCategory, "None");
63+
assertEquals("Unknown", resultComponent);
64+
assertEquals("None", resultCategory);
6565
}
6666

6767
/**
@@ -76,8 +76,8 @@ public void testGetComponentNFEx() throws URISyntaxException {
7676
.getResource(JSON_FILE).toURI()), componentIdentifier);
7777
String resultCategory = instance.getCategoryStr();
7878
String resultComponent = instance.getComponentStr();
79-
assertEquals(resultComponent, "Unknown");
80-
assertEquals(resultCategory, "None");
79+
assertEquals("Unknown", resultComponent);
80+
assertEquals("None", resultCategory);
8181
}
8282

8383
/**
@@ -92,8 +92,8 @@ public void testGetComponentNull() throws URISyntaxException {
9292
.getResource(JSON_FILE).toURI()), componentIdentifier);
9393
String resultCategory = instance.getCategoryStr();
9494
String resultComponent = instance.getComponentStr();
95-
assertEquals(resultComponent, "Unknown");
96-
assertEquals(resultCategory, "None");
95+
assertEquals("Unknown", resultComponent);
96+
assertEquals("None", resultCategory);
9797
}
9898

9999
/**
@@ -108,8 +108,8 @@ public void testGetComponentStandardQueryTCG() throws URISyntaxException {
108108
.getResource(JSON_FILE).toURI()), componentIdentifier);
109109
String resultCategory = instance.getCategoryStr();
110110
String resultComponent = instance.getComponentStr();
111-
assertEquals(resultComponent, "SAS Bridgeboard");
112-
assertEquals(resultCategory, "Modules");
111+
assertEquals("SAS Bridgeboard", resultComponent);
112+
assertEquals("Modules", resultCategory);
113113
}
114114

115115
/**
@@ -140,8 +140,8 @@ public void testGetComponentStandardQueryIntTCG() throws URISyntaxException {
140140
.getResource(JSON_FILE).toURI()), componentIdentifier);
141141
String resultCategory = instance.getCategoryStr();
142142
String resultComponent = instance.getComponentStr();
143-
assertEquals(resultComponent, "SAS Bridgeboard");
144-
assertEquals(resultCategory, "Modules");
143+
assertEquals("SAS Bridgeboard", resultComponent);
144+
assertEquals("Modules", resultCategory);
145145
}
146146

147147
/**
@@ -236,8 +236,8 @@ public void testGetComponentNonStandardQuery() throws URISyntaxException {
236236
.getResource(JSON_FILE).toURI()), componentIdentifier);
237237
String resultCategory = instance.getCategoryStr();
238238
String resultComponent = instance.getComponentStr();
239-
assertEquals(resultComponent, "SAS Bridgeboard");
240-
assertEquals(resultCategory, "Modules");
239+
assertEquals("SAS Bridgeboard", resultComponent);
240+
assertEquals("Modules", resultCategory);
241241
}
242242

243243
/**
@@ -252,8 +252,8 @@ public void testGetComponentNonStandardQuery2() throws URISyntaxException {
252252
.getResource(JSON_FILE).toURI()), componentIdentifier);
253253
String resultCategory = instance.getCategoryStr();
254254
String resultComponent = instance.getComponentStr();
255-
assertEquals(resultComponent, "SAS Bridgeboard");
256-
assertEquals(resultCategory, "Modules");
255+
assertEquals("SAS Bridgeboard", resultComponent);
256+
assertEquals("Modules", resultCategory);
257257
}
258258

259259
/**
@@ -268,8 +268,9 @@ public void testGetComponentNonExistentValue() throws URISyntaxException {
268268
.getResource(JSON_FILE).toURI()), componentIdentifier);
269269
String resultCategory = instance.getCategoryStr();
270270
String resultComponent = instance.getComponentStr();
271-
assertNull(resultComponent);
272-
assertEquals(resultCategory, "Modules");
271+
assertNotNull(resultComponent);
272+
assertEquals("Unknown", resultComponent);
273+
assertEquals("Modules", resultCategory);
273274
}
274275

275276
/**
@@ -284,8 +285,9 @@ public void testGetComponentNonExistentValue2() throws URISyntaxException {
284285
.getResource(JSON_FILE).toURI()), componentIdentifier);
285286
String resultCategory = instance.getCategoryStr();
286287
String resultComponent = instance.getComponentStr();
287-
assertNull(resultComponent);
288-
assertEquals(resultCategory, "Modules");
288+
assertNotNull(resultComponent);
289+
assertEquals("Unknown", resultComponent);
290+
assertEquals("Modules", resultCategory);
289291
}
290292

291293
/**
@@ -300,7 +302,7 @@ public void testGetComponentNonExistentCategory() throws URISyntaxException {
300302
.getResource(JSON_FILE).toURI()), componentIdentifier);
301303
String resultCategory = instance.getCategoryStr();
302304
String resultComponent = instance.getComponentStr();
303-
assertEquals(resultComponent, "Unknown");
304-
assertEquals(resultCategory, "None");
305+
assertEquals("Unknown", resultComponent);
306+
assertEquals("None", resultCategory);
305307
}
306308
}

Diff for: HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/Page.java

+13-76
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package hirs.attestationca.portal.page;
22

33
import hirs.utils.VersionHelper;
4+
import lombok.Getter;
45

56
/**
67
* Contains attributes required to display a portal page and its menu link.
78
*/
9+
@Getter
810
public enum Page {
911

1012
/**
@@ -73,14 +75,25 @@ public enum Page {
7375
HELP("Help", "ic_live_help");
7476

7577
private final String title;
78+
7679
private final String subtitle;
80+
7781
private final String icon;
7882

83+
/**
84+
* Boolean representation of whether the page should display the navigation menu.
85+
*/
7986
private final boolean hasMenu;
87+
8088
private final String menuLinkClass;
89+
90+
/**
91+
* Boolean representation of whether the page should be displayed in the navigation menu.
92+
*/
8193
private final boolean inMenu;
8294

8395
private final String prefixPath;
96+
8497
private final String viewName;
8598

8699
/**
@@ -150,80 +163,4 @@ public enum Page {
150163
final String icon) {
151164
this(title, null, icon, true, true, null, null);
152165
}
153-
154-
/**
155-
* Returns the title of the page.
156-
*
157-
* @return the title of the page.
158-
*/
159-
public String getTitle() {
160-
return title;
161-
}
162-
163-
/**
164-
* Returns the subtitle of the page.
165-
*
166-
* @return the subtitle of the page.
167-
*/
168-
public String getSubtitle() {
169-
return subtitle;
170-
}
171-
172-
/**
173-
* Returns the base filename of the icon for page. E.g. "ic_my_icon", which will be appended
174-
* with appropriate size string (_24dp/_48dp) and file extension (.png) when used.
175-
*
176-
* @return the base filename of the icon for page.
177-
*/
178-
public String getIcon() {
179-
return icon;
180-
}
181-
182-
/**
183-
* Returns true if the page should be displayed in the navigation menu.
184-
*
185-
* @return true if the page should be displayed in the navigation menu.
186-
*/
187-
public boolean getInMenu() {
188-
return inMenu;
189-
}
190-
191-
/**
192-
* Returns the css class to add to the menu link to display it appropriately. E.g. "first" if
193-
* the link is the first in a group to separate it visually from the previous group.
194-
*
195-
* @return he class to add to the menu link to display it appropriately.
196-
*/
197-
public String getMenuLinkClass() {
198-
return menuLinkClass;
199-
}
200-
201-
/**
202-
* Returns true if the page should display the navigation menu.
203-
*
204-
* @return true if the page should display the navigation menu.
205-
*/
206-
public boolean getHasMenu() {
207-
return hasMenu;
208-
}
209-
210-
/**
211-
* Return the page's view name.
212-
*
213-
* @return the page's view name
214-
*/
215-
public String getViewName() {
216-
return viewName;
217-
}
218-
219-
/**
220-
* Return the page's view name.
221-
*
222-
* @return the page's view name
223-
*/
224-
public String getPrefixPath() {
225-
return prefixPath;
226-
}
227-
228166
}
229-

0 commit comments

Comments
 (0)