Project

General

Profile

« Previous | Next » 

Revision 3092

I'm adding the two jsp files that originated in the KNB skin developed
by Matthew Brooke, modified for the PISCO skin.

View differences:

lib/style/skins/pisco/templates/jsp/include_session_vars.jsp
1
<%@ page import="edu.ucsb.nceas.metacat.client.*" %>
2
<% 
3
 /**
4
  *  '$RCSfile$'
5
  *      Authors: Matt Jones, Chad Berkley
6
  *    Copyright: 2000 Regents of the University of California and the
7
  *               National Center for Ecological Analysis and Synthesis
8
  *  For Details: http://www.nceas.ucsb.edu/
9
  *
10
  *   '$Author$'
11
  *     '$Date$'
12
  * '$Revision$'
13
  * 
14
  * This program is free software; you can redistribute it and/or modify
15
  * it under the terms of the GNU General Public License as published by
16
  * the Free Software Foundation; either version 2 of the License, or
17
  * (at your option) any later version.
18
  *
19
  * This program is distributed in the hope that it will be useful,
20
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
  * GNU General Public License for more details.
23
  *
24
  * You should have received a copy of the GNU General Public License
25
  * along with this program; if not, write to the Free Software
26
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27
  *
28
  * This is an XSLT (http://www.w3.org/TR/xslt) stylesheet designed to
29
  * convert an XML file showing the resultset of a query
30
  * into an HTML format suitable for rendering with modern web browsers.
31
  */
32

  
33
  //////////////////////////////////////////////////////////////////////////////
34
  //
35
  // NOTE:
36
  //
37
  //  GLOBAL CONSTANTS (SETTINGS SUCH AS METACAT URL, LDAP DOMAIN  AND DEBUG 
38
  //  SWITCH) ARE ALL IN THE INCLUDE FILE "PORTAL_SETTINGS.jsp"
39
  //
40
  //////////////////////////////////////////////////////////////////////////////
41

  
42
  // GLOBAL VARIABLES //////////////////////////////////////////////////////////
43
  String      loginStatus              = null;
44
  String      sess_sessionId           = null;
45
  String      sessionidField           = null;
46
  String      metacatResponse          = null;
47
  String      posted_ldapUserName      = null;
48
  String      typedUserName            = null;
49
  String      posted_organization      = null;
50
  String      posted_password          = null;
51
  String      loginAction              = null;
52
  String      loginButtonLabel         = null;
53
  String      loginEnabledDisabled     = null;
54
  Metacat     metacat                  = null;
55
  HttpSession rfSession                = null;
56
  boolean     isLoggedIn               = false;
57
//String      relativeRoot             = "@style-skins-path@/pisco";
58
//String      knbSiteUrl               = "@knb-site-url@";
59
//String      include_portalhead_title = null;
60
  
61
  //////////////////////////////////////////////////////////////////////////////  
62
  
63
  try {
64
    rfSession = request.getSession(true);
65
    
66
  } catch(Exception e) {
67
  
68
    throw new ServletException("trying to get session: "+e);
69
  }
70
  
71
  Object sess_sessionIdObj = rfSession.getAttribute("sess_sessionIdObj");
72
  
73
  if (sess_sessionIdObj!=null) {
74
    sess_sessionId = (String)sess_sessionIdObj;
75
    
76
    // if sess_sessionIdObj is empty string, that means user has logged out
77
    // (had problems if I set it to null, so used empty string instead)
78
    if (sess_sessionId.length() < 1) sess_sessionId = null;
79
    else isLoggedIn = true;
80
    
81
  } else {
82
    
83
    sess_sessionId = null;
84
  }
85
  
86
  typedUserName   = request.getParameter("username");
87
  typedUserName   = (typedUserName!=null)? typedUserName.trim() : "";
88
  
89
  posted_organization = request.getParameter("organization");
90
  posted_organization = (posted_organization!=null)? posted_organization.trim() : "";
91

  
92
  posted_ldapUserName = "uid=" + typedUserName 
93
                        + ",o=" + posted_organization + LDAP_DOMAIN;
94
  
95
  posted_password = request.getParameter("password");
96
  posted_password = (posted_password!=null)? posted_password.trim() : "";
97
  
98
  loginAction     = request.getParameter("loginAction");
99
  loginAction     = (loginAction!=null)? loginAction.trim() : "";
100
  
101
  //////////////////////////////////////////////////////////////////////////////  
102
  
103
  if (loginAction.equals(LOGOUT_LABEL)) { 
104
  // DO LOGOUT //////////////////////////////////////////////////////////////    
105
  
106
    if (sess_sessionId!=null && rfSession.getAttribute("sess_metacatObj")!=null) {
107
      metacat = (Metacat)(rfSession.getAttribute("sess_metacatObj"));
108
      metacat.logout();      
109
    }
110
    sess_sessionId = null;
111
    rfSession.setAttribute("sess_sessionIdObj", "");
112
    isLoggedIn = false;
113
    
114
  } else if (loginAction.equals(LOGIN_LABEL)) {  
115
  // DO LOGIN ////////////////////////////////////////////////////////////////  
116
  
117
    if (sess_sessionId!=null) isLoggedIn = true;    
118
    else {
119
    
120
      // get metacat object - either cached from session...
121
      if (rfSession.getAttribute("sess_metacatObj")!=null) {
122
        
123
        metacat = (Metacat)(rfSession.getAttribute("sess_metacatObj"));
124
      
125
      } else {   // ...or create it if it doesn't already exist
126
        try {
127
          metacat = MetacatFactory.createMetacatConnection(METACAT_URL);
128
        } catch (MetacatInaccessibleException mie) {
129
          throw new ServletException("Metacat connection to "+METACAT_URL
130
                                                +" failed." + mie.getMessage());
131
        }
132
        if (metacat==null) {
133
          throw new ServletException("Metacat connection to "+METACAT_URL
134
                                          +" failed - Metacat object is NULL!");
135
        }
136
        rfSession.setAttribute("sess_metacatObj", metacat);
137
      }
138
      // now do login...
139
      try {
140
          metacatResponse = metacat.login(posted_ldapUserName, posted_password);
141
          
142
          if (metacatResponse!=null && metacatResponse.indexOf("<login>") >= 0) {
143
            sess_sessionId = metacat.getSessionId();
144
            rfSession.setAttribute("sess_sessionIdObj", 
145
                                  ((sess_sessionId!=null)? sess_sessionId: "") );
146
            isLoggedIn = true;
147
          } else {
148
            loginStatus = "<em class=\"italic\">Incorrect username or password - please try again</em>";
149
            isLoggedIn = false;
150
          }
151
      } catch (MetacatAuthException mae) {
152
          loginStatus = "<em class=\"italic\">Incorrect username or password! - please try again</em>";
153
          isLoggedIn = false;
154
      } catch (MetacatInaccessibleException mie) {
155
          isLoggedIn = false;
156
          loginStatus = "<em class=\"italic\">ERROR logging in - problems connecting - please try later</em>";
157
      }
158
    }
159
  }
160
  
161
  //////////////////////////////////////////////////////////////////////////////  
162

  
163
  if (isLoggedIn) {
164
    loginButtonLabel     = LOGOUT_LABEL;
165
    loginEnabledDisabled = "disabled";
166
    if (sess_sessionId!=null && sess_sessionId.length()>0) {
167
      sessionidField = "<input type=\"hidden\" name=\"sessionid\"     value=\""
168
                                                          +sess_sessionId+"\">";
169
    } else {
170
      sessionidField = "";
171
    }
172
    // if loginStatus has already been set above, don't overwrite it...
173
    if (loginStatus==null) loginStatus 
174
                          = "<em class=\"italic\">logged in as: " +posted_ldapUserName+"</em>";
175
  } else {
176
    loginButtonLabel     = LOGIN_LABEL;
177
    loginEnabledDisabled = "";
178
    sessionidField = "";
179
    // if loginStatus has already been set above, don't overwrite it...
180
    if (loginStatus==null) loginStatus 
181
                      = "<em class=\"italic\">Not logged in: </em>";
182
  }
183

  
184
  if (DEBUG_TO_BROWSER) {
185
%>  
186
<div id="debug">              
187
  <ul>
188
    <li>METACAT_URL:&nbsp;<%=METACAT_URL%></li>
189
    <li>rfSession:&nbsp;<%=rfSession%></li>
190
    <li>metacatResponse:&nbsp;<%=metacatResponse%></li>
191
    <li>posted_ldapUserName:&nbsp;<%=posted_ldapUserName%></li>
192
    <li>posted_password:&nbsp;<%=posted_password%></li>
193
    <li>isLoggedIn:&nbsp;<%=isLoggedIn%></li>
194
    <li>sess_sessionId LOCAL:&nbsp;<%=sess_sessionId%></li>
195
    <li>sess_sessionIdObj FROM SESSION:&nbsp;<%=rfSession.getAttribute("sess_sessionIdObj")%></li>
196
  </ul>
197
</div>
198
<%
199
  }
200
%>
0 201

  
lib/style/skins/pisco/templates/jsp/portal_settings.jsp
1
<%@ page errorPage="jsperrorpage.html" %>
2
<%
3
 /*
4
  *   '$RCSfile$'
5
  *     Authors: Matthew Brooke
6
  *   Copyright: 2000 Regents of the University of California and the
7
  *              National Center for Ecological Analysis and Synthesis
8
  * For Details: http://www.nceas.ucsb.edu/
9
  *
10
  *    '$Author$'
11
  *      '$Date$'
12
  *  '$Revision$'
13
  *
14
  * Settings file for KNB portal
15
  *
16
  * This program is free software; you can redistribute it and/or modify
17
  * it under the terms of the GNU General Public License as published by
18
  * the Free Software Foundation; either version 2 of the License, or
19
  * (at your option) any later version.
20
  *
21
  * This program is distributed in the hope that it will be useful,
22
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
  * GNU General Public License for more details.
25
  *
26
  * You should have received a copy of the GNU General Public License
27
  * along with this program; if not, write to the Free Software
28
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
29
  */
30
%>
31
<% 
32

  
33
// GLOBAL CONSTANTS FOR KNB PORTAL PAGE /////////////////////////////////////
34

  
35
  // URL of metacat to be used for login & searching:
36
//  String      METACAT_URL           = "http://knb.ecoinformatics.org/knb/servlet/metacat";
37
    String      METACAT_URL           = "@systemidserver@@servlet-path@";
38

  
39
  // default title for :
40
  String      DEFAULT_PORTALHEAD_TITLE = "NEW Biocomplexity Data Search";
41
  
42
  // label for logout form button when user *is* logged in:
43
  String      LOGOUT_LABEL          = "logout";
44
  
45
  // label for login form button when user is *not* logged in:
46
  String      LOGIN_LABEL           = "login";
47
  
48
  // last part of LDAP username to be appended after organization
49
  String      LDAP_DOMAIN           = ",dc=ecoinformatics,dc=org";
50
  
51
  // if true, POST variables echoed at bottom of client's browser window in a big yellow box
52
    boolean     DEBUG_TO_BROWSER      = false;
53
  
54
    String      COMMON_SEARCH_METACAT_POST_FIELDS   =
55
               "<input type=\"hidden\" name=\"action\"        value=\"query\"\\>\n"
56
              +"<input type=\"hidden\" name=\"qformat\"       value=\"knb2\"\\>\n"
57
              +"<input type=\"hidden\" name=\"returnfield\"   value=\"originator/individualName/surName\"\\>\n"
58
              +"<input type=\"hidden\" name=\"returnfield\"   value=\"originator/individualName/givenName\"\\>\n"
59
              +"<input type=\"hidden\" name=\"returnfield\"   value=\"originator/organizationName\"\\>\n"
60
              +"<input type=\"hidden\" name=\"returnfield\"   value=\"creator/individualName/surName\"\\>\n"
61
              +"<input type=\"hidden\" name=\"returnfield\"   value=\"creator/organizationName\"\\>\n"
62
              +"<input type=\"hidden\" name=\"returnfield\"   value=\"dataset/title\"\\>\n"
63
//              +"<input type=\"hidden\" name=\"returnfield\"   value=\"title\"\\>\n"
64
              +"<input type=\"hidden\" name=\"returnfield\"   value=\"keyword\"\\>\n"
65
              +"<input type=\"hidden\" name=\"returnfield\"   value=\"dataset/dataTable/distribution/online/url\"\\>\n"
66
              +"<input type=\"hidden\" name=\"returnfield\"   value=\"dataset/dataTable/distribution/inline\"\\>\n"
67
              +"<input type=\"hidden\" name=\"returndoctype\" value=\"-//ecoinformatics.org//eml-dataset-2.0.0beta6//EN\"\\>\n"
68
              +"<input type=\"hidden\" name=\"returndoctype\" value=\"-//ecoinformatics.org//eml-dataset-2.0.0beta4//EN\"\\>\n"
69
              +"<input type=\"hidden\" name=\"returndoctype\" value=\"eml://ecoinformatics.org/eml-2.0.0\"\\>\n"
70
              +"<input type=\"hidden\" name=\"returndoctype\" value=\"-//NCEAS//eml-dataset-2.0//EN\"\\>\n"
71
              +"<input type=\"hidden\" name=\"returndoctype\" value=\"-//NCEAS//resource//EN\"\\>\n";
72

  
73
  String      SIMPLE_SEARCH_METACAT_POST_FIELDS   =
74
                "<input type=\"hidden\" name=\"operator\"      value=\"UNION\"\\>\n"
75
                +COMMON_SEARCH_METACAT_POST_FIELDS;
76

  
77
  String      ADVANCED_SEARCH_METACAT_POST_FIELDS   =
78
                "<input type=\"hidden\" name=\"operator\"      value=\"INTERSECT\"\\>\n"
79
                +COMMON_SEARCH_METACAT_POST_FIELDS;
80
                              
81
/*******************************************************************************/
82
/*******************************************************************************/
83
%>
0 84

  

Also available in: Unified diff