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
bb229f72
Commit
bb229f72
authored
12 years ago
by
Björn Schießle
Browse files
Options
Downloads
Patches
Plain Diff
write private/public key from the client to the server
parent
e5c84488
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
apps/files_encryption/lib/keymanager.php
+25
-6
25 additions, 6 deletions
apps/files_encryption/lib/keymanager.php
lib/ocs.php
+37
-21
37 additions, 21 deletions
lib/ocs.php
with
62 additions
and
27 deletions
apps/files_encryption/lib/keymanager.php
+
25
−
6
View file @
bb229f72
...
...
@@ -73,8 +73,16 @@ class Keymanager {
* @return bool true/false
*/
public
static
function
setPrivateKey
(
$user
,
$key
)
{
$view
=
new
\OC_FilesystemView
(
'/'
.
$user
.
'/files_encryption/'
);
return
$view
->
file_put_contents
(
$user
.
'.private.key'
,
$key
);
\OC_FileProxy
::
$enabled
=
false
;
$view
=
new
\OC_FilesystemView
(
'/'
.
$user
.
'/files_encryption'
);
if
(
!
$view
->
file_exists
(
''
))
$view
->
mkdir
(
''
);
$result
=
$view
->
file_put_contents
(
$user
.
'.private.key'
,
$key
);
\OC_FileProxy
::
$enabled
=
true
;
return
$result
;
}
...
...
@@ -86,8 +94,16 @@ class Keymanager {
* @return bool true/false
*/
public
static
function
setPublicKey
(
$user
,
$key
)
{
$view
=
new
\OC_FilesystemView
(
'/public-keys/'
);
return
$view
->
file_put_contents
(
$user
.
'.public.key'
,
$key
);
\OC_FileProxy
::
$enabled
=
false
;
$view
=
new
\OC_FilesystemView
(
'/public-keys'
);
if
(
!
$view
->
file_exists
(
''
))
$view
->
mkdir
(
''
);
$result
=
$view
->
file_put_contents
(
$user
.
'.public.key'
,
$key
);
\OC_FileProxy
::
$enabled
=
true
;
return
$result
;
}
/**
...
...
@@ -103,10 +119,13 @@ class Keymanager {
\OC_FileProxy
::
$enabled
=
false
;
$view
=
new
\OC_FilesystemView
(
'/'
.
$userId
.
'/'
.
'files_encryption'
);
return
$view
->
file_put_contents
(
'/'
.
$path
.
'.key'
,
$key
);
$path_parts
=
pathinfo
(
$path
);
if
(
!
$view
->
file_exists
(
$path_parts
[
'dirname'
]))
$view
->
mkdir
(
$path_parts
[
'dirname'
]);
$result
=
$view
->
file_put_contents
(
'/'
.
$path
.
'.key'
,
$key
);
\OC_FileProxy
::
$enabled
=
true
;
return
$result
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
lib/ocs.php
+
37
−
21
View file @
bb229f72
...
...
@@ -173,10 +173,20 @@ class OC_OCS {
$user
=
$ex
[
$paracount
-
3
];
OC_OCS
::
publicKeyGet
(
$format
,
$user
);
//keysetpublic
}
elseif
((
$method
==
'post'
)
and
(
$ex
[
$paracount
-
6
]
==
'v1.php'
)
and
(
$ex
[
$paracount
-
5
]
==
'cloud'
)
and
(
$ex
[
$paracount
-
4
]
==
'user'
)
and
(
$ex
[
$paracount
-
2
]
==
'publickey'
)){
$user
=
$ex
[
$paracount
-
3
];
$key
=
self
::
readData
(
'post'
,
'key'
,
'string'
);
OC_OCS
::
publicKeySet
(
$format
,
$user
,
$key
);
// keygetprivate
}
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
);
}
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
);
// add more calls here
...
...
@@ -680,12 +690,15 @@ class OC_OCS {
*/
private
static
function
publicKeySet
(
$format
,
$user
,
$key
)
{
$login
=
OC_OCS
::
checkpassword
();
if
(
$login
==
$user
)
{
if
(
OC_
User
::
userExists
(
$user
))
{
//TODO: SET public key
echo
self
::
generateXml
(
''
,
'ok'
,
100
,
'
Public key uploaded
'
);
if
(
(
$login
==
$user
)
)
{
if
(
OC_
App
::
isEnabled
(
'files_encryption'
)
&&
OCA_Encryption\Crypt
::
mode
(
$user
)
===
'client'
)
{
if
((
$key
=
OCA_Encryption\Keymanager
::
setPublicKey
(
$user
,
$key
)))
{
echo
self
::
generateXml
(
''
,
'ok'
,
100
,
''
);
}
else
{
echo
self
::
generateXml
(
''
,
'fail'
,
300
,
'User does not exist'
);
echo
self
::
generateXml
(
''
,
'fail'
,
404
,
'could not add your public key to the key storage'
);
}
}
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.'
);
...
...
@@ -727,12 +740,15 @@ class OC_OCS {
*/
private
static
function
privateKeySet
(
$format
,
$user
,
$key
)
{
$login
=
OC_OCS
::
checkpassword
();
if
(
$login
==
$user
)
{
if
(
OC_User
::
userExists
(
$user
))
{
//TODO: SET private key
echo
self
::
generateXml
(
''
,
'ok'
,
100
,
'
Private key uploaded
'
);
if
(
(
$login
==
$user
)
)
{
if
(
OC_App
::
isEnabled
(
'files_encryption'
)
&&
OCA_Encryption\Crypt
::
mode
(
$user
)
===
'client'
)
{
if
((
$key
=
OCA_Encryption\Keymanager
::
setPrivateKey
(
$user
,
$key
)))
{
echo
self
::
generateXml
(
''
,
'ok'
,
100
,
''
);
}
else
{
echo
self
::
generateXml
(
''
,
'fail'
,
300
,
'User does not exist'
);
echo
self
::
generateXml
(
''
,
'fail'
,
404
,
'could not add your private key to the key storage'
);
}
}
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.'
);
...
...
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