8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Copyright (c) 2005 Sun Microsystems Inc. All Rights Reserved
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The contents of this file are subject to the terms
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * of the Common Development and Distribution License
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * (the License). You may not use this file except in
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * compliance with the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * You can obtain a copy of the License at
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * https://opensso.dev.java.net/public/CDDLv1.0.html or
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * See the License for the specific language governing
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * permission and limitations under the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * When distributing Covered Code, include this CDDL
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Header Notice in each file and include the License file
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * If applicable, add the following below the CDDL Header,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * with the fields enclosed by brackets [] replaced by
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * your own identifying information:
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * "Portions Copyrighted [year] [name of copyright owner]"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * $Id: PLLNotificationServlet.java,v 1.6 2008/08/19 19:08:43 veiming Exp $
24ea8b0bf00ce7b51c10c2ba4108ad9b02c49e3fCraig McDonnell * Portions Copyrighted 2011-2014 ForgeRock AS.
24ea8b0bf00ce7b51c10c2ba4108ad9b02c49e3fCraig McDonnellimport com.iplanet.services.comm.share.Notification;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.iplanet.services.comm.share.NotificationSet;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.iplanet.services.comm.share.PLLBundle;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.shared.locale.L10NMessageImpl;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The <code>PLLNotificationServlet</code> class is used to receive
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * notifications from servers and forward those notifications to the high level
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * services and applications for processing.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The doPost() method gets the XML NotificationSet document from the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * HttpRequest object, then parses the XML documnent and reconstructs a
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * NotificationSet object.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @see com.iplanet.services.comm.share.Notification
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @see com.iplanet.services.comm.share.NotificationSet
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpublic class PLLNotificationServlet extends HttpServlet {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Accepts POST requests, reads Inpt Stream, forwards the NotificationSet
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * XML Flushes the ResponseSet XML to OutputStream @param
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * HttpServletNotification Reference to HttpServletNotification object
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param HttpServletResponse Reference to HttpServletResponse object
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @see javax.servlet.http.HttpServlet
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void doPost(HttpServletRequest request, HttpServletResponse response)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Check content length
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ISLocaleContext localeContext = new ISLocaleContext();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster java.util.Locale locale = localeContext.getLocale();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster throw new ServletException(e.getL10NMessage(locale));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster throw new ServletException(PLLBundle.getString("unknownLength"));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster int r = in.read(reqData, offset, length - offset);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (r == -1) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String xml = new String(reqData, 0, length, "UTF-8");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ServletOutputStream out = response.getOutputStream();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void doGet(HttpServletRequest request, HttpServletResponse response)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ServletOutputStream out = response.getOutputStream();
24ea8b0bf00ce7b51c10c2ba4108ad9b02c49e3fCraig McDonnell * This method is used by doPost method. It gets the corresponding notification handler and passes the Notification
24ea8b0bf00ce7b51c10c2ba4108ad9b02c49e3fCraig McDonnell * objects to it for processing.
24ea8b0bf00ce7b51c10c2ba4108ad9b02c49e3fCraig McDonnell * @param notificationXML The XML String for the NotificationSet object.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private void handleNotification(String notificationXML)
24ea8b0bf00ce7b51c10c2ba4108ad9b02c49e3fCraig McDonnell NotificationSet notificationSet = NotificationSet.parseXML(notificationXML);
24ea8b0bf00ce7b51c10c2ba4108ad9b02c49e3fCraig McDonnell Vector<Notification> notifications = notificationSet.getNotifications();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Each notification in this set shall have the same service id
24ea8b0bf00ce7b51c10c2ba4108ad9b02c49e3fCraig McDonnell String serviceID = notificationSet.getServiceID();
24ea8b0bf00ce7b51c10c2ba4108ad9b02c49e3fCraig McDonnell NotificationHandler notificationHandler = PLLClient.getNotificationHandler(serviceID);
24ea8b0bf00ce7b51c10c2ba4108ad9b02c49e3fCraig McDonnell throw new ServletException(PLLBundle.getString("noNotificationHandler") + serviceID);