| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| FrameBodyCRM |
|
| 1.0;1 |
| 1 | /** | |
| 2 | * @author : Paul Taylor | |
| 3 | * @author : Eric Farng | |
| 4 | * | |
| 5 | * Version @version:$Id: FrameBodyCRM.java,v 1.11 2008/07/21 10:45:42 paultaylor Exp $ | |
| 6 | * | |
| 7 | * MusicTag Copyright (C)2003,2004 | |
| 8 | * | |
| 9 | * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser | |
| 10 | * General Public License as published by the Free Software Foundation; either version 2.1 of the License, | |
| 11 | * or (at your option) any later version. | |
| 12 | * | |
| 13 | * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even | |
| 14 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
| 15 | * See the GNU Lesser General Public License for more details. | |
| 16 | * | |
| 17 | * You should have received a copy of the GNU Lesser General Public License along with this library; if not, | |
| 18 | * you can get a copy from http://www.opensource.org/licenses/lgpl-license.php or write to the Free Software | |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 20 | * | |
| 21 | * Description: | |
| 22 | * | |
| 23 | */ | |
| 24 | package org.jaudiotagger.tag.id3.framebody; | |
| 25 | ||
| 26 | import org.jaudiotagger.tag.InvalidTagException; | |
| 27 | import org.jaudiotagger.tag.datatype.ByteArraySizeTerminated; | |
| 28 | import org.jaudiotagger.tag.datatype.DataTypes; | |
| 29 | import org.jaudiotagger.tag.datatype.StringNullTerminated; | |
| 30 | import org.jaudiotagger.tag.id3.ID3v22Frames; | |
| 31 | ||
| 32 | import java.nio.ByteBuffer; | |
| 33 | ||
| 34 | /** | |
| 35 | * Encrypted meta frame | |
| 36 | * <p/> | |
| 37 | * This frame contains one or more encrypted frames. This enables | |
| 38 | * protection of copyrighted information such as pictures and text, that | |
| 39 | * people might want to pay extra for. Since standardisation of such an | |
| 40 | * encryption scheme is beyond this document, all "CRM" frames begin with | |
| 41 | * a terminated string with a URL [URL] containing an email address, or a | |
| 42 | * link to a location where an email adress can be found, that belongs to | |
| 43 | * the organisation responsible for this specific encrypted meta frame. | |
| 44 | * <p/> | |
| 45 | * Questions regarding the encrypted frame should be sent to the | |
| 46 | * indicated email address. If a $00 is found directly after the 'Frame | |
| 47 | * size', the whole frame should be ignored, and preferably be removed. | |
| 48 | * The 'Owner identifier' is then followed by a short content description | |
| 49 | * and explanation as to why it's encrypted. After the | |
| 50 | * 'content/explanation' description, the actual encrypted block follows. | |
| 51 | * <p/> | |
| 52 | * When an ID3v2 decoder encounters a "CRM" frame, it should send the | |
| 53 | * datablock to the 'plugin' with the corresponding 'owner identifier' | |
| 54 | * and expect to receive either a datablock with one or several ID3v2 | |
| 55 | * frames after each other or an error. There may be more than one "CRM" | |
| 56 | * frames in a tag, but only one with the same 'owner identifier'. | |
| 57 | * <p/> | |
| 58 | * Encrypted meta frame "CRM" | |
| 59 | * Frame size $xx xx xx | |
| 60 | * Owner identifier <textstring> $00 (00) | |
| 61 | * Content/explanation <textstring> $00 (00) | |
| 62 | * Encrypted datablock <binary data> | |
| 63 | */ | |
| 64 | public class FrameBodyCRM extends AbstractID3v2FrameBody implements ID3v22FrameBody | |
| 65 | { | |
| 66 | /** | |
| 67 | * Creates a new FrameBodyCRM datatype. | |
| 68 | */ | |
| 69 | public FrameBodyCRM() | |
| 70 | 0 | { |
| 71 | // this.setObject(ObjectTypes.OBJ_OWNER, ""); | |
| 72 | // this.setObject(ObjectTypes.OBJ_DESCRIPTION, ""); | |
| 73 | // this.setObject("Encrypted datablock", new byte[0]); | |
| 74 | 0 | } |
| 75 | ||
| 76 | public FrameBodyCRM(FrameBodyCRM body) | |
| 77 | { | |
| 78 | 0 | super(body); |
| 79 | 0 | } |
| 80 | ||
| 81 | /** | |
| 82 | * Creates a new FrameBodyCRM datatype. | |
| 83 | * | |
| 84 | * @param owner | |
| 85 | * @param description | |
| 86 | * @param data | |
| 87 | */ | |
| 88 | public FrameBodyCRM(String owner, String description, byte[] data) | |
| 89 | 0 | { |
| 90 | 0 | this.setObjectValue(DataTypes.OBJ_OWNER, owner); |
| 91 | 0 | this.setObjectValue(DataTypes.OBJ_DESCRIPTION, description); |
| 92 | 0 | this.setObjectValue(DataTypes.OBJ_ENCRYPTED_DATABLOCK, data); |
| 93 | 0 | } |
| 94 | ||
| 95 | /** | |
| 96 | * Creates a new FrameBodyCRM datatype. | |
| 97 | * | |
| 98 | * @throws InvalidTagException if unable to create framebody from buffer | |
| 99 | */ | |
| 100 | public FrameBodyCRM(ByteBuffer byteBuffer, int frameSize) throws InvalidTagException | |
| 101 | { | |
| 102 | 0 | super(byteBuffer, frameSize); |
| 103 | 0 | } |
| 104 | ||
| 105 | /** | |
| 106 | * The ID3v2 frame identifier | |
| 107 | * | |
| 108 | * @return the ID3v2 frame identifier for this frame type | |
| 109 | */ | |
| 110 | public String getIdentifier() | |
| 111 | { | |
| 112 | 0 | return ID3v22Frames.FRAME_ID_V2_ENCRYPTED_FRAME; |
| 113 | } | |
| 114 | ||
| 115 | /** | |
| 116 | * @return | |
| 117 | */ | |
| 118 | public String getOwner() | |
| 119 | { | |
| 120 | 0 | return (String) getObjectValue(DataTypes.OBJ_OWNER); |
| 121 | } | |
| 122 | ||
| 123 | /** | |
| 124 | * @param description | |
| 125 | */ | |
| 126 | public void getOwner(String description) | |
| 127 | { | |
| 128 | 0 | setObjectValue(DataTypes.OBJ_OWNER, description); |
| 129 | 0 | } |
| 130 | ||
| 131 | /** | |
| 132 | * | |
| 133 | */ | |
| 134 | protected void setupObjectList() | |
| 135 | { | |
| 136 | 0 | objectList.add(new StringNullTerminated(DataTypes.OBJ_OWNER, this)); |
| 137 | 0 | objectList.add(new StringNullTerminated(DataTypes.OBJ_DESCRIPTION, this)); |
| 138 | 0 | objectList.add(new ByteArraySizeTerminated(DataTypes.OBJ_ENCRYPTED_DATABLOCK, this)); |
| 139 | 0 | } |
| 140 | } |