Package org.wijiscommons.ssaf

Examples of org.wijiscommons.ssaf.ServiceResponseInfo


    log.info("Executing DropOffSynchronous operation ");

    Element docElement = (Element) dropOffSyncRequest.getAny();

    DropOffResponse dropOffSyncResponse = new DropOffResponse();
    ServiceResponseInfo sb = new ServiceResponseInfo();
    String mailBoxURI = null;
    String clientsideID = null;
    String recordURI = null;
    String messageID = null;

    HashMap<String, String> attributesMap = SSAFUtil
        .getMessageAttributes(docElement);
    clientsideID = attributesMap.get("clientsideID");
    recordURI = attributesMap.get("recordURI");
    mailBoxURI = attributesMap.get("dropoffMailBoxURI");

    // Throw Fault if clientside_Id is not specified
    if (StringUtils.isBlank(clientsideID))
    {
      sb.noteError("clientside_Id attribute is not specified in incoming request document");
      Drop_OffUtil  .throwFaultrecordURI,
                  null,
                  null,
                  sb, SSAFErrorTypes.REQUEST_INVALID, mailBoxURI,
                  docElement);

    }
    // check if mailBoxURI attribute is present in incoming request
    if (StringUtils.isNotBlank(mailBoxURI))
    {
      String mailBoxesAbsolutePath = mailBoxes_root + mailBoxURI;

      // check if it dropped of a file successfully
      if (DropOffHelperMethods.dropOffAFile(mailBoxesAbsolutePath, docElement,
          sb, clientsideID, recordURI))
      {
        log.info("Successfully dropped off a file to the mailbox location specified : "
                + mailBoxesAbsolutePath +SSAFUtil.fileSeparator+
                "drop_off"+SSAFUtil.fileSeparator+"drop_box");

        // poll for response file in both confirm_box and fail_box
        // folders.
        Element dropOffStatusReponseElement = Drop_OffUtil
                .pollForAFile(mailBoxesAbsolutePath,
                        clientsideID,
                        recordURI,
                        sb, docElement,
                        numberOfTimesToPoll,sleepInterval);

        if (dropOffStatusReponseElement != null)
        {
          // find out what type of response is returned either
          // confirmation or Error
          NodeList acceptedMessageList = dropOffStatusReponseElement
              .getElementsByTagNameNS(SSAFNamespaces.drop_off
                  .getNamespace(), SSAFNodes.accepted_message
                  .getLocalName());

          if (acceptedMessageList.getLength() > 0)
          {
            Element acceptedMessageElement = (Element) acceptedMessageList
                .item(0);

            messageID = acceptedMessageElement.getAttributeNS(
                SSAFNamespaces.ssaf.getNamespace(),
                SSAFNodes.message_id.getLocalName());
          }
          // all confirmation messages must have message_id attribute
          // in them. If not it's a error Document.

          if (StringUtils.isNotBlank(messageID))
          {
            log.info("message_id attribute defined in dropOffStatusReponseElement : "+messageID);
            File confirmationFileToDelete = Drop_OffUtil
                .lookForConfirmationFileWithMessageID(
                    messageID, mailBoxesAbsolutePath,
                    docElement, sb);

            // check if file exists
            if (confirmationFileToDelete != null
                && confirmationFileToDelete.exists())
            {
              // if it exists go ahead and delete a confirmation file
              if (DropOffHelperMethods.deleteAFile(
                  confirmationFileToDelete, sb))
              {
                dropOffSyncResponse
                    .setAny(dropOffStatusReponseElement);
              }
              else
              { // file exists but could not be deleted
               
                sb.noteError("Confirmation file exists in a file system but not " +
                    "able to delete a confirmation file with message_id : "
                        + messageID);
                log.error(sb.getMergedMessages());
               
                Drop_OffUtil.throwFault(recordURI,
                            clientsideID,
                            messageID,
                            sb,SSAFErrorTypes.NONLOGIC,
                            mailBoxURI,
                            dropOffStatusReponseElement);
              }
            }
            else
            {
              // File is not present in file system
              sb.noteError("File does not exists in a file system with specified message_id : "
                      + messageID);
              log.error(sb.getMergedMessages());

              Drop_OffUtil.throwFault(recordURI,
                          clientsideID,
                          messageID,
                          sb,SSAFErrorTypes.REQUEST_RECORD_ERROR,
                          mailBoxURI, dropOffStatusReponseElement);
            }
          }
          else
          {
            // If it is in this block then it is a error document -
            // delete it form file system and then return
            // dropOffSyncResponse.
            log.info("There is no message_id attribute defined in dropOffStatusReponseElement");

            String deleteErrorFileLocation = Drop_OffUtil
                .getFileName(mailBoxesAbsolutePath, "fail_box",
                    clientsideID, "response");

            File fileToDelete = new File(deleteErrorFileLocation);
            // check if error file exists
            if (fileToDelete.exists())
            {
              if (DropOffHelperMethods.deleteAFile(fileToDelete, sb))
              {
                log.info("Successfully deleted the a error file with" +
                    " specified clientside_id :"  + clientsideID);
                dropOffSyncResponse.setAny(dropOffStatusReponseElement);
              }
              else
              { // Confirmation file exists but could not be deleted
                sb.noteError("Confirmation file exists in a file system but not" +
                    " able to delete a error file with specified clientside_id : "
                        + clientsideID);
                log.error(sb.getMergedMessages());

                Drop_OffUtil  .throwFaultrecordURI,
                            clientsideID,
                            messageID,
                            sb,SSAFErrorTypes.NONLOGIC,
                            mailBoxURI,
                            dropOffStatusReponseElement);
              }
            }
            else
            {
              // Error file is not present in file system
              sb.noteError("Error file does not exists in file system with specified" +
                  " clientside_id : "+ clientsideID);
              log.error(sb.getMergedMessages());

              Drop_OffUtil.throwFault(recordURI,
                          clientsideID,
                          messageID,
                          sb,SSAFErrorTypes.REQUEST_RECORD_ERROR,
                          mailBoxURI, dropOffStatusReponseElement);
            }
          }
        }
        // this is else part for pollForAFile if statement.
        else
        {
          // throw FatalFault if you are not able to find file with
          // specified clientside_id in file system.
          sb.noteError("Not able to find a response for this request, SSAF component " +
              "is taking sometime to process a request. Try to invoke asynchronous " +
              "CheckDropOffStatus web service method with clientside_id :" +clientsideID+" to check for response");
          log.error(sb.getMergedMessages());
         
          Drop_OffUtil.throwFault(recordURI,
                      clientsideID,
                      null,
                      sb, SSAFErrorTypes.NONLOGIC,
                      mailBoxesAbsolutePath, docElement);
        }
      }
      // this is else part for dropOffAFile() if statement
      else
      {
        // throw FatalFault if it could not drop-off a file
        sb.noteError("Could not dropOff a file at :"
            + mailBoxesAbsolutePath +SSAFUtil.fileSeparator+
            "drop_off"+SSAFUtil.fileSeparator+"drop_box");
        log.error(sb.getMergedMessages());
       
        Drop_OffUtil.throwFault(recordURI,
                    clientsideID,
                    null,
                    sb, SSAFErrorTypes.NONLOGIC,
                    mailBoxURI, docElement);
      }
    }
    else
    {
      // Throw Fault if MailBoxURI is not specified
      sb.noteMessage("mailbox_nominal_uri attribute in incoming request document" +
          " is not specified properly");
      log.error(sb.getMergedMessages());
      Drop_OffUtil  .throwFaultrecordURI,
                  null,
                  null,
                  sb, SSAFErrorTypes.REQUEST_RECORD_ERROR,
                  mailBoxURI, docElement);
View Full Code Here


            .getNamespace(), SSAFNodes.message_id.getLocalName());

        log.info("\tThe deleteMessageRequest: " + folderURI + " "
            + messageID);

        ServiceResponseInfo serviceResponseInfo = new ServiceResponseInfo();

        if (folderURI == null || messageID == null)
        {
            serviceResponseInfo
            .noteError("nominal folder uri or message_id is missing in the request ");
        }
        else
        {
            String destDir =
View Full Code Here

            SSAFNodes.pick_up_folder_nominal_uri.getNamespace(),
            SSAFNodes.pick_up_folder_nominal_uri.getLocalName());

        log.debug("\tFolderURI: " + folderURI);

        ServiceResponseInfo serviceResponseInfo = new ServiceResponseInfo();
        Document wrappedMessageDoc = null;
        Document messageDoc = null;

        if (StringUtils.isBlank(folderURI))
        {
            serviceResponseInfo
            .noteError("The attribute "
                    + SSAFNodes.pick_up_folder_nominal_uri.getLocalName()
                    + " with namespace "
                    + SSAFNodes.pick_up_folder_nominal_uri.getNamespace()
                    + " is required in the request.");
View Full Code Here

                        throw exception;               
                       
                    }   
   
                    //Verify certificate here
                    ServiceResponseInfo sr = mailboxProperties.isMailBoxURIValid(mailBoxURI, commonNameinCertificate);
                   
                    if (sr.isErrorResponse())
                    {
                        Exception exception = new Exception("Authorization Error Occurred: " + sr.getMergedMessages());
                        exchange.getIn().setHeader("SSAFException", exception);
                        throw exception;               
                    }   
                   
          }   
View Full Code Here

        String nominalURI = "";
        String messageID = "";
       
        HttpServletRequest request = (HttpServletRequest) message.get(AbstractHTTPDestination.HTTP_REQUEST);

        ServiceResponseInfo sb = SecurityHelperMethods.checkClientCert(request,getX509CRLLocation());

        // get input document
        if (!sb.isErrorResponse())
        {
           
            List<Object> myList = message.getContent(List.class);

            Element invocation = null;

            for (Object object : myList)
            {

                if (object instanceof ReadNextMessage)
                {
                    ReadNextMessage readNextMessage = (ReadNextMessage) object;
                    invocation = (Element) readNextMessage.getAny();
                }
                else if (object instanceof DeleteNextUnitOfWork)
                {
                    DeleteNextUnitOfWork deleteNextUnitOfWork = (DeleteNextUnitOfWork) object;
                    invocation = (Element) deleteNextUnitOfWork.getAny();
                }
            }

            if (invocation != null)
            {
                nominalURI = invocation.getAttributeNS(
                    SSAFNodes.pick_up_folder_nominal_uri.getNamespace(),
                    SSAFNodes.pick_up_folder_nominal_uri.getLocalName());
                String mailboxName = StringUtils.substringBetween(nominalURI,
                    "mailboxes/", "/");
                String commonName = this.getCommonNameFromCert(request);
               
                sb = getMailboxAuthenticator()
                        .isMailBoxURIValid(mailboxName,
                    commonName);

                messageID = invocation.getAttributeNS(SSAFNodes.message_id
                        .getNamespace(), SSAFNodes.message_id.getLocalName());
            }
           
            else
            {
                sb.noteError("The invocation is empty.");
            }

        }

        if (sb.isErrorResponse())
        {
            try
            {
                Document errorResponse = DomUtils.createErrorResponse(null,
                    null, messageID, sb.getMergedMessages(), null,
                    SSAFErrorTypes.REQUEST_USER_UNAUTHORIZED, nominalURI, null);
               
                FaultDescription faultDescr = new FaultDescription();
                faultDescr.setAny(errorResponse.getDocumentElement());
                FatalFault ssafFault =
                    new FatalFault(sb.getMergedMessages(), faultDescr);

                throw new Fault(ssafFault);
            }
            catch (ParserConfigurationException e)
            {
View Full Code Here

        HttpServletRequest request = (HttpServletRequest) message
                .get(AbstractHTTPDestination.HTTP_REQUEST);

        // Check the certificate submitted by client
        ServiceResponseInfo sb = SecurityHelperMethods.checkClientCert(request,
                getX509CRLLocation());

        // get input document type
        Element inputDocumentElement = DropOffHelperMethods
                .getInputDocumentType(message);

        String clientsideID = null;
        String recordURI = null;
        String mailBoxURI = null;

        // get the attribute values from inputDocument
        if (inputDocumentElement != null)
        {
            HashMap<String, String> attributesMap = SSAFUtil
                    .getMessageAttributes(inputDocumentElement);
            clientsideID = attributesMap.get("clientsideID");
            recordURI = attributesMap.get("recordURI");
            mailBoxURI = attributesMap.get("dropoffMailBoxURI");
        }
        else
        {
            sb.noteError("Input document did not match with any of excepted types");
            Drop_OffUtil.throwFault(recordURI, clientsideID, null, sb,
                    SSAFErrorTypes.REQUEST_INVALID, mailBoxURI, null);
        }

        // Throw a Fault if cert is invalid
        if (sb.isErrorResponse())
        {
            Drop_OffUtil.throwFault(recordURI, clientsideID, null, sb,
                    SSAFErrorTypes.REQUEST_USER_UNAUTHORIZED, mailBoxURI,
                    inputDocumentElement);
        }
        // go ahead if cert is valid
        else
        {
            X509Certificate certs[] = (X509Certificate[]) request
                    .getAttribute("javax.servlet.request.X509Certificate");

            String dnInCanonicalForm = certs[0].getSubjectX500Principal()
                    .getName("CANONICAL");
            log.info("DN in Cert: " + dnInCanonicalForm);

            X509Name x509NameArgument = new X509Name(dnInCanonicalForm);
            String commonNameInCert = DNUtil.getCommonName(x509NameArgument);
            log.debug("Common Name in Cert: " + commonNameInCert);

            // Check if user is authenticated to MailBox
            sb = Drop_OffUtil.isUserAuthenticated(mailBoxURI, commonNameInCert,
                    authenticateMailBoxURIs);

            if (sb.isErrorResponse())
            {
                sb.noteError("User is not authenticated to use this particular mailbox");
                Drop_OffUtil    .throwFault(
                                recordURI,
                                clientsideID,
                                null,
                                sb, SSAFErrorTypes.REQUEST_USER_UNAUTHORIZED,
View Full Code Here

TOP

Related Classes of org.wijiscommons.ssaf.ServiceResponseInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.