Coverage Report - org.jaudiotagger.audio.asf.io.EncryptionChunkReader
 
Classes in this File Line Coverage Branch Coverage Complexity
EncryptionChunkReader
9%
3/33
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  
     /**
 41  
      * Should not be used for now.
 42  
      */
 43  
     protected EncryptionChunkReader()
 44  42
     {
 45  
         // NOTHING toDo
 46  42
     }
 47  
 
 48  
     /**
 49  
      * {@inheritDoc}
 50  
      */
 51  
     public boolean canFail()
 52  
     {
 53  0
         return false;
 54  
     }
 55  
 
 56  
     /**
 57  
      * {@inheritDoc}
 58  
      */
 59  
     public GUID getApplyingId()
 60  
     {
 61  42
         return GUID.GUID_CONTENT_ENCRYPTION;
 62  
     }
 63  
 
 64  
     /**
 65  
      * {@inheritDoc}
 66  
      */
 67  
     public Chunk read(final GUID guid, final InputStream stream, final long chunkStart) throws IOException
 68  
     {
 69  0
         EncryptionChunk result = null;
 70  0
         BigInteger chunkLen = Utils.readBig64(stream);
 71  0
         result = new EncryptionChunk(chunkLen);
 72  
 
 73  
         // Can't be interpreted
 74  
         /*
 75  
         * Object ID GUID    128
 76  
         * Object Size   QWORD   64
 77  
         * Secret Data Length    DWORD   32
 78  
         * Secret Data   BYTE    varies
 79  
         * Protection Type Length    DWORD   32
 80  
         * Protection Type   char    varies
 81  
         * Key ID Length DWORD   32
 82  
         * Key ID    char    varies
 83  
         * License URL Length    DWORD   32
 84  
         * License URL   char    varies           * Read the
 85  
             */
 86  
         byte[] secretData;
 87  
         byte[] protectionType;
 88  
         byte[] keyID;
 89  
         byte[] licenseURL;
 90  
 
 91  
         // Secret Data length
 92  0
         int fieldLength = 0;
 93  0
         fieldLength = (int) Utils.readUINT32(stream);
 94  
         // Secret Data
 95  0
         secretData = new byte[fieldLength + 1];
 96  0
         stream.read(secretData, 0, fieldLength);
 97  0
         secretData[fieldLength] = 0;
 98  
 
 99  
         // Protection type Length
 100  0
         fieldLength = 0;
 101  0
         fieldLength = (int) Utils.readUINT32(stream);
 102  
         // Protection Data Length
 103  0
         protectionType = new byte[fieldLength + 1];
 104  0
         stream.read(protectionType, 0, fieldLength);
 105  0
         protectionType[fieldLength] = 0;
 106  
 
 107  
         // Key ID length
 108  0
         fieldLength = 0;
 109  0
         fieldLength = (int) Utils.readUINT32(stream);
 110  
         // Key ID
 111  0
         keyID = new byte[fieldLength + 1];
 112  0
         stream.read(keyID, 0, fieldLength);
 113  0
         keyID[fieldLength] = 0;
 114  
 
 115  
         // License URL length
 116  0
         fieldLength = 0;
 117  0
         fieldLength = (int) Utils.readUINT32(stream);
 118  
         // License URL
 119  0
         licenseURL = new byte[fieldLength + 1];
 120  0
         stream.read(licenseURL, 0, fieldLength);
 121  0
         licenseURL[fieldLength] = 0;
 122  
 
 123  0
         result.setSecretData(new String(secretData));
 124  0
         result.setProtectionType(new String(protectionType));
 125  0
         result.setKeyID(new String(keyID));
 126  0
         result.setLicenseURL(new String(licenseURL));
 127  
         
 128  0
         result.setPosition(chunkStart);
 129  
         
 130  0
         return result;
 131  
     }
 132  
 
 133  
 }