Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: e8505c2946be0c8485182c490f3b03b1d446d048 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<!-- **************************************************************************
#
# Copyright  (c) 2004-2010 Oracle Corporation.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors: 
#
#    Inc., Winston Prakash
#        
#
#************************************************************************** --> 


<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler">
  <j:invokeStatic var="fromEncoded" className="java.net.URLEncoder" method="encode">

   <j:arg value="${if (request.session.attribute('from')!=null) request.session.getAttribute('from');  else if (request.getParameter('from')!=null) request.getParameter('from'); else if (request.requestURI=='/loginError' || request.requestURI=='/login') '/'; else request.requestURI;}"/>
   <j:arg value="UTF-8"/>

  </j:invokeStatic>
  
  <j:set var="from" value="${if (request.session.attribute('from')!=null) request.session.getAttribute('from');  else if (request.getParameter('from')!=null) request.getParameter('from'); else if (request.requestURI=='/loginError' || request.requestURI=='/login') '/'; else request.requestURI;}" />
   
  
    <script type="text/javascript">
        
        function showLoginDialog(){
            jQuery.blockUI({
              message: jQuery('#loginDialog'),
              css: { 
                width: '350px'
              },
              title:  'Confirmation'
            });
            jQuery('j_username').focus();
        }

        function submitForm(){
            jQuery('#loginMsg').css({ opacity: 1.0 });
            jQuery('#loginError').css({ opacity: 0.0 });
            var dataString = jQuery("#loginForm").serialize();
            jQuery.ajax({
              type: 'POST',
              url: "${rootURL}/${app.securityRealm.authenticationGatewayUrl}",
              data: dataString,
              success: function(){
                window.location.href="${from}";
              },
              error: function(){
                jQuery('#loginError').css({ opacity: 1.0 });
                jQuery('#loginMsg').css({ opacity: 0.0 });
              },
              dataType: "html"
            }); 
        }

        jQuery(document).ready(function() {
        
            jQuery('#j_username').keypress(function(e){
              if(e.which == 13){
                submitForm();
              }
            });
            
            jQuery('#j_password').keypress(function(e){
              if(e.which == 13){
                submitForm();
              }
            });


            jQuery('#loginButton').click(function() {
                 submitForm();
            });
            

            jQuery('#cancelButton').click(function() {
                jQuery.unblockUI();
                jQuery('#j_username').attr({value:""});
                jQuery('#j_password').attr({value:""});
                jQuery('#loginError').css({ opacity: 0.0 });
                jQuery('#loginMsg').css({ opacity: 0.0 });
                return false;
            });

        });

    </script>

    <!-- We cannot use ajax in case of container based authentication (LegacySecurityRealm)
         because of the HTTP Status 400 - Invalid direct reference to form login page -->
    <j:choose>
        <j:when test="${app.securityRealm.loginUrl=='loginEntry'}">
            <a style="color:inherit" href="${rootURL}/${app.securityRealm.loginUrl}?from=${from}">
                <b>${%login}</b>
            </a>
        </j:when>
        <j:otherwise>
            <a href="${rootURL}/${app.securityRealm.loginUrl}?from=${fromEncoded}"
               onclick="showLoginDialog(); return false;">
                <b>${%login}</b>
            </a>
        </j:otherwise>
    </j:choose>

    <div id="loginDialog" style="display:none; cursor: default">
        <j:set var="submitFrom" value="${from}" />
        <st:include page="loginDialog.jelly" />
    </div>

</j:jelly>

Back to the top