API for write-protected Calc or Writer ?
-
- Volunteer
- Posts: 1160
- Joined: Mon Oct 08, 2007 1:26 am
- Location: France, Paris area
API for write-protected Calc or Writer ?
Hello,
Since OpenOffice.org version 3.3 it is possible to have a password protecting a Calc or Writer document from modifications. Such document can be read, not modified.
See new features and see this announce.
If you open by program a document protected from modifications, you can modify it, but the store() method throws an exception.
I have searched for an API that would allow to :
- protect from modifications a document by setting a password
- save the document with same password protection after it has been modified by program.
I could not find any new API feature. There is nothing new in the IDL description of MediaDescriptor.
Maybe someone that can read source codes could find out if such API exists or not ?
Flame icon removed. That icon means 'Tagged to a known issue' (TheGurkha, Moderator)
Since OpenOffice.org version 3.3 it is possible to have a password protecting a Calc or Writer document from modifications. Such document can be read, not modified.
See new features and see this announce.
If you open by program a document protected from modifications, you can modify it, but the store() method throws an exception.
I have searched for an API that would allow to :
- protect from modifications a document by setting a password
- save the document with same password protection after it has been modified by program.
I could not find any new API feature. There is nothing new in the IDL description of MediaDescriptor.
Maybe someone that can read source codes could find out if such API exists or not ?
Flame icon removed. That icon means 'Tagged to a known issue' (TheGurkha, Moderator)
Last edited by B Marcelly on Sun Mar 18, 2012 11:02 am, edited 1 time in total.
Bernard
OpenOffice.org 1.1.5 / Apache OpenOffice 4.1.1 / LibreOffice 5.0.5
MS-Windows 7 Home SP1
OpenOffice.org 1.1.5 / Apache OpenOffice 4.1.1 / LibreOffice 5.0.5
MS-Windows 7 Home SP1
Re: API for write-protected Calc or Writer ?
Hi,
It seems it is not documented yet. I found the following way in the source code [1]:
salt and hash are generated from password in [2] and the function is not accessible though API. These values are taken by macro recorder in the above code.
[1] http://svn.services.openoffice.org/open ... l.cxx#2864
[2] http://svn.services.openoffice.org/open ... per.cxx#83
It seems it is not documented yet. I found the following way in the source code [1]:
Code: Select all
sub StoreWithModifyPassowrd
Dim info(3) As new com.sun.star.beans.PropertyValue
info(0).Name = "algorithm-name"
info(0).Value = "PBKDF2"
info(1).Name = "salt"
info(1).Value = Array(107,118,-86,-63,19,7,-93,-63,-127,-38,-40,2,120,-32,-66,94)
info(2).Name = "iteration-count"
info(2).Value = 1024
info(3).Name = "hash"
info(3).Value = Array(-84,-89,22,-88,116,126,-48,-86,41,-70,-103,-5,52,84,52,24)
Dim args(0) As new com.sun.star.beans.PropertyValue
args(0).Name = "ModifyPasswordInfo"
args(0).Value = info
ThisComponent.storeAsURL(_
"file:///home/user/Desktop/u1.odt", args)
end sub
[1] http://svn.services.openoffice.org/open ... l.cxx#2864
[2] http://svn.services.openoffice.org/open ... per.cxx#83
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
Apache OpenOffice 4-dev on Xubuntu 14.04
-
- Volunteer
- Posts: 1160
- Joined: Mon Oct 08, 2007 1:26 am
- Location: France, Paris area
Re: API for write-protected Calc or Writer ?
Thank you for your investigation, hanya !
Your code is a complex alternative to the absence of an API. I have created Bug 119086 to request a real API.
Regards
Your code is a complex alternative to the absence of an API. I have created Bug 119086 to request a real API.
Regards
Bernard
OpenOffice.org 1.1.5 / Apache OpenOffice 4.1.1 / LibreOffice 5.0.5
MS-Windows 7 Home SP1
OpenOffice.org 1.1.5 / Apache OpenOffice 4.1.1 / LibreOffice 5.0.5
MS-Windows 7 Home SP1
-
- Posts: 10
- Joined: Tue Apr 10, 2012 12:56 am
Re: [Issue] API for write-protected Calc or Writer ?
were you able to get a solution for this?
I'm trying to do a storeasurl with password on edit but with no luck
Thanks
I'm trying to do a storeasurl with password on edit but with no luck
Thanks
OpenOffice 3.3.0
Window 7
Window 7
-
- Posts: 10
- Joined: Tue Apr 10, 2012 12:56 am
Re: [Issue] API for write-protected Calc or Writer ?
in fact what's the password that generated the salt and the hash above?
how can i generate my own salt and hash (one time)
Thanks
how can i generate my own salt and hash (one time)
Thanks
OpenOffice 3.3.0
Window 7
Window 7
Re: [Issue] API for write-protected Calc or Writer ?
The password is given in Hanya's reference [2]
If you can't work it out you should question if you should be attempting to use code at this level.
If you can't work it out you should question if you should be attempting to use code at this level.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
-
- Posts: 10
- Joined: Tue Apr 10, 2012 12:56 am
Re: [Issue] API for write-protected Calc or Writer ?
I could probably if I want to it's just I was looking for a quick answer...
I just translated 2000 lines of code from vba to python-uno/OOBasic (no previous knowledge in python or OOBasic) and didn't want to defer my focus in building a utility or learn the OO framework for a simple feature I was looking for.
on a different day I wouldn't mind digging in or even contribute to this project, but for now any help would be greatly appreciated.
I just translated 2000 lines of code from vba to python-uno/OOBasic (no previous knowledge in python or OOBasic) and didn't want to defer my focus in building a utility or learn the OO framework for a simple feature I was looking for.
on a different day I wouldn't mind digging in or even contribute to this project, but for now any help would be greatly appreciated.
OpenOffice 3.3.0
Window 7
Window 7
-
- Posts: 10
- Joined: Tue Apr 10, 2012 12:56 am
Re: [Issue] API for write-protected Calc or Writer ?
ok so I'm generating the salt and hash from recording a macro using my own password, when I run the code posted by hanya with the generated salt/hash and then I try to open the file and try to edit, i'm being asked for a password but my original password does not work...
what am I doing wrong here
Thanks
what am I doing wrong here
Thanks
OpenOffice 3.3.0
Window 7
Window 7
Re: API for write-protected Calc or Writer ?
Try this function to help conversion of the salt and hash:i'm being asked for a password but my original password does not work...
what am I doing wrong here
Code: Select all
Sub ByteSeqToIntSeq(a)
for i = 0 to ubound(a) step 1
v = a(i)
if v < 0 then
a(i) = &H100 + v
end if
next
End sub
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
Apache OpenOffice 4-dev on Xubuntu 14.04
-
- Posts: 10
- Joined: Tue Apr 10, 2012 12:56 am
Re: API for write-protected Calc or Writer ?
Hanya, thanks for the response.
I tried the conversion as per your function but this didn't help, I still cannot edit the saved odt.
here is my block of code
dim salt
dim hash
salt = Array(-76,46,-73,112,-50,31,76,47,-39,-26,89,-29,111,113,-92,-93)
ByteSeqToIntSeq(salt)
hash = Array(102,-105,33,31,104,-35,115,63,-118,-86,11,-40,46,19,-124,-71)
ByteSeqToIntSeq(hash)
Dim info(3) As new com.sun.star.beans.PropertyValue
info(0).Name = "algorithm-name"
info(0).Value = "PBKDF2"
info(1).Name = "salt"
info(1).Value = salt
info(2).Name = "iteration-count"
info(2).Value = 1024
info(3).Name = "hash"
info(3).Value = hash
Dim args(1) As new com.sun.star.beans.PropertyValue
args(0).Name = "ModifyPasswordInfo"
args(0).Value = info
args(1).Name = "Overwrite"
args(1).Value = True
ThisComponent.storeAsURL(ThisComponent.URL, args)
I tried the conversion as per your function but this didn't help, I still cannot edit the saved odt.
here is my block of code
dim salt
dim hash
salt = Array(-76,46,-73,112,-50,31,76,47,-39,-26,89,-29,111,113,-92,-93)
ByteSeqToIntSeq(salt)
hash = Array(102,-105,33,31,104,-35,115,63,-118,-86,11,-40,46,19,-124,-71)
ByteSeqToIntSeq(hash)
Dim info(3) As new com.sun.star.beans.PropertyValue
info(0).Name = "algorithm-name"
info(0).Value = "PBKDF2"
info(1).Name = "salt"
info(1).Value = salt
info(2).Name = "iteration-count"
info(2).Value = 1024
info(3).Name = "hash"
info(3).Value = hash
Dim args(1) As new com.sun.star.beans.PropertyValue
args(0).Name = "ModifyPasswordInfo"
args(0).Value = info
args(1).Name = "Overwrite"
args(1).Value = True
ThisComponent.storeAsURL(ThisComponent.URL, args)
OpenOffice 3.3.0
Window 7
Window 7
Re: API for write-protected Calc or Writer ?
My apologies, so it should be work now, pass it like as follows:
I wonder these values are stored in settings.xml file in ODF file and the contents of the file are not encrypted. So someone can remove the part and to modify the document. The purpose of this passoword is to protect the document from easy modification...?, I don't konw.
Code: Select all
info(1).Name = "salt"
info(1).Value = CreateUnoValue("[]byte", (Array(13,92,-41,.....-92,36))
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
Apache OpenOffice 4-dev on Xubuntu 14.04
-
- Posts: 10
- Joined: Tue Apr 10, 2012 12:56 am
Re: API for write-protected Calc or Writer ?
Perfect now it works. Thanks for the help.
OpenOffice 3.3.0
Window 7
Window 7