Add attributes in file creation

1

I'm developing a Java application that creates files in the user's directory.

So when I created the files I needed to add some attributes in their properties, so I can identify where they originated this file if the operating system user copies those files and shares them with others.

Is there any way in Java to do this? Eg in MP3 format files there are attributes Author, Description.

    
asked by anonymous 24.09.2014 / 15:23

1 answer

1

In general, what attributes (metadata) a file can receive depends on two things:

  • From the operating system, if these attributes are external to the file (i.e. not part of your content);
  • From the file format, if these attributes are internal (eg, the metadata that MP3 supports).

In your case, it seems to me that there is a requirement that they be external, since the format does not support them. In this case, we have some problems:

  • Most OSs only support simple metadata (name, creation date, etc);
  • Although an OS supports something more elaborate, this metadata can be lost if the file is transferred from one computer to another;
  • The user can always change the data in his / her absence.

That last point is important, because from your last comment it seemed to me that you were wanting to do some sort of DRM. This is highly unworkable, with no warranty whatsoever, and can bring problems - particularly when applied to a file format that does not give native support to this. If you want to "prevent user X from copying the file to user Y," then I'm afraid there is not a good way to do that (and personally I do not consider it a good goal, but it's just my opinion).

If this is not the question, then please edit your question in more detail because there may be some "out of the box" solution to your problem. For example, why not put this file inside a zip and sign zip ? At the same time, you can change the extent of zip (not to make it obvious that it's a zip ) and modify your program to use zip as input - not the bin contained in it. This should prevent any accidental changes in the metadata (but not the malicious ones, as described above).

    
24.09.2014 / 17:26