use of org.codice.imaging.nitf.core.security.FileSecurityMetadata in project alliance by codice.
the class CatalogOutputAdapterTest method createFileSecurityMetadata.
private FileSecurityMetadata createFileSecurityMetadata() {
FileSecurityMetadata fileSecurityMetadata = mock(FileSecurityMetadata.class);
when(fileSecurityMetadata.getSecurityClassification()).thenReturn(SecurityClassification.UNCLASSIFIED);
when(fileSecurityMetadata.getSecurityClassificationSystem()).thenReturn("AB");
when(fileSecurityMetadata.getCodewords()).thenReturn("ABCDEFGHIJK");
when(fileSecurityMetadata.getControlAndHandling()).thenReturn("AB");
when(fileSecurityMetadata.getReleaseInstructions()).thenReturn("01234567890123456789");
when(fileSecurityMetadata.getDeclassificationType()).thenReturn("DD");
when(fileSecurityMetadata.getDeclassificationDate()).thenReturn("20160101");
when(fileSecurityMetadata.getDeclassificationExemption()).thenReturn("abcd");
when(fileSecurityMetadata.getDowngrade()).thenReturn("S");
when(fileSecurityMetadata.getDowngradeDate()).thenReturn("20160202");
when(fileSecurityMetadata.getClassificationText()).thenReturn("classtext");
when(fileSecurityMetadata.getClassificationAuthorityType()).thenReturn("O");
when(fileSecurityMetadata.getClassificationAuthority()).thenReturn("MyAuthority");
when(fileSecurityMetadata.getClassificationReason()).thenReturn("A");
when(fileSecurityMetadata.getSecuritySourceDate()).thenReturn("20160303");
when(fileSecurityMetadata.getSecurityControlNumber()).thenReturn("012345678901234");
when(fileSecurityMetadata.getFileCopyNumber()).thenReturn("99999");
when(fileSecurityMetadata.getFileNumberOfCopies()).thenReturn("99999");
return fileSecurityMetadata;
}
use of org.codice.imaging.nitf.core.security.FileSecurityMetadata in project alliance by codice.
the class TreUtilityTest method createSecurityMetadata.
public static FileSecurityMetadata createSecurityMetadata() {
FileSecurityMetadata securityMetadata = mock(FileSecurityMetadata.class);
when(securityMetadata.getFileType()).thenReturn(FileType.NITF_TWO_ONE);
when(securityMetadata.getSecurityClassification()).thenReturn(SecurityClassification.UNCLASSIFIED);
when(securityMetadata.getSecurityClassificationSystem()).thenReturn("");
when(securityMetadata.getCodewords()).thenReturn("");
when(securityMetadata.getControlAndHandling()).thenReturn("");
when(securityMetadata.getReleaseInstructions()).thenReturn("");
when(securityMetadata.getDeclassificationType()).thenReturn("");
when(securityMetadata.getDeclassificationDate()).thenReturn("");
when(securityMetadata.getDeclassificationExemption()).thenReturn("");
when(securityMetadata.getDowngrade()).thenReturn("");
when(securityMetadata.getDowngradeDate()).thenReturn("");
when(securityMetadata.getClassificationText()).thenReturn("");
when(securityMetadata.getClassificationAuthorityType()).thenReturn("");
when(securityMetadata.getClassificationAuthority()).thenReturn("");
when(securityMetadata.getClassificationReason()).thenReturn("");
when(securityMetadata.getSecuritySourceDate()).thenReturn("");
when(securityMetadata.getSecurityControlNumber()).thenReturn("");
when(securityMetadata.getFileCopyNumber()).thenReturn("");
when(securityMetadata.getFileNumberOfCopies()).thenReturn("");
return securityMetadata;
}
use of org.codice.imaging.nitf.core.security.FileSecurityMetadata in project alliance by codice.
the class NitfHeaderAttributeTest method testValidFileClassificationSystem.
@Test
public void testValidFileClassificationSystem() throws Exception {
NitfTestCommons.setupNitfUtilities("US", Collections.singletonList("ABC"));
FileSecurityMetadata fsmMock = mock(FileSecurityMetadata.class);
when(nitfHeader.getFileSecurityMetadata()).thenReturn(fsmMock);
when(nitfHeader.getFileSecurityMetadata().getSecurityClassificationSystem()).thenReturn("US");
Serializable value = NitfHeaderAttribute.FILE_CLASSIFICATION_SECURITY_SYSTEM_ATTRIBUTE.getAccessorFunction().apply(nitfHeader);
assertThat(value, is("ABC"));
}
use of org.codice.imaging.nitf.core.security.FileSecurityMetadata in project alliance by codice.
the class NitfHeaderAttributeTest method testNitfFileReleasabilityWithMultipleSpaces.
@Test
public void testNitfFileReleasabilityWithMultipleSpaces() throws Exception {
CountryCodeConverter mockCountryCodeConverter = mock(CountryCodeConverter.class);
doReturn(Collections.singletonList("USA")).when(mockCountryCodeConverter).convertFipsToIso3("US");
doReturn(Collections.singletonList("GBR")).when(mockCountryCodeConverter).convertFipsToIso3("GB");
new NitfAttributeConverters(mockCountryCodeConverter);
FileSecurityMetadata fsmMock = mock(FileSecurityMetadata.class);
when(nitfHeader.getFileSecurityMetadata()).thenReturn(fsmMock);
when(nitfHeader.getFileSecurityMetadata().getReleaseInstructions()).thenReturn("US GB");
Serializable value = NitfHeaderAttribute.FILE_RELEASING_INSTRUCTIONS_ATTRIBUTE.getAccessorFunction().apply(nitfHeader);
assertThat(value, is(equalTo("USA GBR")));
}
use of org.codice.imaging.nitf.core.security.FileSecurityMetadata in project alliance by codice.
the class NitfHeaderTransformerTest method testValidationWarningsOnNitfAttributeTransformException.
@Test
public void testValidationWarningsOnNitfAttributeTransformException() throws Exception {
String originalNitfValue = "US";
NitfTestCommons.setupNitfUtilities(originalNitfValue, Arrays.asList("USA", "CAN"));
File nitfFile = temporaryFolder.newFile("nitf-attribute-header-test.ntf");
FileSecurityMetadata fileSecurityMetadata = TreUtilityTest.createSecurityMetadata();
when(fileSecurityMetadata.getSecurityClassificationSystem()).thenReturn(originalNitfValue);
Supplier<NitfHeader> nitfHeader = () -> TreUtilityTest.createFileHeader(fileSecurityMetadata);
new NitfCreationFlowImpl().fileHeader(nitfHeader).write(nitfFile.getAbsolutePath());
Metacard metacard;
try (InputStream inputStream = new FileInputStream(nitfFile)) {
metacard = metacardFactory.createMetacard("nitfHeaderTest");
NitfSegmentsFlow nitfSegmentsFlow = new NitfParserInputFlowImpl().inputStream(inputStream).headerOnly();
nitfHeaderTransformer.transform(nitfSegmentsFlow, metacard);
}
assertThat(metacard, is(not(nullValue())));
assertThat(metacard.getAttribute(Validation.VALIDATION_WARNINGS).getValues().size(), equalTo(1));
assertThat(metacard.getAttribute(Security.CLASSIFICATION_SYSTEM).getValue(), is(originalNitfValue));
}
Aggregations