In general, what attributes (metadata) a file can receive depends on two things:
- From the operating system, if these attributes are outsiders to the archive (i.e. not part of its contents);
- From the file format, if these attributes are interns (e.g.: the metadata that MP3 supports).
In your case, it seems to me that there is a requirement that these be external, since the format does not support them. In this case, we have some problems:
- Most Oses only support simple metadata (name, creation date, etc);
- Although an OS supports something more elaborate, these metadata can be lost if the file is transferred from one computer to another;
- The user can always change the data by default.
That last point is important, because from your last comment it seemed to me that you were wanting to do a kind of DRM. This is highly impractical, without any guarantee, and can bring problems - in particular when applied to a file format that does not give native support to it. If you want to "prevent user X from copying the file to user Y", then I’m afraid there’s no good way to do that (and personally I don’t consider it a good goal, but it’s just my opinion).
If that’s not the question, then please edit your question in more detail, as there may be some "out-of-the-box" solution to your problem. For example, why not put this file inside a zip
and sign the zip
? At the same time, you can change the extension of the zip
(not to make it obvious that it’s a zip
) and modify your program to use the zip
as input - and not the bin
contained in it. This should prevent any accidental alteration in metadata (but not malicious ones as described above).
If you’re talking about what I’m thinking, this type of metadata is specific to each file type. For example, Mp3s usually use the format ID3 (several libraries implement ID3 support in Java, see that link).
– Anthony Accioly
Most of the files I’m going to create are. bin, so there is no given way to change some attribute of it or create a new one so that I can put some information that helps me identify whose file it was? In the realization I am working with Java web and I am doing a download center and needed to identify in the file who made the download. I’ve been looking at the Java API and it has such a setOwner(), but only to set some user that exists in the operating system of the person and not any String.
– caio carriel
Setar the
owner
is just set an attribute in the file system (which can be modified, in linux for example just use the commandchmod
). If you are talking about binary "raw" music files, metadata is usually demarcated in a textual file Cue.– Anthony Accioly
It’s not music files. Are firmwares that will be available for download, however we would like to perform a control of these files downloaded by the user. I was looking to sign the files before the download, but only meeting for files . zip and pdf.
– caio carriel