Not logged in : Login

About: ODSControllerJSPAPILoginSource     Goto   Sponge   NotDistinct   Permalink

An Entity of Type : atom:Entry, within Data Space : ods.openlinksw.com associated with source document(s)

AttributesValues
type
Date Created
Date Modified
label
  • ODSControllerJSPAPILoginSource
maker
Title
  • ODSControllerJSPAPILoginSource
isDescribedUsing
has creator
content
  • ---++ODS Controller for JSP API Login Source Code The following source code represents the ODS Controller for JSP API Login users.jsp file: <%@ page import="java.sql.*" %> <%@ page import="java.io.*" %> <%@ page import="java.util.*" %> <%@ page import="java.net.HttpURLConnection" %> <%@ page import="java.net.MalformedURLException" %> <%@ page import="java.net.ProtocolException" %> <%@ page import="java.net.URL" %> <%@ page import="java.net.URLEncoder" %> <%@ page import="java.security.MessageDigest" %> <%@ page import="java.security.NoSuchAlgorithmException" %> <%@ page import="sun.misc.BASE64Encoder" %> <%@ page import="javax.xml.parsers.*" %> <%@ page import="javax.xml.xpath.*" %> <%@ page import="org.xml.sax.InputSource" %> <%@ page import="org.w3c.dom.*" %> Virtuoso Web Applications <%! XPathFactory factory = XPathFactory.newInstance(); XPath xpath = factory.newXPath(); Document createDocument (String S) { try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); if (factory == null) throw new RuntimeException("Unable to create XML document factory"); DocumentBuilder builder = factory.newDocumentBuilder(); if (builder == null) throw new RuntimeException("Unable to create XML document factory"); StringReader stringReader = new StringReader(S); InputSource is = new InputSource(stringReader); return builder.parse(is); } catch (Exception e) { throw new RuntimeException("Error creating XML document factory : " + e.getMessage()); } } String encrypt (String S) { String hash = new String(""); try { MessageDigest md = MessageDigest.getInstance("SHA-1"); byte[] textBytes = S.getBytes("UTF-8"); md.update(textBytes); for (byte b : md.digest()) { hash += Integer.toHexString(b & 0xff); } } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (UnsupportedEncodingException ex) { ex.printStackTrace(); } return hash; } String httpParam (String prefix, String key, String value) throws Exception { String S = ""; if (value != null) S = prefix + key + "=" + URLEncoder.encode(value); return S; } String httpRequest (String httpMethod, String method, String params) throws Exception { HttpURLConnection connection = null; DataOutputStream wr = null; BufferedReader rd = null; StringBuilder sb = null; String line = null; URL serverAddress = null; Boolean isFirst = true; try { serverAddress = new URL("http://localhost:8005/ods/api/"+method); //Set up the initial connection connection = (HttpURLConnection)serverAddress.openConnection(); connection.setRequestMethod(httpMethod); connection.setDoOutput(true); connection.setDoInput(true); connection.setReadTimeout(10000); connection.connect(); //get the output stream writer and write the output to the server wr = new DataOutputStream(connection.getOutputStream()); if (params != null) { wr.writeBytes(params); } wr.flush (); wr.close (); //read the result from the server rd = new BufferedReader(new InputStreamReader(connection.getInputStream())); sb = new StringBuilder(); while ((line = rd.readLine()) != null) { if (!isFirst) sb.append('\n'); sb.append(line); isFirst = false; } rd.close (); return sb.toString(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (ProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { //close the connection, set all objects to null connection.disconnect(); rd = null; sb = null; wr = null; connection = null; } throw new Exception ("Bad request!"); } String xpathEvaluate (Document doc, String xpathString) throws XPathExpressionException { return xpath.evaluate(xpathString, doc); } void outFormTitle (javax.servlet.jsp.JspWriter out, String formName) throws IOException { if (formName.equals("login")) out.print("Login"); if (formName.equals("register")) out.print("Register"); if (formName.equals("user")) out.print("View Profile"); if (formName.equals("profile")) out.print("Edit Profile"); } void outSelectOptions (javax.servlet.jsp.JspWriter out, String fieldValue, String listValue) throws IOException, SQLException { outSelectOptions (out, fieldValue, listValue, null); } void outSelectOptions (javax.servlet.jsp.JspWriter out, String fieldValue, String listValue, String paramValue) { try { String params; params = httpParam ("", "key", listValue); if (paramValue != null) params += httpParam ("&", "param", paramValue); String retValue = httpRequest ("GET", "lookup.list", params); Document doc = createDocument(retValue); XPathFactory factory = XPathFactory.newInstance(); XPath xpath = factory.newXPath(); XPathExpression expr = xpath.compile("/items/item/text()"); Object result = expr.evaluate(doc, XPathConstants.NODESET); NodeList nodes = (NodeList) result; for (int i = 0; i < nodes.getLength(); i++) { String F = nodes.item(i).getNodeValue(); out.print ("" + F + ""); } } catch (Exception e) { } } %> <% String $_form = request.getParameter("form"); if ($_form == null) $_form = "login"; String $_sid = request.getParameter("sid"); String $_realm = "wa"; String $_error = ""; String $_retValue; Document $_document = null; String params = null; try { if ($_form.equals("login")) { if (request.getParameter("lf_login") != null) { try { params = httpParam ( "", "user_name", request.getParameter("lf_uid")) + httpParam ("&", "password_hash", encrypt (request.getParameter("lf_uid")+request.getParameter("lf_password"))); $_retValue = httpRequest ("GET", "user.authenticate", params); if ($_retValue.indexOf("") == 0) { $_document = createDocument($_retValue); throw new Exception(xpathEvaluate($_document, "/failed/message")); } $_sid = $_retValue; $_form = "user"; } catch (Exception e) { $_error = e.getMessage(); } } } if ($_form.equals("user")) { if (request.getParameter("uf_profile") != null) $_form = "profile"; } if ($_form.equals("profile")) { if (request.getParameter("pf_update") != null) { try { params = httpParam ( "", "sid" , $_sid) + httpParam ("&", "realm" , $_realm) + httpParam ("&", "mail" , request.getParameter("pf_mail")) + httpParam ("&", "title" , request.getParameter("pf_title")) + httpParam ("&", "firstName" , request.getParameter("pf_firstName")) + httpParam ("&", "lastName" , request.getParameter("pf_lastName")) + httpParam ("&", "fullName" , request.getParameter("pf_fullName")) + httpParam ("&", "gender" , request.getParameter("pf_gender")) + httpParam ("&", "birthday" , request.getParameter("pf_birthday")) + httpParam ("&", "icq" , request.getParameter("pf_icq")) + httpParam ("&", "skype" , request.getParameter("pf_skype")) + httpParam ("&", "yahoo" , request.getParameter("pf_yahoo")) + httpParam ("&", "aim" , request.getParameter("pf_aim")) + httpParam ("&", "msn" , request.getParameter("pf_msn")) + httpParam ("&", "homeDefaultMapLocation", request.getParameter("pf_homeDefaultMapLocation")) + httpParam ("&", "homeCountry" , request.getParameter("pf_homecountry")) + httpParam ("&", "homeState" , request.getParameter("pf_homestate")) + httpParam ("&", "homeCity" , request.getParameter("pf_homecity")) + httpParam ("&", "homeCode" , request.getParameter("pf_homecode")) + httpParam ("&", "homeAddress1" , request.getParameter("pf_homeaddress1")) + httpParam ("&", "homeAddress2" , request.getParameter("pf_homeaddress2")) + httpParam ("&", "homeTimezone" , request.getParameter("pf_homeTimezone")) + httpParam ("&", "homeLatitude" , request.getParameter("pf_homelat")) + httpParam ("&", "homeLongitude" , request.getParameter("pf_homelng")) + httpParam ("&", "homePhone" , request.getParameter("pf_homePhone")) + httpParam ("&", "homeMobile" , request.getParameter("pf_homeMobile")) + httpParam ("&", "businessIndustry" , request.getParameter("pf_businessIndustry")) + httpParam ("&", "businessOrganization" , request.getParameter("pf_businessOrganization")) + httpParam ("&", "businessHomePage" , request.getParameter("pf_businessHomePage")) + httpParam ("&", "businessJob" , request.getParameter("pf_businessJob")) + httpParam ("&", "businessCountry" , request.getParameter("pf_businesscountry")) + httpParam ("&", "businessState" , request.getParameter("pf_businessstate")) + httpParam ("&", "businessCity" , request.getParameter("pf_businesscity")) + httpParam ("&", "businessCode" , request.getParameter("pf_businesscode")) + httpParam ("&", "businessAddress1" , request.getParameter("pf_businessaddress1")) + httpParam ("&", "businessAddress2" , request.getParameter("pf_businessaddress2")) + httpParam ("&", "businessTimezone" , request.getParameter("pf_businessTimezone")) + httpParam ("&", "businessLatitude" , request.getParameter("pf_businesslat")) + httpParam ("&", "businessLongitude" , request.getParameter("pf_businesslng")) + httpParam ("&", "businessPhone" , request.getParameter("pf_businessPhone")) + httpParam ("&", "businessMobile" , request.getParameter("pf_businessMobile")) + httpParam ("&", "businessRegNo" , request.getParameter("pf_businessRegNo")) + httpParam ("&", "businessCareer" , request.getParameter("pf_businessCareer")) + httpParam ("&", "businessEmployees" , request.getParameter("pf_businessEmployees")) + httpParam ("&", "businessVendor" , request.getParameter("pf_businessVendor")) + httpParam ("&", "businessService" , request.getParameter("pf_businessService")) + httpParam ("&", "businessOther" , request.getParameter("pf_businessOther")) + httpParam ("&", "businessNetwork" , request.getParameter("pf_businessNetwork")) + httpParam ("&", "businessResume" , request.getParameter("pf_businessResume")) + httpParam ("&", "securitySecretQuestion", request.getParameter("pf_securitySecretQuestion")) + httpParam ("&", "securitySecretAnswer" , request.getParameter("pf_securitySecretAnswer")) + httpParam ("&", "securitySiocLimit" , request.getParameter("pf_securitySiocLimit")); $_retValue = httpRequest ("POST", "user.update.fields", params); if ($_retValue.indexOf("") == 0) { $_document = createDocument($_retValue); throw new Exception(xpathEvaluate($_document, "/failed/message")); } $_form = "user"; } catch (Exception e) { $_error = e.getMessage(); $_form = "login"; } } else if (request.getParameter("pf_cancel") != null) { $_form = "user"; } } if ($_form.equals("user") || $_form.equals("profile")) { try { params = httpParam ( "", "sid" , $_sid) + httpParam ("&", "realm" , $_realm); if ($_form.equals("profile")) params += httpParam ("&", "short", "0"); $_retValue = httpRequest ("GET", "user.info", params); $_document = createDocument($_retValue); if ("".compareTo(xpathEvaluate($_document, "/failed/message")) != 0) throw new Exception (xpathEvaluate($_document, "/failed/message")); } catch (Exception e) { $_error = e.getMessage(); $_form = "login"; } } if ($_form.equals("login")) { $_sid = ""; } } catch (Exception e) { $_error = "Failure to connect to JDBC. " + e.getMessage(); } %>
    ODS Home > <% outFormTitle (out, $_form); %>
    <% if ($_form != "login") { %> <% } %>

    <% if ($_form.equals("login")) { %>
    <% if ($_error != "") { out.print("
    " + $_error + "
    "); } %>
    Enter your Member ID and Password
    or
    <% } if ($_form.equals("user")) { %>
    User profile
    Login Name <% out.print(xpathEvaluate($_document, "/user/name")); %>
    E-mail <% out.print(xpathEvaluate($_document, "/user/mail")); %>
    Title <% out.print(xpathEvaluate($_document, "/user/title")); %>
    First Name <% out.print(xpathEvaluate($_document, "/user/firstName")); %>
    Last Name <% out.print(xpathEvaluate($_document, "/user/lastName")); %>
    Full Name <% out.print(xpathEvaluate($_document, "/user/fullName")); %>
    <% } if ($_form.equals("profile")) { %>
    <% if ($_error != "") { out.print("
    " + $_error + "
    "); } %>
    Update user profile
    • Personal
    • Contact
    • Home
    • Business
    • Security
    " id="pf_firstName" style="width: 220px;" />
    " id="pf_lastName" style="width: 220px;" />
    " id="pf_fullName" size="60" />
    " id="pf_mail" style="width: 220px;" />
    " onclick="cPopup.select ($('pf_birthday'), 'pf_birthday_select', 'yyyy-MM-dd');"/>
    <% } %>
    Powered by OpenLink Virtuoso Universal Server
    FAQ | Privacy | Report Abuse
    Copyright © 1999-2009 OpenLink Software
id
  • cbf018ca6ece542ddf32142759614116
link
has container
http://rdfs.org/si...ices#has_services
atom:title
  • ODSControllerJSPAPILoginSource
atom:source
atom:author
atom:published
  • 2017-06-13T06:07:22Z
atom:updated
  • 2017-06-29T07:29:24Z
topic
is made of
is container of of
is link of
is http://rdfs.org/si...vices#services_of of
is creator of of
is atom:entry of
is atom:contains of
Faceted Search & Find service v1.17_git132 as of May 12 2023


Alternative Linked Data Documents: iSPARQL | ODE     Content Formats:   [cxml] [csv]     RDF   [text] [turtle] [ld+json] [rdf+json] [rdf+xml]     ODATA   [atom+xml] [odata+json]     Microdata   [microdata+json] [html]    About   
This material is Open Knowledge   W3C Semantic Web Technology [RDF Data] Valid XHTML + RDFa
OpenLink Virtuoso version 08.03.3332 as of Sep 11 2024, on Linux (x86_64-generic-linux-glibc25), Single-Server Edition (15 GB total memory, 2 GB memory in use)
Data on this page belongs to its respective rights holders.
Virtuoso Faceted Browser Copyright © 2009-2024 OpenLink Software