Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
reg-app
Regapp
Commits
dcb878f7
Commit
dcb878f7
authored
Feb 18, 2016
by
michael.simon
Browse files
access service password by serviceShortName
parent
a873fed2
Changes
2
Show whitespace changes
Inline
Side-by-side
bwreg-webapp/src/main/java/edu/kit/scc/webreg/bean/SetServicePasswordBean.java
View file @
dcb878f7
...
...
@@ -25,6 +25,7 @@ import edu.kit.scc.webreg.exc.NotAuthorizedException;
import
edu.kit.scc.webreg.exc.RegisterException
;
import
edu.kit.scc.webreg.sec.AuthorizationBean
;
import
edu.kit.scc.webreg.service.RegistryService
;
import
edu.kit.scc.webreg.service.ServiceService
;
import
edu.kit.scc.webreg.service.UserService
;
import
edu.kit.scc.webreg.service.reg.RegisterUserService
;
import
edu.kit.scc.webreg.service.reg.RegisterUserWorkflow
;
...
...
@@ -41,6 +42,9 @@ public class SetServicePasswordBean implements Serializable {
@Inject
private
RegistryService
registryService
;
@Inject
private
ServiceService
serviceService
;
@Inject
private
AuthorizationBean
authBean
;
...
...
@@ -61,19 +65,32 @@ public class SetServicePasswordBean implements Serializable {
private
UserEntity
userEntity
;
private
Long
id
;
private
String
serviceShortName
;
private
String
password1
,
password2
;
private
Long
initialized
Id
;
private
Boolean
initialized
=
false
;
public
void
preRenderView
(
ComponentSystemEvent
ev
)
{
if
(
id
!=
initializedId
)
{
if
(!
initialized
)
{
userEntity
=
userService
.
findById
(
sessionManager
.
getUserId
());
if
(
id
!=
null
)
{
registryEntity
=
registryService
.
findById
(
id
);
if
(
registryEntity
==
null
)
throw
new
IllegalArgumentException
(
"Service Registry not found"
);
userEntity
=
userService
.
findById
(
sessionManager
.
getUserId
());
serviceEntity
=
registryEntity
.
getService
();
}
else
if
(
serviceShortName
!=
null
)
{
serviceEntity
=
serviceService
.
findByShortName
(
serviceShortName
);
if
(
serviceEntity
==
null
)
throw
new
IllegalArgumentException
(
"Service not found"
);
registryEntity
=
registryService
.
findByServiceAndUserAndStatus
(
serviceEntity
,
userEntity
,
RegistryStatus
.
ACTIVE
);
}
if
(!
registryEntity
.
getUser
().
getId
().
equals
(
userEntity
.
getId
()))
throw
new
NotAuthorizedException
(
"Not authorized to view this item"
);
...
...
@@ -84,7 +101,7 @@ public class SetServicePasswordBean implements Serializable {
password1
=
null
;
password2
=
null
;
initialized
Id
=
id
;
initialized
=
true
;
}
}
...
...
@@ -172,4 +189,12 @@ public class SetServicePasswordBean implements Serializable {
public
void
setPassword2
(
String
password2
)
{
this
.
password2
=
password2
;
}
public
String
getServiceShortName
()
{
return
serviceShortName
;
}
public
void
setServiceShortName
(
String
serviceShortName
)
{
this
.
serviceShortName
=
serviceShortName
;
}
}
bwreg-webapp/src/main/webapp/service/set-password.xhtml
View file @
dcb878f7
...
...
@@ -14,6 +14,7 @@
<f:view>
<f:metadata>
<f:viewParam
name=
"registryId"
value=
"#{setServicePasswordBean.id}"
/>
<f:viewParam
name=
"ssn"
value=
"#{setServicePasswordBean.serviceShortName}"
/>
<f:event
type=
"javax.faces.event.PreRenderViewEvent"
listener=
"#{setServicePasswordBean.preRenderView}"
/>
</f:metadata>
...
...
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