Package org.wijiscommons.ssaf

Examples of org.wijiscommons.ssaf.ServiceResponseInfo$InfoItem


                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


    {
      log.info("Entering x509 Interceptor");

    HttpServletRequest request = (HttpServletRequest) message
        .get(AbstractHTTPDestination.HTTP_REQUEST);
    ServiceResponseInfo sb = new ServiceResponseInfo();
    Element inputElement = SearchServiceUtil.getInputDocumentType(message);
   
    if(inputElement != null)
    {
      // if condition below is just to know which type of error to throw.
      if(SearchServiceUtil.isSearchRequest(message))
      {
        if (SearchServiceUtil.checkPortForIncomingRequest(request,
            SSAFAdminPort, SSAFAdminIPAddress))
        {
          // Check the certificate submitted by client
          sb = SecurityHelperMethods.checkClientCert(request,
              getX509CRLLocation());

          // Throw a Fault if cert is invalid
          if (sb.isErrorResponse())
          {
            SearchServiceUtil.throwFault(sb,
                SSAFErrorTypes.REQUEST_USER_UNAUTHORIZED,
                inputElement, true);
          }
        }
      }
      else
      {
        if (SearchServiceUtil.checkPortForIncomingRequest(request,
            SSAFAdminPort, SSAFAdminIPAddress))
        {
          // Check the certificate submitted by client
          sb = SecurityHelperMethods.checkClientCert(request,
              getX509CRLLocation());

          // Throw a Fault if cert is invalid
          if (sb.isErrorResponse())
          {
            SearchServiceUtil.throwFault(sb,
                SSAFErrorTypes.REQUEST_USER_UNAUTHORIZED,
                inputElement, false);
          }
View Full Code Here

  {   
    log.info("Executing RecordRetrieval operation");

    Element retrieveDocElement = (Element) recordRetrievalRequest.getAny();
    RecordRetrievalResponse recordRetrievalResponse = new RecordRetrievalResponse();
    ServiceResponseInfo sb = new ServiceResponseInfo();
    Document retrievalResponseDocument = null;
   
      if (recordRetrievalSolrBean != null)
      {
        try
        {   retrievalResponseDocument = recordRetrievalSolrBean.retrieve(
              solarLocation, retrieveDocElement.getOwnerDocument(),
              xpathLocation);
          recordRetrievalResponse.setAny(retrievalResponseDocument
                .getDocumentElement());
        }
        catch (SSAFSolrException solrException)
        {
          sb.noteError(solrException.getMessage());
          log.error(sb.getMergedMessages());
          SearchServiceUtil.throwFault(sb, solrException.getErrortype(),
                  retrieveDocElement,false);
        }
        catch (Exception ex)
        {
          sb.noteError("Caught exception while connecting to SSAFSOLR retrieval method :"+ex.getMessage());
          log.error(sb.getMergedMessages());
          SearchServiceUtil.throwFault(sb, SSAFErrorTypes.REQUEST_RECORD_ERROR,
                  retrieveDocElement,false);
        }
      }
      else
View Full Code Here

  public SearchResponse search(Search searchRequest) throws FatalSearchFault
  {
    log.info("Executing Search operation");
    Element searchRequestDocElement = (Element) searchRequest.getAny();
    SearchResponse searchReponse = new SearchResponse();
    ServiceResponseInfo sb = new ServiceResponseInfo();
    Document searchResultsDocument = null;

    try
    {
      if (searchSolrBean != null)
      {
        searchResultsDocument = searchSolrBean.search(solarLocation,
            searchRequestDocElement.getOwnerDocument());
        searchReponse.setAny(searchResultsDocument.getDocumentElement());
       
      }
      else
      {
        log.error("Injected SSAFSolr search implementation bean is null");
      }
    }
    catch (SSAFSolrException solrException)
    {
      sb.noteError(solrException.getMessage());
      log.error(sb.getMergedMessages());
      SearchServiceUtil.throwFault(
              sb, solrException.getErrortype(),
              searchRequestDocElement,true);
    }
    catch (Exception ex)
    {
      sb.noteError("Caught exception while connecting to SSAFSOLR search method :"+ex.getMessage());
      log.error(sb.getMergedMessages());
      SearchServiceUtil.throwFault(
              sb, SSAFErrorTypes.REQUEST_RECORD_ERROR,
              searchRequestDocElement,true);
    }
    return searchReponse;
View Full Code Here

            deletionRequestFolderUri.replace(
                NominalUriPartNames.DELETION_REQUEST.toString(),
                NominalUriPartNames.NEXT_MESSAGE.toString());
       

        ServiceResponseInfo serviceResponseInfo = jmsTemplateWrapper
                .deleteHeadMessageOnRequest( reqeust.getDocumentElement(),
                    queueName, messageDir );

        DOMSource domSource = createResponse( reqeust, serviceResponseInfo );
       
View Full Code Here

        Document document = message.getBody(Document.class);
       
        Exception exception = (Exception) exchange
                .getProperty( "CamelExceptionCaught" );

        ServiceResponseInfo serviceResponseInfo = new ServiceResponseInfo();
        serviceResponseInfo.noteExceptionAsProblem( exception, false, true );
       
        DOMSource domSource;
        try
        {
            domSource = createResponse(document, serviceResponseInfo);
View Full Code Here

  @SuppressWarnings("unchecked")
  public static Element getInputDocumentType(SoapMessage message)
  {
    Element inputDocumentElement = null;
    List<Object> myList = message.getContent(List.class);
    ServiceResponseInfo sb = new ServiceResponseInfo();

    for (Object object : myList)
    {
      // check what type of document is coming in.
      switch (SSAFWebservicesEnum.valueOfClassName(object.getClass()
          .getName()))
      {
        case SEARCH:
        {
          Search search = (Search) object;
          Element docElement = (Element) search.getAny();

          if ((docElement != null)
              && (docElement.getLocalName()
                  .equalsIgnoreCase(SSAFNodes.search_request.getLocalName())
              && (docElement.getNamespaceURI()
                  .equalsIgnoreCase(SSAFNodes.search_request
                      .getNamespace()))))
          {
            inputDocumentElement = docElement;
            log.info("Incoming request document is of type  Search");
          }
          else
          {   // throw FatalFault if incoming Search request does
            // not contain expected search:search_request element.
            sb.noteError("Incoming search request document does not contain "
                    + "search_request element which is required");
            throwFault(sb, SSAFErrorTypes.REQUEST_INVALID, docElement,true);
          }
          break;
        }
        case RECORDRETRIEVAL:
        {
          RecordRetrieval checkConfirmation = (RecordRetrieval) object;
          Element docElement = (Element) checkConfirmation.getAny();
         
          if ((docElement != null)
              && (docElement.getLocalName()
                  .equalsIgnoreCase(SSAFNodes.record_retrieval_request
                      .getLocalName()))
              && (docElement.getNamespaceURI()
                  .equalsIgnoreCase(SSAFNodes.record_retrieval_request
                      .getNamespace())))
          {
            inputDocumentElement = docElement;
            log.info("Incoming request document is of type RecordRetrieval ");
          }
          else
          {
            // throw FatalFault if incoming recordRetrieval request
            // does not contain expected search:record_retrieval_request element.
            sb.noteError("Incoming RecordRetrieval request document does not contain "
                    + "record_retrieval_request element which is required");
            throwFault(sb, SSAFErrorTypes.REQUEST_INVALID, docElement,false);
          }
          break;
        }
View Full Code Here

            String queueName, String messageDir)
    throws JMSException,
            FileNotFoundException, IOException, SAXException,
            ParserConfigurationException
    {
        ServiceResponseInfo serviceResponseInfo = new ServiceResponseInfo();
        String messageIDInRequest = request.getAttributeNS(SSAFNodes.message_id
                .getNamespace(), SSAFNodes.message_id.getLocalName());

        if (messageIDInRequest != null)
        {
            log.info("Get request to delete message "
                + messageIDInRequest);

            String messageIDOfHeadMessage = getMessageIDOfHeadMessage(queueName);

            File nextMessageDirectory = new File(messageDir);
            if (messageIDInRequest.equals(messageIDOfHeadMessage))
            {
                // Remove the headMessage of the queue
                jmsTemplate.receive(queueName);
                // Clean the next_message directory

                try
                {
                    FileUtils.cleanDirectory(nextMessageDirectory);
                }
                catch (IOException e)
                {
                    log.error("The folder " + nextMessageDirectory
                            + " is not found.", e);
                }

                serviceResponseInfo
                        .noteMessage("The message "
                                + messageIDInRequest
                                + "is removed from "
                                + "the head of the queue. The next message in the queue will be put into the "
                                + "'next_message' folder unless the queue is empty");
View Full Code Here

    if (StringUtils.isBlank(mailBoxURI) && StringUtils.isBlank(commonName))
    {
      throw new IllegalArgumentException(
          "isMailBoxURIValid method arguments passed in should not be null or empty");
    }
    ServiceResponseInfo serviceResponseInfo = new ServiceResponseInfo();

    log.info("Looking for mailBox name in HashMap :" + mailBoxURI
        + " for common name : " + commonName);

    if (mailBoxProperties.containsKey(mailBoxURI))
    {
      HashMap<String, List<String>> mailBoxDetailsHashMap = mailBoxProperties
          .get(mailBoxURI);
     
      if(mailBoxDetailsHashMap.containsKey("certificates"))
      {
        List<String> commonNameList = mailBoxDetailsHashMap.get("certificates");
       
        if (commonNameList.contains(commonName))
        {
          System.out.println("The Common Name in the Cert was valid for "
                    + mailBoxURI);
          serviceResponseInfo.noteMessage("The Common Name in the Cert was valid for "
                    + mailBoxURI);
          return serviceResponseInfo;
        }
        // if common name is not authorized
        log.error("The common name " + commonName
            + " is not authorized to access mailBoX URI " + mailBoxURI);
        serviceResponseInfo.noteError("The common name " + commonName
            + " is not authorized to access mailBoX URI " + mailBoxURI);
      }
      else
      {
        // if it can not find certificates map
        log.error("Not able to find a map with  name certificates: "
                 + mailBoxURI);
        serviceResponseInfo.noteError("Not able to find a map name certificates : "
                + mailBoxURI);
      }
    }
    else
    {   // if it can not find mailBox name in hashMap
      log.error("Not able to find a mailBox name specified : "
               + mailBoxURI);
      serviceResponseInfo.noteError("Not able to find a mailBox name specified : "
              + mailBoxURI);
    }
    return serviceResponseInfo;
  }
View Full Code Here

    };
   
    public static final ServiceResponseInfo checkClientCert(HttpServletRequest request, File x509CRLLocation)
  {
    log.info("Checking Client Certificate");
      ServiceResponseInfo sb = null;
      sb = new ServiceResponseInfo();
   
    String hostName = request.getRemoteHost();
       
    X509Certificate[] certs = (X509Certificate[]) request
                .getAttribute("javax.servlet.request.X509Certificate");
   
    if (certs == null)
        {
            sb.noteError("Client certificate is missing");
            return sb;
        }

        X509Certificate cert = certs[0];

    log.debug("Content Type: " + request.getContentType());
    log.debug("Prinicipal Name" + cert.getSubjectX500Principal().getName());
    log.debug("Host Name: " + hostName);
    log.debug(cert.getIssuerDN());
                       
      try {
        // Get the InetAddress.
        InetAddress inetClient = InetAddress.getByName(request.getRemoteAddr());
        log.debug ("Client Host: " + inetClient.getHostName());
        log.debug ("Client IP Address: " + inetClient.getHostAddress());
       
        String hostNameStringArray[] = cert.getSubjectDN().getName().split(
                ",");
       
        String hostNameString = hostNameStringArray[0].substring(3);
               
        InetAddress inetCN = InetAddress.getByName(hostNameString);
        log.debug ("Host from cert: " + inetCN.getHostName());
        log.debug ("Host IP from cert: " + inetCN.getHostAddress());

        //TODO We need to figure out we want to conduct this test, We might not want to allow anyone in if this fails
        if (!inetClient.getHostAddress().toString().equals(inetCN.getHostAddress().toString()))
        {
          log.warn("Client Host name on wire: " + inetClient.getHostName() + " for IP Address: " + inetClient.getHostAddress()
                 + " did not match address from cert, host name: " + inetCN.getHostName() + ", host address " + inetCN.getHostAddress());
       
       
      } catch( UnknownHostException uhe ){
          //log.debug("UnknownHostException: "+uhe.toString());
          //sb.noteError(uhe.getMessage());
          //return sb;
        log.warn("UnknownHostException", uhe);
      }
   
    try {
      SecurityHelperMethods.checkCRL(cert, x509CRLLocation, true);
    } catch (CertPathValidatorException e1) {
      log.error("The CRL check return an exception", e1);
          sb.noteError(e1.getMessage());
          return sb;
    }
    
    try {
      certs[0].checkValidity();
    } catch (CertificateExpiredException e) {
      log.error("The certificate validity check return an exception", e);
          sb.noteError(e.getMessage());
          return sb;
    } catch (CertificateNotYetValidException e) {
      log.error("The certificate validity check return an exception", e);
          sb.noteError(e.getMessage());
          return sb;
    }
   
    return sb;
  }
View Full Code Here

TOP

Related Classes of org.wijiscommons.ssaf.ServiceResponseInfo$InfoItem

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.