Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
f752a276
Commit
f752a276
authored
12 years ago
by
Björn Schießle
Browse files
Options
Downloads
Patches
Plain Diff
write keyfiles to server
parent
931c4695
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
apps/files_encryption/lib/keymanager.php
+1
-1
1 addition, 1 deletion
apps/files_encryption/lib/keymanager.php
lib/filestorage/local.php
+1
-1
1 addition, 1 deletion
lib/filestorage/local.php
lib/ocs.php
+31
-11
31 additions, 11 deletions
lib/ocs.php
with
33 additions
and
13 deletions
apps/files_encryption/lib/keymanager.php
+
1
−
1
View file @
f752a276
...
...
@@ -118,7 +118,7 @@ class Keymanager {
\OC_FileProxy
::
$enabled
=
false
;
$view
=
new
\OC_FilesystemView
(
'/'
.
$userId
.
'/'
.
'files_encryption'
);
$view
=
new
\OC_FilesystemView
(
'/'
.
$userId
.
'/'
.
'files_encryption
/keyfiles
'
);
$path_parts
=
pathinfo
(
$path
);
if
(
!
$view
->
file_exists
(
$path_parts
[
'dirname'
]))
$view
->
mkdir
(
$path_parts
[
'dirname'
]);
$result
=
$view
->
file_put_contents
(
'/'
.
$path
.
'.key'
,
$key
);
...
...
This diff is collapsed.
Click to expand it.
lib/filestorage/local.php
+
1
−
1
View file @
f752a276
...
...
@@ -12,7 +12,7 @@ class OC_Filestorage_Local extends OC_Filestorage_Common{
}
}
public
function
mkdir
(
$path
){
return
@
mkdir
(
$this
->
datadir
.
$path
);
return
@
mkdir
(
$this
->
datadir
.
$path
,
0755
,
true
);
}
public
function
rmdir
(
$path
){
return
@
rmdir
(
$this
->
datadir
.
$path
);
...
...
This diff is collapsed.
Click to expand it.
lib/ocs.php
+
31
−
11
View file @
f752a276
...
...
@@ -183,11 +183,24 @@ class OC_OCS {
}
elseif
((
$method
==
'get'
)
and
(
$ex
[
$paracount
-
6
]
==
'v1.php'
)
and
(
$ex
[
$paracount
-
5
]
==
'cloud'
)
and
(
$ex
[
$paracount
-
4
]
==
'user'
)
and
(
$ex
[
$paracount
-
2
]
==
'privatekey'
)){
$user
=
$ex
[
$paracount
-
3
];
OC_OCS
::
privateKeyGet
(
$format
,
$user
);
//keysetprivate
}
elseif
((
$method
==
'post'
)
and
(
$ex
[
$paracount
-
6
]
==
'v1.php'
)
and
(
$ex
[
$paracount
-
5
]
==
'cloud'
)
and
(
$ex
[
$paracount
-
4
]
==
'user'
)
and
(
$ex
[
$paracount
-
2
]
==
'privatekey'
)){
$user
=
$ex
[
$paracount
-
3
];
$key
=
self
::
readData
(
'post'
,
'key'
,
'string'
);
OC_OCS
::
privateKeySet
(
$format
,
$user
,
$key
);
// keygetfiles
}
elseif
((
$method
==
'get'
)
and
(
$ex
[
$paracount
-
6
]
==
'v1.php'
)
and
(
$ex
[
$paracount
-
5
]
==
'cloud'
)
and
(
$ex
[
$paracount
-
4
]
==
'user'
)
and
(
$ex
[
$paracount
-
2
]
==
'filekey'
)){
$user
=
$ex
[
$paracount
-
3
];
OC_OCS
::
fileKeyGet
(
$format
,
$user
);
//keysetfiles
}
elseif
((
$method
==
'post'
)
and
(
$ex
[
$paracount
-
6
]
==
'v1.php'
)
and
(
$ex
[
$paracount
-
5
]
==
'cloud'
)
and
(
$ex
[
$paracount
-
4
]
==
'user'
)
and
(
$ex
[
$paracount
-
2
]
==
'filekey'
)){
$user
=
$ex
[
$paracount
-
3
];
$key
=
self
::
readData
(
'post'
,
'key'
,
'string'
);
$file
=
self
::
readData
(
'post'
,
'file'
,
'string'
);
OC_OCS
::
fileKeySet
(
$format
,
$user
,
$file
,
$key
);
// add more calls here
// please document all the call in the draft spec
...
...
@@ -766,7 +779,7 @@ class OC_OCS {
$login
=
OC_OCS
::
checkpassword
();
if
(
OC_Group
::
inGroup
(
$login
,
'admin'
)
or
(
$login
==
$user
))
{
if
(
OC_User
::
userExists
(
$user
)){
//TODO: GET file key
//TODO: GET file key
, check needed if it is a shared file or not
$xml
=
array
();
$xml
[
'key'
]
=
"this is the key for
$file
"
;
$txt
=
OC_OCS
::
generatexml
(
$format
,
'ok'
,
100
,
''
,
$xml
,
'cloud'
,
''
,
1
,
0
,
0
);
...
...
@@ -787,18 +800,25 @@ class OC_OCS {
* @param string $key
* @return string xml/json
*/
private
static
function
fileKeySet
(
$format
,
$user
,
$file
,
$key
)
{
private
static
function
fileKeySet
(
$format
,
$user
,
$file
,
$key
)
{
$login
=
OC_OCS
::
checkpassword
();
if
(
$login
==
$user
)
{
if
(
OC_User
::
userExists
(
$user
)){
//TODO: SET file key
echo
self
::
generateXml
(
''
,
'ok'
,
100
,
'File key uploaded'
);
}
else
{
echo
self
::
generateXml
(
''
,
'fail'
,
300
,
'User does not exist'
);
if
((
$login
==
$user
))
{
if
(
OC_App
::
isEnabled
(
'files_encryption'
)
&&
OCA_Encryption\Crypt
::
mode
(
$user
)
===
'client'
)
{
if
((
$key
=
OCA_Encryption\Keymanager
::
setFileKey
(
$user
,
$file
,
$key
)))
{
// TODO: emit hook to move file from tmp location to the right place
echo
self
::
generateXml
(
''
,
'ok'
,
100
,
''
);
return
true
;
}
else
{
echo
self
::
generateXml
(
''
,
'fail'
,
404
,
'could not write key file'
);
}
}
else
{
echo
self
::
generateXml
(
''
,
'fail'
,
300
,
'Client side encryption not enabled for user '
.
$user
);
}
}
else
{
echo
self
::
generateXml
(
''
,
'fail'
,
300
,
'You don´t have permission to access this ressource.'
);
}
}
}
//TODO: emit signal to remove file from tmp location
return
false
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment