added extensio to support oAuth2 requesting applications

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

View File

@ -50,9 +50,6 @@
this application's request to access your member data and interact this application's request to access your member data and interact
with D4Science on your behalf. with D4Science on your behalf.
<p> <p>
<p>
<button class="btn" onClick="location.href='<%=context.getGatewayURL(request)%>'">Cancel</button>
</p>
</div> </div>
<% <%
} else { } else {

View File

@ -20,7 +20,8 @@
<script> <script>
window.jQuery window.jQuery
|| document || document
.write('<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" type="text/javascript"><\/script>') .write(
'<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" type="text/javascript"><\/script>')
</script> </script>
<script type="text/javascript" <script type="text/javascript"
src="/html/portlet/login/js/bootstrap-collapse.js"></script> src="/html/portlet/login/js/bootstrap-collapse.js"></script>
@ -32,103 +33,112 @@
<link rel="stylesheet" href="/html/portlet/login/css/login-hook.css"> <link rel="stylesheet" href="/html/portlet/login/css/login-hook.css">
<% <%
String[] socials = PropsUtil.getArray("login.form.navigation.socials");
String[] socials = PropsUtil.getArray("login.form.navigation.socials"); PortalContext context = PortalContext.getConfiguration();
String siteUrl = context.getSiteLandingPagePath(request);
PortalContext context = PortalContext.getConfiguration(); String workspaceUrl = siteUrl + GCubePortalConstants.USER_WORKSPACE_FRIENDLY_URL;
String siteUrl = context.getSiteLandingPagePath(request); final String GET_CLIENT_ID_PARAMETER = "client_id";
String workspaceUrl = siteUrl + GCubePortalConstants.USER_WORKSPACE_FRIENDLY_URL; final String GET_SCOPE_PARAMETER = "scope";
final String GET_CLIENT_ID_PARAMETER = "client_id"; boolean hideCreateAccountAndForgotPassword = false;
final String GET_SCOPE_PARAMETER = "scope";
boolean hideCreateAccountAndForgotPassword = false;
%> %>
<c:choose> <c:choose>
<c:when test="<%= themeDisplay.isSignedIn() %>"> <c:when test="<%=themeDisplay.isSignedIn()%>">
<% <%
String signedInAs = HtmlUtil.escape(user.getFullName()); String signedInAs = HtmlUtil.escape(user.getFullName());
if (themeDisplay.isShowMyAccountIcon() && (themeDisplay.getURLMyAccount() != null)) { if (themeDisplay.isShowMyAccountIcon() && (themeDisplay.getURLMyAccount() != null)) {
String myAccountURL = String.valueOf(themeDisplay.getURLMyAccount()); String myAccountURL = String.valueOf(themeDisplay.getURLMyAccount());
if (PropsValues.DOCKBAR_ADMINISTRATIVE_LINKS_SHOW_IN_POP_UP) { if (PropsValues.DOCKBAR_ADMINISTRATIVE_LINKS_SHOW_IN_POP_UP) {
signedInAs = "<a class=\"signed-in\" href=\"javascript:Liferay.Util.openWindow({dialog: {destroyOnHide: true}, title: '" + HtmlUtil.escapeJS(LanguageUtil.get(pageContext, "my-account")) + "', uri: '" + HtmlUtil.escapeJS(myAccountURL) + "'});\">" + signedInAs + "</a>"; signedInAs = "<a class=\"signed-in\" href=\"javascript:Liferay.Util.openWindow({dialog: {destroyOnHide: true}, title: '"
} + HtmlUtil.escapeJS(LanguageUtil.get(pageContext, "my-account")) + "', uri: '"
else { + HtmlUtil.escapeJS(myAccountURL) + "'});\">" + signedInAs + "</a>";
myAccountURL = HttpUtil.setParameter(myAccountURL, "controlPanelCategory", PortletCategoryKeys.MY); } else {
myAccountURL = HttpUtil.setParameter(myAccountURL, "controlPanelCategory",
PortletCategoryKeys.MY);
signedInAs = "<a class=\"signed-in\" href=\"" + HtmlUtil.escape(myAccountURL) + "\">" + signedInAs + "</a>"; signedInAs = "<a class=\"signed-in\" href=\"" + HtmlUtil.escape(myAccountURL) + "\">"
} + signedInAs + "</a>";
} }
}
%> %>
<% <%
String siteMarkUp = "<a href=\"" + HtmlUtil.escape(siteUrl) + "\">" + themeDisplay.getSiteGroupName() +"</a>"; String siteMarkUp = "<a href=\"" + HtmlUtil.escape(siteUrl) + "\">"
String workSpaceMarkUp = "<a href=\"" + HtmlUtil.escape(workspaceUrl) + "\">" + LanguageUtil.get(pageContext, "shared-workspace") +"</a>"; + themeDisplay.getSiteGroupName() + "</a>";
String workSpaceMarkUp = "<a href=\"" + HtmlUtil.escape(workspaceUrl) + "\">"
+ LanguageUtil.get(pageContext, "shared-workspace") + "</a>";
%> %>
<%= LanguageUtil.format(pageContext, "you-are-signed-in-as-x", signedInAs, false) %> <%=LanguageUtil.format(pageContext, "you-are-signed-in-as-x", signedInAs, false)%>
<br> <br>
<%= LanguageUtil.format(pageContext, "go-to-x", siteMarkUp, false) %> <%=LanguageUtil.format(pageContext, "go-to-x", siteMarkUp, false)%>
<br> <br>
<%= LanguageUtil.format(pageContext, "go-to-x", workSpaceMarkUp, false) %> <%=LanguageUtil.format(pageContext, "go-to-x", workSpaceMarkUp, false)%>
</c:when> </c:when>
<c:otherwise> <c:otherwise>
<% <%
String redirect = ParamUtil.getString(request, "redirect");%> String redirect = ParamUtil.getString(request, "redirect");
%>
<!-- include for recongnizing requesting apps--> <!-- include for recongnizing requesting apps-->
<%@ include file="/html/portlet/login/RequestingApplication.jsp"%> <%@ include file="/html/portlet/login/RequestingApplication.jsp"%>
<!-- end include for recongnizing requesting apps--> <!-- end include for recongnizing requesting apps-->
<h4 class="login-sign-in"><%= LanguageUtil.get(pageContext, "sign-in") %></h4> <h4 class="login-sign-in"><%=LanguageUtil.get(pageContext, "sign-in")%></h4>
<% <%
String login = LoginUtil.getLogin(request, "login", company); String login = LoginUtil.getLogin(request, "login", company);
String password = StringPool.BLANK; String password = StringPool.BLANK;
boolean rememberMe = ParamUtil.getBoolean(request, "rememberMe"); boolean rememberMe = ParamUtil.getBoolean(request, "rememberMe");
if (Validator.isNull(authType)) { if (Validator.isNull(authType)) {
authType = company.getAuthType(); authType = company.getAuthType();
} }
%> %>
<portlet:actionURL <portlet:actionURL
secure="<%= PropsValues.COMPANY_SECURITY_AUTH_REQUIRES_HTTPS || request.isSecure() %>" secure="<%=PropsValues.COMPANY_SECURITY_AUTH_REQUIRES_HTTPS || request.isSecure()%>"
var="loginURL"> var="loginURL">
<portlet:param name="struts_action" value="/login/login" /> <portlet:param name="struts_action" value="/login/login" />
</portlet:actionURL> </portlet:actionURL>
<aui:form action="<%= loginURL %>" <aui:form action="<%=loginURL%>"
autocomplete='<%= PropsValues.COMPANY_SECURITY_LOGIN_FORM_AUTOCOMPLETE ? "on" : "off" %>' autocomplete='<%=PropsValues.COMPANY_SECURITY_LOGIN_FORM_AUTOCOMPLETE ? "on" : "off"%>'
cssClass="sign-in-form" method="post" name="fm"> cssClass="sign-in-form" method="post" name="fm">
<aui:input name="saveLastPath" type="hidden" value="<%= false %>" /> <aui:input name="saveLastPath" type="hidden" value="<%=false%>" />
<aui:input name="redirect" type="hidden" value="<%= redirect %>" /> <aui:input name="redirect" type="hidden" value="<%=redirect%>" />
<aui:input name="doActionAfterLogin" type="hidden" <aui:input name="doActionAfterLogin" type="hidden"
value="<%= portletName.equals(PortletKeys.FAST_LOGIN) ? true : false %>" /> value="<%=portletName.equals(PortletKeys.FAST_LOGIN) ? true : false%>" />
<c:choose> <c:choose>
<c:when test='<%= SessionMessages.contains(request, "userAdded") %>'> <c:when test='<%=SessionMessages.contains(request, "userAdded")%>'>
<% <%
String userEmailAddress = (String)SessionMessages.get(request, "userAdded"); String userEmailAddress = (String) SessionMessages.get(request, "userAdded");
String userPassword = (String)SessionMessages.get(request, "userAddedPassword"); String userPassword = (String) SessionMessages.get(request, "userAddedPassword");
%> %>
<div class="alert alert-success"> <div class="alert alert-success">
<c:choose> <c:choose>
<c:when <c:when
test="<%= company.isStrangersVerify() || Validator.isNull(userPassword) %>"> test="<%=company.isStrangersVerify() || Validator.isNull(userPassword)%>">
<%= LanguageUtil.get(pageContext, "thank-you-for-creating-an-account") %> <%=LanguageUtil.get(pageContext, "thank-you-for-creating-an-account")%>
<c:if test="<%= company.isStrangersVerify() %>"> <c:if test="<%=company.isStrangersVerify()%>">
<%= LanguageUtil.format(pageContext, "your-email-verification-code-has-been-sent-to-x", userEmailAddress) %> <%=LanguageUtil.format(pageContext,
"your-email-verification-code-has-been-sent-to-x",
userEmailAddress)%>
</c:if> </c:if>
</c:when> </c:when>
<c:otherwise> <c:otherwise>
<%= LanguageUtil.format(pageContext, "thank-you-for-creating-an-account.-your-password-is-x", userPassword, false) %> <%=LanguageUtil.format(pageContext,
"thank-you-for-creating-an-account.-your-password-is-x", userPassword,
false)%>
</c:otherwise> </c:otherwise>
</c:choose> </c:choose>
@ -138,66 +148,67 @@ boolean hideCreateAccountAndForgotPassword = false;
</div> </div>
</c:when> </c:when>
<c:when <c:when
test='<%= SessionMessages.contains(request, "userPending") %>'> test='<%=SessionMessages.contains(request, "userPending")%>'>
<% <%
String userEmailAddress = (String)SessionMessages.get(request, "userPending"); String userEmailAddress = (String) SessionMessages.get(request, "userPending");
%> %>
<div class="alert alert-success"> <div class="alert alert-success">
<%= LanguageUtil.format(pageContext, "thank-you-for-creating-an-account.-you-will-be-notified-via-email-at-x-when-your-account-has-been-approved", userEmailAddress) %> <%=LanguageUtil.format(pageContext,
"thank-you-for-creating-an-account.-you-will-be-notified-via-email-at-x-when-your-account-has-been-approved",
userEmailAddress)%>
</div> </div>
</c:when> </c:when>
</c:choose> </c:choose>
<liferay-ui:error exception="<%= AuthException.class %>" <liferay-ui:error exception="<%=AuthException.class%>"
message="authentication-failed" /> message="authentication-failed" />
<liferay-ui:error exception="<%= CompanyMaxUsersException.class %>" <liferay-ui:error exception="<%=CompanyMaxUsersException.class%>"
message="unable-to-login-because-the-maximum-number-of-users-has-been-reached" /> message="unable-to-login-because-the-maximum-number-of-users-has-been-reached" />
<liferay-ui:error <liferay-ui:error
exception="<%= CookieNotSupportedException.class %>" exception="<%=CookieNotSupportedException.class%>"
message="authentication-failed-please-enable-browser-cookies" /> message="authentication-failed-please-enable-browser-cookies" />
<liferay-ui:error exception="<%= NoSuchUserException.class %>" <liferay-ui:error exception="<%=NoSuchUserException.class%>"
message="authentication-failed" /> message="authentication-failed" />
<liferay-ui:error exception="<%= PasswordExpiredException.class %>" <liferay-ui:error exception="<%=PasswordExpiredException.class%>"
message="your-password-has-expired" /> message="your-password-has-expired" />
<liferay-ui:error exception="<%= UserEmailAddressException.class %>" <liferay-ui:error exception="<%=UserEmailAddressException.class%>"
message="authentication-failed" /> message="authentication-failed" />
<liferay-ui:error exception="<%= UserLockoutException.class %>" <liferay-ui:error exception="<%=UserLockoutException.class%>"
message="this-account-has-been-locked" /> message="this-account-has-been-locked" />
<liferay-ui:error exception="<%= UserPasswordException.class %>" <liferay-ui:error exception="<%=UserPasswordException.class%>"
message="authentication-failed" /> message="authentication-failed" />
<liferay-ui:error exception="<%= UserScreenNameException.class %>" <liferay-ui:error exception="<%=UserScreenNameException.class%>"
message="authentication-failed" /> message="authentication-failed" />
<aui:fieldset> <aui:fieldset>
<% <%
String loginLabel = null; String loginLabel = null;
if (authType.equals(CompanyConstants.AUTH_TYPE_EA)) { if (authType.equals(CompanyConstants.AUTH_TYPE_EA)) {
loginLabel = "email-address"; loginLabel = "email-address";
} } else if (authType.equals(CompanyConstants.AUTH_TYPE_SN)) {
else if (authType.equals(CompanyConstants.AUTH_TYPE_SN)) { loginLabel = "screen-name";
loginLabel = "screen-name"; } else if (authType.equals(CompanyConstants.AUTH_TYPE_ID)) {
} loginLabel = "id";
else if (authType.equals(CompanyConstants.AUTH_TYPE_ID)) { }
loginLabel = "id"; %>
}
%>
<div class="custom-form-login-wrapper"> <div class="custom-form-login-wrapper">
<aui:input <aui:input
autoFocus="<%= windowState.equals(LiferayWindowState.EXCLUSIVE) || windowState.equals(WindowState.MAXIMIZED) %>" autoFocus="<%=windowState.equals(LiferayWindowState.EXCLUSIVE)
|| windowState.equals(WindowState.MAXIMIZED)%>"
cssClass="clearable login-identifier input-xlarge" cssClass="clearable login-identifier input-xlarge"
placeholder="<%= loginLabel %>" label="" name="login" placeholder="<%=loginLabel%>" label="" name="login"
showRequiredLabel="<%= false %>" type="text"> showRequiredLabel="<%=false%>" type="text">
<aui:validator name="required" /> <aui:validator name="required" />
</aui:input> </aui:input>
<aui:input name="password" placeholder="password" <aui:input name="password" placeholder="password"
cssClass="login-password input-xlarge" label="" cssClass="login-password input-xlarge" label=""
showRequiredLabel="<%= false %>" type="password" showRequiredLabel="<%=false%>" type="password"
value="<%= password %>"> value="<%=password%>">
<aui:validator name="required" /> <aui:validator name="required" />
</aui:input> </aui:input>
@ -209,9 +220,9 @@ boolean hideCreateAccountAndForgotPassword = false;
key="caps-lock-is-on" /></span> key="caps-lock-is-on" /></span>
<c:if <c:if
test="<%= company.isAutoLogin() && !PropsValues.SESSION_DISABLED %>"> test="<%=company.isAutoLogin() && !PropsValues.SESSION_DISABLED%>">
<div class="login-remember-me"> <div class="login-remember-me">
<aui:input checked="<%= rememberMe %>" name="rememberMe" <aui:input checked="<%=rememberMe%>" name="rememberMe"
type="checkbox" /> type="checkbox" />
</div> </div>
</c:if> </c:if>
@ -219,10 +230,15 @@ boolean hideCreateAccountAndForgotPassword = false;
</aui:fieldset> </aui:fieldset>
</aui:form> </aui:form>
<c:if test="<%=hideCreateAccountAndForgotPassword == true%>">
<div style="text-align: center;">
<button class="btn input-xlarge"
onClick="location.href='<%=context.getGatewayURL(request)%>'">Cancel</button>
</div>
</c:if>
<liferay-util:include page="/html/portlet/login/navigation.jsp" /> <liferay-util:include page="/html/portlet/login/navigation.jsp" />
<c:if test="<%= socials.length > 0 %>"> <c:if test="<%=socials.length > 0%>">
<div class="accordion" id="accordion" role="tablist"> <div class="accordion" id="accordion" role="tablist">
<div class="accordion-group"> <div class="accordion-group">
<div class="accordion-heading"> <div class="accordion-heading">
@ -258,8 +274,8 @@ boolean hideCreateAccountAndForgotPassword = false;
</aui:script> </aui:script>
</c:otherwise> </c:otherwise>
</c:choose> </c:choose>
<c:if test="<%= hideCreateAccountAndForgotPassword == true %>"> <c:if test="<%=hideCreateAccountAndForgotPassword == true%>">
<script> <script>
$(".taglib-icon-list").hide(); $(".taglib-icon-list").hide();
</script> </script>
</c:if> </c:if>