Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CONF
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UvA
CONF
Commits
765c98cb
Commit
765c98cb
authored
Apr 20, 2017
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
null check
parent
0c2670b1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
6 deletions
+6
-6
KeyPairService.java
...main/java/nl/uva/sne/drip/api/service/KeyPairService.java
+3
-3
KeyPairController.java
...n/java/nl/uva/sne/drip/api/v1/rest/KeyPairController.java
+1
-1
KeyPair.java
...c/main/java/nl/uva/sne/drip/data/v1/external/KeyPair.java
+2
-2
No files found.
drip-api/src/main/java/nl/uva/sne/drip/api/service/KeyPairService.java
View file @
765c98cb
...
...
@@ -59,11 +59,11 @@ public class KeyPairService {
return
k
;
}
public
KeyPair
save
(
KeyPair
upk
)
{
public
KeyPair
save
(
KeyPair
keyPair
)
{
User
user
=
(
User
)
SecurityContextHolder
.
getContext
().
getAuthentication
().
getPrincipal
();
String
owner
=
user
.
getUsername
();
upk
.
setOwner
(
owner
);
return
dao
.
save
(
upk
);
keyPair
.
setOwner
(
owner
);
return
dao
.
save
(
keyPair
);
}
@PostAuthorize
(
"(hasRole('ROLE_ADMIN'))"
)
...
...
drip-api/src/main/java/nl/uva/sne/drip/api/v1/rest/KeyPairController.java
View file @
765c98cb
...
...
@@ -108,7 +108,7 @@ public class KeyPairController {
@ResponseCode
(
code
=
400
,
condition
=
"Key can't be empty"
)
})
public
@ResponseBody
String
postKey
(
@RequestBody
KeyPair
pair
)
{
String
postKey
Pair
(
@RequestBody
KeyPair
pair
)
{
if
(
pair
.
getPrivateKey
()
==
null
&&
pair
.
getPublicKey
()
==
null
)
{
throw
new
NullKeyException
();
}
...
...
drip-api/src/main/java/nl/uva/sne/drip/data/v1/external/KeyPair.java
View file @
765c98cb
...
...
@@ -42,7 +42,7 @@ public class KeyPair extends OwnedObject {
* @throws nl.uva.sne.drip.api.exception.KeyException
*/
public
void
setPrivateKey
(
Key
privateKey
)
throws
KeyException
{
if
(
privateKey
.
getType
()
!=
Key
.
KeyType
.
PRIVATE
)
{
if
(
privateKey
!=
null
&&
privateKey
.
getType
()
!=
Key
.
KeyType
.
PRIVATE
)
{
throw
new
KeyException
(
"Trying to add public key to private"
);
}
this
.
privateKey
=
privateKey
;
...
...
@@ -60,7 +60,7 @@ public class KeyPair extends OwnedObject {
* @throws nl.uva.sne.drip.api.exception.KeyException
*/
public
void
setPublicKey
(
Key
publicKey
)
throws
KeyException
{
if
(
p
rivate
Key
.
getType
()
!=
Key
.
KeyType
.
PUBLIC
)
{
if
(
p
ublicKey
!=
null
&&
public
Key
.
getType
()
!=
Key
.
KeyType
.
PUBLIC
)
{
throw
new
KeyException
(
"Trying to add private to public"
);
}
this
.
publicKey
=
publicKey
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment