AesGcmInputFile.java org::apache::iceberg::encryption::AesGcmInputFile org::apache::iceberg::encryption /* *LicensedtotheApacheSoftwareFoundation(ASF)underone *ormorecontributorlicenseagreements.SeetheNOTICEfile *distributedwiththisworkforadditionalinformation *regardingcopyrightownership.TheASFlicensesthisfile *toyouundertheApacheLicense,Version2.0(the *"License");youmaynotusethisfileexceptincompliance *withtheLicense.YoumayobtainacopyoftheLicenseat * *http://www.apache.org/licenses/LICENSE-2.0 * *Unlessrequiredbyapplicablelaworagreedtoinwriting, *softwaredistributedundertheLicenseisdistributedonan *"ASIS"BASIS,WITHOUTWARRANTIESORCONDITIONSOFANY *KIND,eitherexpressorimplied.SeetheLicenseforthe *specificlanguagegoverningpermissionsandlimitations *undertheLicense. */ packageorg.apache.iceberg.encryption; importorg.apache.iceberg.io.InputFile; importorg.apache.iceberg.io.SeekableInputStream; importorg.apache.iceberg.relocated.com.google.common.base.Preconditions; publicclassAesGcmInputFileimplementsInputFile{ privatefinalInputFilesourceFile; privatefinalbyte[]dataKey; privatefinalbyte[]fileAADPrefix; privatelongplaintextLength; publicAesGcmInputFile(InputFilesourceFile,byte[]dataKey,byte[]fileAADPrefix){ this.sourceFile=sourceFile; this.dataKey=dataKey; this.fileAADPrefix=fileAADPrefix; this.plaintextLength=-1; } @Override publiclonggetLength(){ if(plaintextLength==-1){ //Presumesallstreamsusehard-codedplaintextblocksize. plaintextLength=AesGcmInputStream.calculatePlaintextLength(sourceFile.getLength()); } returnplaintextLength; } @Override publicSeekableInputStreamnewStream(){ longciphertextLength=sourceFile.getLength(); Preconditions.checkState( ciphertextLength>=Ciphers.MIN_STREAM_LENGTH, "Invalidencryptedstream:%disshorterthantheminimumpossiblestreamlength", ciphertextLength); returnnewAesGcmInputStream(sourceFile.newStream(),ciphertextLength,dataKey,fileAADPrefix); } @Override publicStringlocation(){ returnsourceFile.location(); } @Override publicbooleanexists(){ returnsourceFile.exists(); } }