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
with D4Science on your behalf.
<p>
<p>
<button class="btn" onClick="location.href='<%=context.getGatewayURL(request)%>'">Cancel</button>
</p>
</div>
<%
} else {

View File

@ -20,7 +20,8 @@
<script>
window.jQuery
|| 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 type="text/javascript"
src="/html/portlet/login/js/bootstrap-collapse.js"></script>
@ -32,103 +33,112 @@
<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);
String workspaceUrl = siteUrl + GCubePortalConstants.USER_WORKSPACE_FRIENDLY_URL;
final String GET_CLIENT_ID_PARAMETER = "client_id";
final String GET_SCOPE_PARAMETER = "scope";
boolean hideCreateAccountAndForgotPassword = false;
PortalContext context = PortalContext.getConfiguration();
String siteUrl = context.getSiteLandingPagePath(request);
String workspaceUrl = siteUrl + GCubePortalConstants.USER_WORKSPACE_FRIENDLY_URL;
final String GET_CLIENT_ID_PARAMETER = "client_id";
final String GET_SCOPE_PARAMETER = "scope";
boolean hideCreateAccountAndForgotPassword = false;
%>
<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)) {
String myAccountURL = String.valueOf(themeDisplay.getURLMyAccount());
if (themeDisplay.isShowMyAccountIcon() && (themeDisplay.getURLMyAccount() != null)) {
String myAccountURL = String.valueOf(themeDisplay.getURLMyAccount());
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>";
}
else {
myAccountURL = HttpUtil.setParameter(myAccountURL, "controlPanelCategory", PortletCategoryKeys.MY);
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>";
} 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 workSpaceMarkUp = "<a href=\"" + HtmlUtil.escape(workspaceUrl) + "\">" + LanguageUtil.get(pageContext, "shared-workspace") +"</a>";
String siteMarkUp = "<a href=\"" + HtmlUtil.escape(siteUrl) + "\">"
+ 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>
<%= LanguageUtil.format(pageContext, "go-to-x", siteMarkUp, false) %>
<%=LanguageUtil.format(pageContext, "go-to-x", siteMarkUp, false)%>
<br>
<%= LanguageUtil.format(pageContext, "go-to-x", workSpaceMarkUp, false) %>
<%=LanguageUtil.format(pageContext, "go-to-x", workSpaceMarkUp, false)%>
</c:when>
<c:otherwise>
<%
String redirect = ParamUtil.getString(request, "redirect");%>
<%
String redirect = ParamUtil.getString(request, "redirect");
%>
<!-- include for recongnizing requesting apps-->
<%@ include file="/html/portlet/login/RequestingApplication.jsp"%>
<!-- 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 password = StringPool.BLANK;
boolean rememberMe = ParamUtil.getBoolean(request, "rememberMe");
String login = LoginUtil.getLogin(request, "login", company);
String password = StringPool.BLANK;
boolean rememberMe = ParamUtil.getBoolean(request, "rememberMe");
if (Validator.isNull(authType)) {
authType = company.getAuthType();
}
if (Validator.isNull(authType)) {
authType = company.getAuthType();
}
%>
<portlet:actionURL
secure="<%= PropsValues.COMPANY_SECURITY_AUTH_REQUIRES_HTTPS || request.isSecure() %>"
secure="<%=PropsValues.COMPANY_SECURITY_AUTH_REQUIRES_HTTPS || request.isSecure()%>"
var="loginURL">
<portlet:param name="struts_action" value="/login/login" />
</portlet:actionURL>
<aui:form action="<%= loginURL %>"
autocomplete='<%= PropsValues.COMPANY_SECURITY_LOGIN_FORM_AUTOCOMPLETE ? "on" : "off" %>'
<aui:form action="<%=loginURL%>"
autocomplete='<%=PropsValues.COMPANY_SECURITY_LOGIN_FORM_AUTOCOMPLETE ? "on" : "off"%>'
cssClass="sign-in-form" method="post" name="fm">
<aui:input name="saveLastPath" type="hidden" value="<%= false %>" />
<aui:input name="redirect" type="hidden" value="<%= redirect %>" />
<aui:input name="saveLastPath" type="hidden" value="<%=false%>" />
<aui:input name="redirect" type="hidden" value="<%=redirect%>" />
<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:when test='<%= SessionMessages.contains(request, "userAdded") %>'>
<c:when test='<%=SessionMessages.contains(request, "userAdded")%>'>
<%
String userEmailAddress = (String)SessionMessages.get(request, "userAdded");
String userPassword = (String)SessionMessages.get(request, "userAddedPassword");
%>
String userEmailAddress = (String) SessionMessages.get(request, "userAdded");
String userPassword = (String) SessionMessages.get(request, "userAddedPassword");
%>
<div class="alert alert-success">
<c:choose>
<c:when
test="<%= company.isStrangersVerify() || Validator.isNull(userPassword) %>">
<%= LanguageUtil.get(pageContext, "thank-you-for-creating-an-account") %>
test="<%=company.isStrangersVerify() || Validator.isNull(userPassword)%>">
<%=LanguageUtil.get(pageContext, "thank-you-for-creating-an-account")%>
<c:if test="<%= company.isStrangersVerify() %>">
<%= LanguageUtil.format(pageContext, "your-email-verification-code-has-been-sent-to-x", userEmailAddress) %>
<c:if test="<%=company.isStrangersVerify()%>">
<%=LanguageUtil.format(pageContext,
"your-email-verification-code-has-been-sent-to-x",
userEmailAddress)%>
</c:if>
</c:when>
<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:choose>
@ -138,66 +148,67 @@ boolean hideCreateAccountAndForgotPassword = false;
</div>
</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">
<%= 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>
</c:when>
</c:choose>
<liferay-ui:error exception="<%= AuthException.class %>"
<liferay-ui:error exception="<%=AuthException.class%>"
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" />
<liferay-ui:error
exception="<%= CookieNotSupportedException.class %>"
exception="<%=CookieNotSupportedException.class%>"
message="authentication-failed-please-enable-browser-cookies" />
<liferay-ui:error exception="<%= NoSuchUserException.class %>"
<liferay-ui:error exception="<%=NoSuchUserException.class%>"
message="authentication-failed" />
<liferay-ui:error exception="<%= PasswordExpiredException.class %>"
<liferay-ui:error exception="<%=PasswordExpiredException.class%>"
message="your-password-has-expired" />
<liferay-ui:error exception="<%= UserEmailAddressException.class %>"
<liferay-ui:error exception="<%=UserEmailAddressException.class%>"
message="authentication-failed" />
<liferay-ui:error exception="<%= UserLockoutException.class %>"
<liferay-ui:error exception="<%=UserLockoutException.class%>"
message="this-account-has-been-locked" />
<liferay-ui:error exception="<%= UserPasswordException.class %>"
<liferay-ui:error exception="<%=UserPasswordException.class%>"
message="authentication-failed" />
<liferay-ui:error exception="<%= UserScreenNameException.class %>"
<liferay-ui:error exception="<%=UserScreenNameException.class%>"
message="authentication-failed" />
<aui:fieldset>
<%
String loginLabel = null;
if (authType.equals(CompanyConstants.AUTH_TYPE_EA)) {
loginLabel = "email-address";
}
else if (authType.equals(CompanyConstants.AUTH_TYPE_SN)) {
loginLabel = "screen-name";
}
else if (authType.equals(CompanyConstants.AUTH_TYPE_ID)) {
loginLabel = "id";
}
%>
if (authType.equals(CompanyConstants.AUTH_TYPE_EA)) {
loginLabel = "email-address";
} else if (authType.equals(CompanyConstants.AUTH_TYPE_SN)) {
loginLabel = "screen-name";
} else if (authType.equals(CompanyConstants.AUTH_TYPE_ID)) {
loginLabel = "id";
}
%>
<div class="custom-form-login-wrapper">
<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"
placeholder="<%= loginLabel %>" label="" name="login"
showRequiredLabel="<%= false %>" type="text">
placeholder="<%=loginLabel%>" label="" name="login"
showRequiredLabel="<%=false%>" type="text">
<aui:validator name="required" />
</aui:input>
<aui:input name="password" placeholder="password"
cssClass="login-password input-xlarge" label=""
showRequiredLabel="<%= false %>" type="password"
value="<%= password %>">
showRequiredLabel="<%=false%>" type="password"
value="<%=password%>">
<aui:validator name="required" />
</aui:input>
@ -209,9 +220,9 @@ boolean hideCreateAccountAndForgotPassword = false;
key="caps-lock-is-on" /></span>
<c:if
test="<%= company.isAutoLogin() && !PropsValues.SESSION_DISABLED %>">
test="<%=company.isAutoLogin() && !PropsValues.SESSION_DISABLED%>">
<div class="login-remember-me">
<aui:input checked="<%= rememberMe %>" name="rememberMe"
<aui:input checked="<%=rememberMe%>" name="rememberMe"
type="checkbox" />
</div>
</c:if>
@ -219,10 +230,15 @@ boolean hideCreateAccountAndForgotPassword = false;
</aui:fieldset>
</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" />
<c:if test="<%= socials.length > 0 %>">
<c:if test="<%=socials.length > 0%>">
<div class="accordion" id="accordion" role="tablist">
<div class="accordion-group">
<div class="accordion-heading">
@ -258,8 +274,8 @@ boolean hideCreateAccountAndForgotPassword = false;
</aui:script>
</c:otherwise>
</c:choose>
<c:if test="<%= hideCreateAccountAndForgotPassword == true %>">
<c:if test="<%=hideCreateAccountAndForgotPassword == true%>">
<script>
$(".taglib-icon-list").hide();
</script>
$(".taglib-icon-list").hide();
</script>
</c:if>