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
3bbc224a
Commit
3bbc224a
authored
Mar 24, 2021
by
michael.simon
Browse files
add possiblity to store idp selection
parent
772e28b0
Changes
3
Hide whitespace changes
Inline
Side-by-side
bwreg-webapp/src/main/java/edu/kit/scc/webreg/bean/DiscoveryLoginBean.java
View file @
3bbc224a
...
@@ -22,6 +22,7 @@ import javax.faces.context.ExternalContext;
...
@@ -22,6 +22,7 @@ import javax.faces.context.ExternalContext;
import
javax.faces.context.FacesContext
;
import
javax.faces.context.FacesContext
;
import
javax.faces.event.ComponentSystemEvent
;
import
javax.faces.event.ComponentSystemEvent
;
import
javax.inject.Inject
;
import
javax.inject.Inject
;
import
javax.servlet.http.Cookie
;
import
edu.kit.scc.webreg.bootstrap.ApplicationConfig
;
import
edu.kit.scc.webreg.bootstrap.ApplicationConfig
;
import
edu.kit.scc.webreg.entity.FederationEntity
;
import
edu.kit.scc.webreg.entity.FederationEntity
;
...
@@ -42,6 +43,7 @@ import edu.kit.scc.webreg.service.oidc.OidcOpConfigurationService;
...
@@ -42,6 +43,7 @@ import edu.kit.scc.webreg.service.oidc.OidcOpConfigurationService;
import
edu.kit.scc.webreg.service.oidc.OidcRpConfigurationService
;
import
edu.kit.scc.webreg.service.oidc.OidcRpConfigurationService
;
import
edu.kit.scc.webreg.service.saml.FederationSingletonBean
;
import
edu.kit.scc.webreg.service.saml.FederationSingletonBean
;
import
edu.kit.scc.webreg.session.SessionManager
;
import
edu.kit.scc.webreg.session.SessionManager
;
import
edu.kit.scc.webreg.util.CookieHelper
;
import
edu.kit.scc.webreg.util.FacesMessageGenerator
;
import
edu.kit.scc.webreg.util.FacesMessageGenerator
;
@ManagedBean
@ManagedBean
...
@@ -83,11 +85,16 @@ public class DiscoveryLoginBean implements Serializable {
...
@@ -83,11 +85,16 @@ public class DiscoveryLoginBean implements Serializable {
@Inject
@Inject
private
OidcClientConfigurationService
oidcClientConfigService
;
private
OidcClientConfigurationService
oidcClientConfigService
;
@Inject
private
CookieHelper
cookieHelper
;
private
List
<
FederationEntity
>
federationList
;
private
List
<
FederationEntity
>
federationList
;
private
List
<
SamlIdpMetadataEntity
>
idpList
;
private
List
<
SamlIdpMetadataEntity
>
idpList
;
private
FederationEntity
selectedFederation
;
private
FederationEntity
selectedFederation
;
private
SamlIdpMetadataEntity
selectedIdp
;
private
SamlIdpMetadataEntity
selectedIdp
;
private
Boolean
storeIdpSelection
;
private
List
<
OidcRpConfigurationEntity
>
oidcRpList
;
private
List
<
OidcRpConfigurationEntity
>
oidcRpList
;
private
OidcRpConfigurationEntity
selectedOidcRp
;
private
OidcRpConfigurationEntity
selectedOidcRp
;
...
@@ -136,7 +143,18 @@ public class DiscoveryLoginBean implements Serializable {
...
@@ -136,7 +143,18 @@ public class DiscoveryLoginBean implements Serializable {
messageGenerator
.
addErrorMessage
(
"Das SAML Subsystem ist noch nicht konfiguriert"
);
messageGenerator
.
addErrorMessage
(
"Das SAML Subsystem ist noch nicht konfiguriert"
);
return
;
return
;
}
}
updateIdpList
();
updateIdpList
();
Cookie
idpCookie
=
cookieHelper
.
getCookie
(
"preselect_idp"
);
if
(
idpCookie
!=
null
)
{
Long
idpId
=
Long
.
parseLong
(
idpCookie
.
getValue
());
if
(
idpId
!=
null
)
{
SamlIdpMetadataEntity
idp
=
idpService
.
findById
(
idpId
);
if
(
idp
!=
null
)
{
selectedIdp
=
idp
;
storeIdpSelection
=
true
;
}
}
}
initialized
=
true
;
initialized
=
true
;
}
}
}
}
...
@@ -156,6 +174,12 @@ public class DiscoveryLoginBean implements Serializable {
...
@@ -156,6 +174,12 @@ public class DiscoveryLoginBean implements Serializable {
sessionManager
.
setSpId
(
spConfig
.
getId
());
sessionManager
.
setSpId
(
spConfig
.
getId
());
sessionManager
.
setIdpId
(
selectedIdp
.
getId
());
sessionManager
.
setIdpId
(
selectedIdp
.
getId
());
if
(
storeIdpSelection
)
{
cookieHelper
.
setCookie
(
"preselect_idp"
,
selectedIdp
.
getId
().
toString
(),
356
*
24
*
3600
);
}
else
{
cookieHelper
.
setCookie
(
"preselect_idp"
,
""
,
0
);
}
try
{
try
{
externalContext
.
redirect
(
"/Shibboleth.sso/Login"
);
externalContext
.
redirect
(
"/Shibboleth.sso/Login"
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
...
@@ -318,4 +342,12 @@ public class DiscoveryLoginBean implements Serializable {
...
@@ -318,4 +342,12 @@ public class DiscoveryLoginBean implements Serializable {
return
clientConfig
;
return
clientConfig
;
}
}
public
Boolean
getStoreIdpSelection
()
{
return
storeIdpSelection
;
}
public
void
setStoreIdpSelection
(
Boolean
storeIdpSelection
)
{
this
.
storeIdpSelection
=
storeIdpSelection
;
}
}
}
bwreg-webapp/src/main/java/edu/kit/scc/webreg/util/CookieHelper.java
0 → 100644
View file @
3bbc224a
package
edu.kit.scc.webreg.util
;
import
java.io.Serializable
;
import
javax.enterprise.context.ApplicationScoped
;
import
javax.faces.context.FacesContext
;
import
javax.servlet.http.Cookie
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
@ApplicationScoped
public
class
CookieHelper
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
public
void
setCookie
(
String
name
,
String
value
,
int
expiry
)
{
FacesContext
facesContext
=
FacesContext
.
getCurrentInstance
();
HttpServletRequest
request
=
(
HttpServletRequest
)
facesContext
.
getExternalContext
().
getRequest
();
Cookie
cookie
=
null
;
Cookie
[]
userCookies
=
request
.
getCookies
();
if
(
userCookies
!=
null
&&
userCookies
.
length
>
0
)
{
for
(
int
i
=
0
;
i
<
userCookies
.
length
;
i
++)
{
if
(
userCookies
[
i
].
getName
().
equals
(
name
))
{
cookie
=
userCookies
[
i
];
break
;
}
}
}
if
(
cookie
!=
null
)
{
cookie
.
setValue
(
value
);
}
else
{
cookie
=
new
Cookie
(
name
,
value
);
cookie
.
setPath
(
request
.
getContextPath
());
}
cookie
.
setMaxAge
(
expiry
);
cookie
.
setPath
(
"/"
);
cookie
.
setSecure
(
true
);
HttpServletResponse
response
=
(
HttpServletResponse
)
facesContext
.
getExternalContext
().
getResponse
();
response
.
addCookie
(
cookie
);
}
public
Cookie
getCookie
(
String
name
)
{
FacesContext
facesContext
=
FacesContext
.
getCurrentInstance
();
HttpServletRequest
request
=
(
HttpServletRequest
)
facesContext
.
getExternalContext
().
getRequest
();
Cookie
cookie
=
null
;
Cookie
[]
userCookies
=
request
.
getCookies
();
if
(
userCookies
!=
null
&&
userCookies
.
length
>
0
)
{
for
(
int
i
=
0
;
i
<
userCookies
.
length
;
i
++)
{
if
(
userCookies
[
i
].
getName
().
equals
(
name
))
{
cookie
=
userCookies
[
i
];
return
cookie
;
}
}
}
return
null
;
}
}
bwreg-webapp/src/main/webapp/welcome/index.xhtml
View file @
3bbc224a
...
@@ -73,6 +73,9 @@
...
@@ -73,6 +73,9 @@
var=
"idp"
itemLabel=
"#{idp.displayName == null ? idp.orgName : idp.displayName}"
itemValue=
"#{idp}"
/>
var=
"idp"
itemLabel=
"#{idp.displayName == null ? idp.orgName : idp.displayName}"
itemValue=
"#{idp}"
/>
<p:ajax
event=
"dblclick"
listener=
"#{discoveryLoginBean.login}"
update=
":form"
/>
<p:ajax
event=
"dblclick"
listener=
"#{discoveryLoginBean.login}"
update=
":form"
/>
</p:selectOneListbox>
</p:selectOneListbox>
<h:outputText
value=
"#{messages.store_idp_selection}: "
/>
<h:selectBooleanCheckbox
value=
"#{discoveryLoginBean.storeIdpSelection}"
/>
</h:panelGrid>
</h:panelGrid>
...
...
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