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 | import org.farng.mp3.object.ObjectStringNullTerminated; |
7 | |
8 | import java.io.IOException; |
9 | import java.io.RandomAccessFile; |
10 | |
11 | /** |
12 | * <h3>4.25. Encryption method registration</h3> |
13 | * <p/> |
14 | * <p> To identify with which method a frame has been encrypted the<br> |
15 | * <p/> |
16 | * encryption method must be registered in the tag with this frame. The<br> 'Owner identifier' |
17 | * is a null-terminated string with a URL [URL]<br> containing an email address, or a link to a location |
18 | * where an email<br> address can be found, that belongs to the organisation responsible<br> |
19 | * for this specific encryption method. Questions regarding the<br> |
20 | * <p/> |
21 | * encryption method should be sent to the indicated email address. The<br> 'Method symbol' |
22 | * contains a value that is associated with this method<br> throughout the whole tag, in the range $80-F0. |
23 | * All other values are<br> reserved. The 'Method symbol' may optionally be followed by<br> |
24 | * encryption specific data. There may be several "ENCR" |
25 | * <p/> |
26 | * frames in a tag<br> but only one containing the same symbol and only one containing the<br> |
27 | * same owner identifier. The method must be used somewhere in the tag.<br> See the description of the |
28 | * frame encryption flag in the ID3v2<br> structure document [ID3v2-strct] for more information.</p> |
29 | * <p/> |
30 | * <p> <Header for 'Encryption method registration', ID: "ENCR"><br> |
31 | * Owner identifier <text string> $00<br> |
32 | * Method symbol $xx<br> |
33 | * <p/> |
34 | * Encryption data <binary data><br> </p> |
35 | * |
36 | * @author Eric Farng |
37 | * @version $Revision: 1.4 $ |
38 | */ |
39 | public class FrameBodyENCR extends AbstractID3v2FrameBody { |
40 | |
41 | /** |
42 | * Creates a new FrameBodyENCR object. |
43 | */ |
44 | public FrameBodyENCR() { |
45 | super(); |
46 | } |
47 | |
48 | /** |
49 | * Creates a new FrameBodyENCR object. |
50 | */ |
51 | public FrameBodyENCR(final FrameBodyENCR body) { |
52 | super(body); |
53 | } |
54 | |
55 | /** |
56 | * Creates a new FrameBodyENCR object. |
57 | */ |
58 | public FrameBodyENCR(final String owner, final byte methodSymbol, final byte[] data) { |
59 | setObject("Owner", owner); |
60 | setObject("Method Symbol", new Byte(methodSymbol)); |
61 | setObject("Encryption Data", data); |
62 | } |
63 | |
64 | /** |
65 | * Creates a new FrameBodyENCR object. |
66 | */ |
67 | public FrameBodyENCR(final RandomAccessFile file) throws IOException, InvalidTagException { |
68 | this.read(file); |
69 | } |
70 | |
71 | public String getIdentifier() { |
72 | return "ENCR" + ((char) 0) + getOwner(); |
73 | } |
74 | |
75 | public void setOwner(final String owner) { |
76 | setObject("Owner", owner); |
77 | } |
78 | |
79 | public String getOwner() { |
80 | return (String) getObject("Owner"); |
81 | } |
82 | |
83 | protected void setupObjectList() { |
84 | appendToObjectList(new ObjectStringNullTerminated("Owner")); |
85 | appendToObjectList(new ObjectNumberFixedLength("Method Symbol", 1)); |
86 | appendToObjectList(new ObjectByteArraySizeTerminated("Encryption Data")); |
87 | } |
88 | } |