added extensio to support oAuth2 requesting applications with error handling

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portal/liferay62-plugins/login-hook@142016 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2017-02-01 17:12:45 +00:00
parent fb75255689
commit 21c8a9a848
2 changed files with 25 additions and 13 deletions

View File

@ -10,21 +10,21 @@
<%
if (redirect.startsWith(siteUrl + GCubePortalConstants.AUTHORIZATION_FRIENDLY_URL)) {
hideCreateAccountAndForgotPassword = true;
Map<String, String> queryMap = AuthUtil.getQueryMap(redirect);
if (!queryMap.isEmpty()) {
String clientId = queryMap.get(GET_CLIENT_ID_PARAMETER);
String scope = queryMap.get(GET_SCOPE_PARAMETER);
if (clientId != null && clientId.compareTo("") != 0) {
RequestingApp app = AuthUtil.getAuthorisedApplicationInfoFromIs(clientId);
if (app != null) {
%>
<script>
$(".portlet-title-text").text("Sign in to approve application");
</script>
<div style="text-align: center;">
<%
if (app.getLogoURL() != null && !app.getLogoURL().isEmpty()) {
hideCreateAccountAndForgotPassword = true;
Map<String, String> queryMap = AuthUtil.getQueryMap(redirect);
if (!queryMap.isEmpty()) {
String clientId = queryMap.get(GET_CLIENT_ID_PARAMETER);
String scope = queryMap.get(GET_SCOPE_PARAMETER);
if (clientId != null && clientId.compareTo("") != 0) {
RequestingApp app = AuthUtil.getAuthorisedApplicationInfoFromIs(clientId);
if (app != null) {
if (app.getLogoURL() != null && !app.getLogoURL().isEmpty()) {
%>
<p>
<img style="width: 100px;" src="<%=app.getLogoURL()%>" />
@ -53,7 +53,16 @@
</div>
<%
} else {
System.out.println(
%>
<p class="lead">We're sorry your application is not authorised by
D4Science</p>
<p style="color: red;">
The client_id does not exist or something occurred in retrieving it
from the Information System: " (<%=clientId%>)
</p>
<%
clientNotAuthorised = true;
System.out.println(
"The client_id does not exist or something occurred in retrieving it from IS: "
+ clientId);
}

View File

@ -41,6 +41,7 @@
final String GET_CLIENT_ID_PARAMETER = "client_id";
final String GET_SCOPE_PARAMETER = "scope";
boolean hideCreateAccountAndForgotPassword = false;
boolean clientNotAuthorised = false;
%>
<c:choose>
<c:when test="<%=themeDisplay.isSignedIn()%>">
@ -105,8 +106,9 @@
var="loginURL">
<portlet:param name="struts_action" value="/login/login" />
</portlet:actionURL>
<!-- START CLIENT NOT AUTHORISED -->
<c:if test="<%=clientNotAuthorised == false%>">
<aui:form action="<%=loginURL%>"
autocomplete='<%=PropsValues.COMPANY_SECURITY_LOGIN_FORM_AUTOCOMPLETE ? "on" : "off"%>'
cssClass="sign-in-form" method="post" name="fm">
@ -258,7 +260,8 @@
</div>
</div>
</c:if>
<!-- END CLIENT NOT AUTHORISED -->
</c:if>
<aui:script use="aui-base">
var password = A.one('#<portlet:namespace />password');