Coverage Report - org.jaudiotagger.audio.asf.io.EncryptionChunkReader
 
Classes in this File Line Coverage Branch Coverage Complexity
EncryptionChunkReader
12%
4/32
N/A
1
 
 1  
 /*
 2  
  * Entagged Audio Tag library
 3  
  * Copyright (c) 2004-2005 Christian Laireiter <liree@web.de>
 4  
  * 
 5  
  * This library is free software; you can redistribute it and/or
 6  
  * modify it under the terms of the GNU Lesser General Public
 7  
  * License as published by the Free Software Foundation; either
 8  
  * version 2.1 of the License, or (at your option) any later version.
 9  
  *  
 10  
  * This library is distributed in the hope that it will be useful,
 11  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 13  
  * Lesser General Public License for more details.
 14  
  * 
 15  
  * You should have received a copy of the GNU Lesser General Public
 16  
  * License along with this library; if not, write to the Free Software
 17  
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 18  
  */
 19  
 package org.jaudiotagger.audio.asf.io;
 20  
 
 21  
 import org.jaudiotagger.audio.asf.data.Chunk;
 22  
 import org.jaudiotagger.audio.asf.data.EncryptionChunk;
 23  
 import org.jaudiotagger.audio.asf.data.GUID;
 24  
 import org.jaudiotagger.audio.asf.util.Utils;
 25  
 
 26  
 import java.io.IOException;
 27  
 import java.io.InputStream;
 28  
 import java.math.BigInteger;
 29  
 
 30  
 /**
 31  
  * This class reads the chunk containing encoding data <br>
 32  
  * <b>Warning:<b><br>
 33  
  * Implementation is not completed. More analysis of this chunk is needed.
 34  
  * 
 35  
  * @author Christian Laireiter
 36  
  */
 37  
 class EncryptionChunkReader implements ChunkReader {
 38  
 
 39  
     /**
 40  
      * The GUID this reader {@linkplain #getApplyingIds() applies to}
 41  
      */
 42  4
     private final static GUID[] APPLYING = { GUID.GUID_CONTENT_ENCRYPTION };
 43  
 
 44  
     /**
 45  
      * Should not be used for now.
 46  
      */
 47  4
     protected EncryptionChunkReader() {
 48  
         // NOTHING toDo
 49  4
     }
 50  
 
 51  
     /**
 52  
      * {@inheritDoc}
 53  
      */
 54  
     public boolean canFail() {
 55  0
         return false;
 56  
     }
 57  
 
 58  
     /**
 59  
      * {@inheritDoc}
 60  
      */
 61  
     public GUID[] getApplyingIds() {
 62  4
         return APPLYING.clone();
 63  
     }
 64  
 
 65  
     /**
 66  
      * {@inheritDoc}
 67  
      */
 68  
     public Chunk read(final GUID guid, final InputStream stream,
 69  
             final long chunkStart) throws IOException {
 70  
         EncryptionChunk result;
 71  0
         final BigInteger chunkLen = Utils.readBig64(stream);
 72  0
         result = new EncryptionChunk(chunkLen);
 73  
 
 74  
         // Can't be interpreted
 75  
         /*
 76  
          * Object ID GUID 128 Object Size QWORD 64 Secret Data Length DWORD 32
 77  
          * Secret Data INTEGER varies Protection Type Length DWORD 32 Protection
 78  
          * Type char varies Key ID Length DWORD 32 Key ID char varies License
 79  
          * URL Length DWORD 32 License URL char varies * Read the
 80  
          */
 81  
         byte[] secretData;
 82  
         byte[] protectionType;
 83  
         byte[] keyID;
 84  
         byte[] licenseURL;
 85  
 
 86  
         // Secret Data length
 87  
         int fieldLength;
 88  0
         fieldLength = (int) Utils.readUINT32(stream);
 89  
         // Secret Data
 90  0
         secretData = new byte[fieldLength + 1];
 91  0
         stream.read(secretData, 0, fieldLength);
 92  0
         secretData[fieldLength] = 0;
 93  
 
 94  
         // Protection type Length
 95  0
         fieldLength = 0;
 96  0
         fieldLength = (int) Utils.readUINT32(stream);
 97  
         // Protection Data Length
 98  0
         protectionType = new byte[fieldLength + 1];
 99  0
         stream.read(protectionType, 0, fieldLength);
 100  0
         protectionType[fieldLength] = 0;
 101  
 
 102  
         // Key ID length
 103  0
         fieldLength = 0;
 104  0
         fieldLength = (int) Utils.readUINT32(stream);
 105  
         // Key ID
 106  0
         keyID = new byte[fieldLength + 1];
 107  0
         stream.read(keyID, 0, fieldLength);
 108  0
         keyID[fieldLength] = 0;
 109  
 
 110  
         // License URL length
 111  0
         fieldLength = 0;
 112  0
         fieldLength = (int) Utils.readUINT32(stream);
 113  
         // License URL
 114  0
         licenseURL = new byte[fieldLength + 1];
 115  0
         stream.read(licenseURL, 0, fieldLength);
 116  0
         licenseURL[fieldLength] = 0;
 117  
 
 118  0
         result.setSecretData(new String(secretData));
 119  0
         result.setProtectionType(new String(protectionType));
 120  0
         result.setKeyID(new String(keyID));
 121  0
         result.setLicenseURL(new String(licenseURL));
 122  
 
 123  0
         result.setPosition(chunkStart);
 124  
 
 125  0
         return result;
 126  
     }
 127  
 
 128  
 }