| 1 | package org.farng.mp3.id3; |
| 2 | |
| 3 | import org.farng.mp3.InvalidTagException; |
| 4 | import org.farng.mp3.object.ObjectByteArraySizeTerminated; |
| 5 | import org.farng.mp3.object.ObjectNumberFixedLength; |
| 6 | |
| 7 | import java.io.IOException; |
| 8 | import java.io.RandomAccessFile; |
| 9 | |
| 10 | /** |
| 11 | * <h3>4.28. Signature frame</h3> |
| 12 | * <p/> |
| 13 | * <p> This frame enables a group of frames, grouped with the 'Group<br> identification |
| 14 | * registration', to be signed. Although signatures can<br> |
| 15 | * <p/> |
| 16 | * reside inside the registration frame, it might be desired to store<br> the signature |
| 17 | * elsewhere, e.g. in watermarks. There may be more than<br> one 'signature frame' in a tag, but no two may |
| 18 | * be identical.</p> |
| 19 | * <p/> |
| 20 | * <p> <Header for 'Signature frame', ID: "SIGN"><br> |
| 21 | * <p/> |
| 22 | * Group symbol $xx<br> |
| 23 | * Signature <binary data><br> </p> |
| 24 | * |
| 25 | * @author Eric Farng |
| 26 | * @version $Revision: 1.4 $ |
| 27 | */ |
| 28 | public class FrameBodySIGN extends AbstractID3v2FrameBody { |
| 29 | |
| 30 | /** |
| 31 | * Creates a new FrameBodySIGN object. |
| 32 | */ |
| 33 | public FrameBodySIGN() { |
| 34 | super(); |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Creates a new FrameBodySIGN object. |
| 39 | */ |
| 40 | public FrameBodySIGN(final FrameBodySIGN body) { |
| 41 | super(body); |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Creates a new FrameBodySIGN object. |
| 46 | */ |
| 47 | public FrameBodySIGN(final byte groupSymbol, final byte[] signature) { |
| 48 | setObject("Group Symbol", new Byte(groupSymbol)); |
| 49 | setObject("Signature", signature); |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Creates a new FrameBodySIGN object. |
| 54 | */ |
| 55 | public FrameBodySIGN(final RandomAccessFile file) throws IOException, InvalidTagException { |
| 56 | this.read(file); |
| 57 | } |
| 58 | |
| 59 | public void setGroupSymbol(final byte groupSymbol) { |
| 60 | setObject("Group Symbol", new Byte(groupSymbol)); |
| 61 | } |
| 62 | |
| 63 | public byte getGroupSymbol() { |
| 64 | if (getObject("Group Symbol") != null) { |
| 65 | return ((Byte) getObject("Group Symbol")).byteValue(); |
| 66 | } |
| 67 | return 0; |
| 68 | } |
| 69 | |
| 70 | public String getIdentifier() { |
| 71 | return "SIGN" + ((char) 0) + getGroupSymbol() + ((char) 0) + (new String(getSignature())); |
| 72 | } |
| 73 | |
| 74 | public void setSignature(final byte[] signature) { |
| 75 | setObject("Signature", signature); |
| 76 | } |
| 77 | |
| 78 | public byte[] getSignature() { |
| 79 | return (byte[]) getObject("Signature"); |
| 80 | } |
| 81 | |
| 82 | protected void setupObjectList() { |
| 83 | appendToObjectList(new ObjectNumberFixedLength("Group Symbol", 1)); |
| 84 | appendToObjectList(new ObjectByteArraySizeTerminated("Signature")); |
| 85 | } |
| 86 | } |