Package org.apache.commons.ssl.asn1

Examples of org.apache.commons.ssl.asn1.DERObject


    }

    public void testHuaweiEnodeBClientRequest() throws IOException, InvalidKeyException, NoSuchAlgorithmException, NoSuchProviderException, SignatureException {
      // Read an initialization request to see that we can process it
      ASN1InputStream in = new ASN1InputStream(huaweiir);
    DERObject derObject = in.readObject();
    PKIMessage req = PKIMessage.getInstance(derObject);
    //log.info(req.toString());
      CrmfRequestMessage msg = new CrmfRequestMessage(req, null, false, "CN");
      // This message does not have an issuerDN in the cert template
      assertNull(msg.getIssuerDN());
View Full Code Here


   * @return IResponseMessage containing the CMP response message or null if there is no message to send back or some internal error has occurred
   * @throws IOException
   */
  @TransactionAttribute(TransactionAttributeType.REQUIRED)
  public IResponseMessage dispatch(Admin admin, byte[] ba) throws IOException {
    DERObject derObject = new LimitLengthASN1Reader(new ByteArrayInputStream(ba), ba.length).readObject();
    return dispatch(admin, derObject);
  }
View Full Code Here

      // Not a CVC request, perhaps a PKCS10 request
      try {
        final PKCS10CertificationRequest pkcs10 = new PKCS10CertificationRequest(requestBytes);
//        ret = pkcs10.toString();
        final ASN1InputStream ais = new ASN1InputStream(new ByteArrayInputStream(pkcs10.getEncoded()));
        final DERObject obj = ais.readObject();
        ret = ASN1Dump.dumpAsString(obj);
        type = "PKCS#10";
      } catch (IOException e1) {
         // ignore, move on to certificate decoding
      } catch (IllegalArgumentException e1) {
        // ignore, move on to certificate decoding
      } catch (ClassCastException e2) {
        // ignore, move on to certificate decoding
      }
    } else if (ret != null) {
      type = "CVC";
    }
    if (ret == null) {
      // Not a CVC object or PKCS10 request message, perhaps a X.509 certificate?
      try {
        final Certificate cert = getCert(bytes);
        ret = CertTools.dumpCertificateAsString(cert);
        type = "X.509";
      } catch (Exception e) {
        // Not a X.509 certificate either...try to simply decode asn.1
        try {
          final ASN1InputStream ais = new ASN1InputStream(new ByteArrayInputStream(bytes));
          final DERObject obj = ais.readObject();
          if (obj != null) {
            ret = ASN1Dump.dumpAsString(obj);
            type = "ASN.1";           
          }
        } catch (IOException e1) {
View Full Code Here

        } catch (Exception e) {
          iscert = false;
        }
        if (!iscert) {
            ASN1InputStream ais = new ASN1InputStream(new FileInputStream(filename));
            DERObject obj = ais.readObject();
            String dump = ASN1Dump.dumpAsString(obj);
            getLogger().info(dump);         
        } else {
            Iterator<Certificate> iter = coll.iterator();
            while (iter.hasNext()) {
View Full Code Here

      log.trace(">doPost()");
      if ( this.config==null ) {
        throw new ServletException("Servlet not initialized.");
      }
      final ServletInputStream sin = servletReq.getInputStream();
      final DERObject message;
      try {
        message = new LimitLengthASN1Reader(sin, servletReq.getContentLength()).readObject();
      } catch ( IOException e ) {
        servletResp.sendError(HttpServletResponse.SC_BAD_REQUEST, e.getMessage());
        log.error( intres.getLocalizedMessage("cmp.errornoasn1"), e );
        return;
      }
      log.info( intres.getLocalizedMessage("cmp.receivedmsg", servletReq.getRemoteAddr()) );
      long startTime = System.currentTimeMillis();
      // Send back CMP response
      this.connection.send(message.getDEREncoded(), servletResp, servletReq.getContentType());
      long endTime = System.currentTimeMillis();
      log.info( intres.getLocalizedMessage("cmp.sentresponsemsg", servletReq.getRemoteAddr(), Long.valueOf(endTime - startTime)) );
    } catch (Throwable t) {
      log.error("Error in CmpServlet:", t);
      servletResp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, t.getMessage());
View Full Code Here

        pkcs7input[20] = four;
        pkcs7input[21] = three;
        pkcs7input[22] = two;
        pkcs7input[23] = one;

        DERObject obj = createDERForRecipient(pkcs7input, (X509Certificate)certificate);

        ByteArrayOutputStream baos = new ByteArrayOutputStream();

        DEROutputStream k = new DEROutputStream(baos);
View Full Code Here

        AlgorithmParameterGenerator algorithmparametergenerator = AlgorithmParameterGenerator.getInstance(s);
        AlgorithmParameters algorithmparameters = algorithmparametergenerator.generateParameters();
        ByteArrayInputStream bytearrayinputstream = new ByteArrayInputStream(algorithmparameters.getEncoded("ASN.1"));
        ASN1InputStream asn1inputstream = new ASN1InputStream(bytearrayinputstream);
        DERObject derobject = asn1inputstream.readObject();
        KeyGenerator keygenerator = KeyGenerator.getInstance(s);
        keygenerator.init(128);
        SecretKey secretkey = keygenerator.generateKey();
        Cipher cipher = Cipher.getInstance(s);
        cipher.init(1, secretkey, algorithmparameters);
View Full Code Here

            ASN1InputStream din = new ASN1InputStream(new ByteArrayInputStream(contentsKey));

            //
            // Basic checks to make sure it's a PKCS#7 SignedData Object
            //
            DERObject pkcs;

            try {
                pkcs = din.readObject();
            }
            catch (IOException e) {
View Full Code Here

     * @throws CertificateParsingException on error
     * @since  2.1.6
     */
    public static String getOCSPURL(X509Certificate certificate) throws CertificateParsingException {
        try {
            DERObject obj = getExtensionValue(certificate, X509Extensions.AuthorityInfoAccess.getId());
            if (obj == null) {
                return null;
            }

            ASN1Sequence AccessDescriptions = (ASN1Sequence) obj;
View Full Code Here

            log.debug("Privatekey : " + privateKey.getAlgorithm());
            decBytes = recipient.getContent(privateKey, jceProvider);
            break;
        }

        DERObject derobj = new ASN1InputStream(new ByteArrayInputStream(decBytes)).readObject();
        if (messageType == ScepRequestMessage.SCEP_TYPE_PKCSREQ) {
            ASN1Sequence seq = (ASN1Sequence) derobj;
            pkcs10 = new PKCS10CertificationRequest(seq);
            if (log.isDebugEnabled()) {
              log.debug("Successfully extracted PKCS10:"+new String(Base64.encode(pkcs10.getEncoded())));
View Full Code Here

TOP

Related Classes of org.apache.commons.ssl.asn1.DERObject

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.