亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? requesthelper.java

?? 一套JAVA的CA證書簽發(fā)系統(tǒng).
?? JAVA
字號:
/************************************************************************* *                                                                       * *  EJBCA: The OpenSource Certificate Authority                          * *                                                                       * *  This software is free software; you can redistribute it and/or       * *  modify it under the terms of the GNU Lesser General Public           * *  License as published by the Free Software Foundation; either         * *  version 2.1 of the License, or any later version.                    * *                                                                       * *  See terms of license at gnu.org.                                     * *                                                                       * *************************************************************************/ package se.anatom.ejbca.apply;import java.io.*;import java.security.cert.X509Certificate;import java.util.regex.Pattern;import javax.servlet.ServletContext;import javax.servlet.ServletOutputStream;import javax.servlet.http.HttpServletResponse;import org.apache.log4j.Logger;import org.bouncycastle.asn1.*;import org.bouncycastle.jce.netscape.NetscapeCertRequest;import se.anatom.ejbca.ca.exception.SignRequestSignatureException;import se.anatom.ejbca.ca.sign.ISignSessionRemote;import se.anatom.ejbca.log.Admin;import se.anatom.ejbca.protocol.PKCS10RequestMessage;import se.anatom.ejbca.protocol.IResponseMessage;import se.anatom.ejbca.util.Base64;import se.anatom.ejbca.util.FileTools;import se.anatom.ejbca.util.CertTools;/** * Helper class for hadnling certificate request from browsers or general PKCS#10 */public class RequestHelper {    private static Logger log = Logger.getLogger(RequestHelper.class);    private Admin administrator;    private ServletDebug debug;    private static final Pattern CLASSID = Pattern.compile("\\$CLASSID");	public static final  String BEGIN_CERTIFICATE_REQUEST  = "-----BEGIN CERTIFICATE REQUEST-----";	public static final  String END_CERTIFICATE_REQUEST     = "-----END CERTIFICATE REQUEST-----";	public static final  String BEGIN_CERTIFICATE_REQUEST_WITH_NL = "-----BEGIN CERTIFICATE REQUEST-----\n";	public static final  String END_CERTIFICATE_REQUEST_WITH_NL    = "\n-----END CERTIFICATE REQUEST-----\n";	public static final  String BEGIN_CERTIFICATE                = "-----BEGIN CERTIFICATE-----";	public static final  String END_CERTIFICATE                    = "-----END CERTIFICATE-----";    	public static final  String BEGIN_CERTIFICATE_WITH_NL = "-----BEGIN CERTIFICATE-----\n";	public static final  String END_CERTIFICATE_WITH_NL    = "\n-----END CERTIFICATE-----\n";	public static final  String BEGIN_PKCS7  = "-----BEGIN PKCS7-----\n";	public static final  String END_PKCS7     = "\n-----END PKCS7-----\n";		public static final  String BEGIN_PKCS7_WITH_NL = "-----BEGIN PKCS7-----\n";	public static final  String END_PKCS7_WITH_NL    = "\n-----END PKCS7-----\n";		public static final int ENCODED_CERTIFICATE = 1;	public static final int ENCODED_PKCS7          = 2;	    /**     * Creates a new RequestHelper object.     *     * @param administrator Admin doing the request     * @param debug object to send debug to     */    public RequestHelper(Admin administrator, ServletDebug debug) {        this.administrator = administrator;        this.debug = debug;    }    /**     * Handles NetScape certificate request (KEYGEN), these are constructed as: <code>     * SignedPublicKeyAndChallenge ::= SEQUENCE { publicKeyAndChallenge    PublicKeyAndChallenge,     * signatureAlgorithm   AlgorithmIdentifier, signature        BIT STRING }</code> PublicKey's     * encoded-format has to be RSA X.509.     *     * @param signsession EJB session to signature bean.     * @param reqBytes buffer holding te request from NS.     * @param username username in EJBCA for authoriation.     * @param password users password for authorization.     *     * @return byte[] containing DER-encoded certificate.     */    public byte[] nsCertRequest(ISignSessionRemote signsession, byte[] reqBytes, String username,        String password) throws Exception {        byte[] buffer = Base64.decode(reqBytes);        if (buffer == null) {            return null;        }        DERInputStream in = new DERInputStream(new ByteArrayInputStream(buffer));        ASN1Sequence spkac = (ASN1Sequence) in.readObject();        in.close();        NetscapeCertRequest nscr = new NetscapeCertRequest(spkac);        // Verify POPO, we don't care about the challenge, it's not important.        nscr.setChallenge("challenge");        if (nscr.verify("challenge") == false) {            throw new SignRequestSignatureException(                "Invalid signature in NetscapeCertRequest, popo-verification failed.");        }        log.debug("POPO verification successful");        X509Certificate cert = (X509Certificate) signsession.createCertificate(administrator,                username, password, nscr.getPublicKey());        //Certificate[] chain = ss.getCertificateChain();        byte[] pkcs7 = signsession.createPKCS7(administrator, cert);        log.debug("Created certificate (PKCS7) for " + username);        debug.print("<h4>Generated certificate:</h4>");        debug.printInsertLineBreaks(cert.toString().getBytes());        return pkcs7;    } //nsCertRequest    /**     * Handles PKCS10 certificate request, these are constructed as: <code> CertificationRequest     * ::= SEQUENCE { certificationRequestInfo  CertificationRequestInfo, signatureAlgorithm     * AlgorithmIdentifier{{ SignatureAlgorithms }}, signature                       BIT STRING }     * CertificationRequestInfo ::= SEQUENCE { version             INTEGER { v1(0) } (v1,...),     * subject             Name, subjectPKInfo   SubjectPublicKeyInfo{{ PKInfoAlgorithms }},     * attributes          [0] Attributes{{ CRIAttributes }}} SubjectPublicKeyInfo { ALGORITHM :     * IOSet} ::= SEQUENCE { algorithm           AlgorithmIdentifier {{IOSet}}, subjectPublicKey     * BIT STRING }</code> PublicKey's encoded-format has to be RSA X.509.     *     * @param signsession signsession to get certificate from     * @param b64Encoded base64 encoded pkcs10 request message     * @param username username of requesting user     * @param password password of requesting user     * @param resulttype should indicate if a PKCS7 or just the certificate is wanted.     *     * @return Base64 encoded byte[]      */    public byte[] pkcs10CertRequest(ISignSessionRemote signsession, byte[] b64Encoded,        String username, String password, int resulttype) throws Exception {        byte[] result = null;	        X509Certificate cert=null;		PKCS10RequestMessage req = genPKCS10RequestMessageFromPEM(b64Encoded);		req.setUsername(username);        req.setPassword(password);        IResponseMessage resp = signsession.createCertificate(administrator,req,Class.forName("se.anatom.ejbca.protocol.X509ResponseMessage"));        cert = CertTools.getCertfromByteArray(resp.getResponseMessage());        if(resulttype == ENCODED_CERTIFICATE)          result = cert.getEncoded();        else            result = signsession.createPKCS7(administrator, cert);        log.debug("Created certificate (PKCS7) for " + username);        debug.print("<h4>Generated certificate:</h4>");        debug.printInsertLineBreaks(cert.toString().getBytes());        return Base64.encode(result);    } //pkcs10CertReq            /**     * Formats certificate in form to be received by IE     *     * @param bA input     * @param out Output     */    public static void ieCertFormat(byte[] bA, PrintStream out)        throws Exception {        BufferedReader br = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(bA)));        int rowNr = 0;        while (true) {            String line = br.readLine();            if (line == null) {                break;            }            if (line.indexOf("END CERT") < 0) {                if (line.indexOf(" CERT") < 0) {                    if (++rowNr > 1) {                        out.println(" & _ ");                    } else {                        out.print("    cert = ");                    }                    out.print('\"' + line + '\"');                }            } else {                break;            }        }        out.println();    } // ieCertFormat    /**     * Reads template and inserts cert to send back to IE for installation of cert     *     * @param b64cert cert to be installed in IE-client     * @param out utput stream to send to     * @param sc serveltcontext     * @param responseTemplate path to responseTemplate     * @param classid replace     *     * @throws Exception on error     */    public static void sendNewCertToIEClient(byte[] b64cert, OutputStream out, ServletContext sc,        String responseTemplate, String classid) throws Exception {        if (b64cert.length == 0) {            log.error("0 length certificate can not be sent to IE client!");            return;        }        PrintStream ps = new PrintStream(out);        BufferedReader br = new BufferedReader(new InputStreamReader(sc.getResourceAsStream(                        responseTemplate)));        while (true) {            String line = br.readLine();            if (line == null) {                break;            }            if (line.indexOf("cert =") < 0) {                ps.println(CLASSID.matcher(line).replaceFirst(classid));            } else {                RequestHelper.ieCertFormat(b64cert, ps);            }        }        ps.close();        log.debug("Sent reply to IE client");        log.debug(new String(b64cert));    } // sendNewCertToIEClient    /**     * Sends back cert to NS/Mozilla for installation of cert     *     * @param certs DER encoded certificates to be installed in browser     * @param out output stream to send to     *     * @throws Exception on error     */    public static void sendNewCertToNSClient(byte[] certs, HttpServletResponse out)        throws Exception {        if (certs.length == 0) {            log.error("0 length certificate can not be sent to NS client!");            return;        }        // Set content-type to what NS wants        out.setContentType("application/x-x509-user-cert");        out.setContentLength(certs.length);        // Print the certificate        out.getOutputStream().write(certs);        log.debug("Sent reply to NS client");        log.debug(new String(Base64.encode(certs)));    } // sendNewCertToNSClient    /**     * Sends back certificate as binary file (application/octet-stream)     *     * @param b64cert base64 encoded certificate to be returned     * @param out output stream to send to     * @param beginKey, String contaitning key information, ie BEGIN_CERTIFICATE_WITH_NL or BEGIN_PKCS7_WITH_NL     * @param beginKey, String contaitning key information, ie END_CERTIFICATE_WITH_NL or END_PKCS7_WITH_NL     * @throws Exception on error     */    public static void sendNewB64Cert(byte[] b64cert, HttpServletResponse out, String beginKey, String endKey)        throws Exception {        if (b64cert.length == 0) {            log.error("0 length certificate can not be sent to client!");            return;        }        // Set content-type to general file        out.setContentType("application/octet-stream");                out.setHeader("Content-disposition", "filename=cert.pem");        out.setContentLength(b64cert.length + beginKey.length() + endKey.length());        // Write the certificate        ServletOutputStream os = out.getOutputStream();        os.write(beginKey.getBytes());        os.write(b64cert);        os.write(endKey.getBytes());        out.flushBuffer();        log.debug("Sent reply to client");        log.debug(new String(b64cert));    } // sendNewB64Cert    /**     * Sends back CA-certificate as binary file (application/x-x509-ca-cert)     *     * @param cert DER encoded certificate to be returned     * @param out output stream to send to     *     * @throws Exception on error     */    public static void sendNewX509CaCert(byte[] cert, HttpServletResponse out)        throws Exception {        // Set content-type to CA-cert        sendBinaryBytes(cert, out, "application/x-x509-ca-cert");    } // sendNewX509CaCert    /**     * Sends back a number of bytes     *     * @param bytes DER encoded certificate to be returned     * @param out output stream to send to     * @param contentType mime type to send back bytes as     *     * @throws Exception on error     */    public static void sendBinaryBytes(byte[] bytes, HttpServletResponse out, String contentType)        throws Exception {        if (bytes.length == 0) {            log.error("0 length can not be sent to client!");            return;        }        // Set content-type to general file        out.setContentType(contentType);        out.setContentLength(bytes.length);        // Write the certificate        ServletOutputStream os = out.getOutputStream();        os.write(bytes);        out.flushBuffer();        log.debug("Sent " + bytes.length + " bytes to client");    } // sendBinaryBytes        public static PKCS10RequestMessage genPKCS10RequestMessageFromPEM(byte[] b64Encoded){ 	  byte[] buffer = null;	  try {		// A real PKCS10 PEM request		String beginKey = BEGIN_CERTIFICATE_REQUEST;		String endKey = END_CERTIFICATE_REQUEST;		buffer = FileTools.getBytesFromPEM(b64Encoded, beginKey, endKey);      } catch (IOException e) {	 			try {			// Keytool PKCS10 PEM request			String beginKey = "-----BEGIN NEW CERTIFICATE REQUEST-----";			String endKey = "-----END NEW CERTIFICATE REQUEST-----";			buffer = FileTools.getBytesFromPEM(b64Encoded, beginKey, endKey);		} catch (IOException ioe) {			// IE PKCS10 Base64 coded request			buffer = Base64.decode(b64Encoded);        }      } 	  if (buffer == null) {		return null;	  }	  	  return new PKCS10RequestMessage(buffer);    } // PKCS10RequestMessage    }

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲国产成人av好男人在线观看| 秋霞av亚洲一区二区三| 欧美疯狂做受xxxx富婆| 色国产综合视频| 色妹子一区二区| 一本一本久久a久久精品综合麻豆| 国产成人免费视频精品含羞草妖精| 奇米一区二区三区av| 日本aⅴ免费视频一区二区三区| 亚洲成人你懂的| 欧美一级免费大片| 欧美日韩国产成人在线免费| 欧美精品 国产精品| 欧美久久久久久久久| 欧美日产在线观看| 欧美一区二区三区白人| 欧美成人高清电影在线| 久久久精品综合| 国产欧美一区二区在线观看| 国产亚洲欧美色| 亚洲天堂a在线| 亚洲最大成人网4388xx| 337p亚洲精品色噜噜噜| 欧美不卡一二三| 国产欧美一区二区三区网站 | 亚洲成av人片观看| 日韩电影在线观看电影| 国产麻豆日韩欧美久久| 成人福利视频网站| 91激情在线视频| 91麻豆精品国产91久久久使用方法 | 在线一区二区三区四区五区 | 国产成人综合在线| 99视频在线观看一区三区| 欧美三级电影精品| 久久精品在线免费观看| 国产精品电影院| 视频一区二区三区中文字幕| 国产精品中文字幕欧美| 91丨九色丨蝌蚪丨老版| 日韩一区二区三区在线观看| 久久久精品日韩欧美| 一区二区三区四区视频精品免费 | 精品国产123| 一区二区三区国产精华| 极品瑜伽女神91| 成人avav影音| 在线不卡一区二区| 欧美高清在线精品一区| 日韩一区二区在线看片| 亚洲日本电影在线| 国产一区在线观看麻豆| 欧美日韩免费一区二区三区 | 色综合久久久久网| 精品成人在线观看| 亚洲午夜羞羞片| av动漫一区二区| 26uuu国产一区二区三区| 亚洲国产cao| 91香蕉视频黄| 国产精品天美传媒| 激情五月播播久久久精品| 欧美二区乱c少妇| 色激情天天射综合网| 国产精品久久久久天堂| 国内精品久久久久影院一蜜桃| 精品视频一区三区九区| 伊人性伊人情综合网| aaa欧美色吧激情视频| 久久这里只有精品6| 秋霞午夜av一区二区三区| 欧美三级午夜理伦三级中视频| 亚洲欧洲国产专区| jlzzjlzz亚洲女人18| 国产亚洲欧美色| 国产亲近乱来精品视频| 精品一区二区三区欧美| 欧美一级夜夜爽| 另类调教123区| 久久精品人人做人人爽人人| 日韩成人午夜电影| 日韩一区二区三区视频在线观看| 免费看日韩精品| 精品88久久久久88久久久| 久久电影网电视剧免费观看| 精品国产一区二区三区av性色| 美女视频黄久久| 26uuu另类欧美| av亚洲产国偷v产偷v自拍| 亚洲欧美中日韩| 91国偷自产一区二区三区观看| 亚洲色图视频免费播放| 色婷婷香蕉在线一区二区| 亚洲午夜日本在线观看| 欧美男人的天堂一二区| 久久激情综合网| 国产欧美日韩视频一区二区| 97成人超碰视| 亚洲国产日产av| 在线不卡中文字幕播放| 韩国v欧美v日本v亚洲v| 国产女主播视频一区二区| 99国产精品国产精品毛片| 综合精品久久久| 欧美日本国产一区| 国产精品一级二级三级| 亚洲日本电影在线| 欧美一级片免费看| 99精品视频在线观看免费| 亚洲一区二区三区三| 欧美一区二区福利视频| 高清免费成人av| 天天色天天爱天天射综合| 2023国产精华国产精品| 一本色道久久综合亚洲91| 亚洲第一狼人社区| 久久久影视传媒| 欧美日韩亚洲综合| www.爱久久.com| 免费观看日韩av| 亚洲色图第一区| 日韩一级大片在线| 欧美自拍偷拍午夜视频| 亚洲不卡av一区二区三区| 亚洲精品一区二区在线观看| 91亚洲精品久久久蜜桃网站 | 亚洲精品欧美在线| 欧美大胆一级视频| 一本色道**综合亚洲精品蜜桃冫| 日本不卡中文字幕| 日本道在线观看一区二区| 狠狠色丁香久久婷婷综合丁香| 亚洲黄色录像片| 久久久精品日韩欧美| 欧美精品1区2区| av中文字幕亚洲| 国内精品国产成人国产三级粉色 | 欧美电影在线免费观看| 高清shemale亚洲人妖| 久久精品72免费观看| 亚洲成人在线免费| 亚洲网友自拍偷拍| 亚洲男人天堂一区| 国产亚洲一区字幕| 日韩精品在线一区二区| 色婷婷精品久久二区二区蜜臀av| 国产成人av资源| 国产精品系列在线观看| 美国毛片一区二区| 亚洲va国产天堂va久久en| 一区二区三区丝袜| 亚洲女女做受ⅹxx高潮| 中文字幕中文乱码欧美一区二区| 国产午夜精品一区二区三区四区| 欧美大片日本大片免费观看| 337p亚洲精品色噜噜| 9191久久久久久久久久久| 欧美日韩日日摸| 欧美一区二区在线播放| 日韩欧美一区二区在线视频| 欧美一级欧美三级| 日韩久久久久久| 欧美精品一区二区高清在线观看| 日韩视频一区二区三区在线播放| 欧美一区二区在线观看| 精品伦理精品一区| 久久噜噜亚洲综合| 国产精品美女久久久久久久| 国产精品久久午夜夜伦鲁鲁| 综合久久久久久| 亚洲成人1区2区| 精一区二区三区| 国产**成人网毛片九色| 成人黄色网址在线观看| 色偷偷成人一区二区三区91| 欧美日韩一区二区三区在线 | 精品奇米国产一区二区三区| 精品国产污污免费网站入口 | 日韩视频一区二区| 国产日韩欧美精品一区| 亚洲欧洲国产日韩| 毛片av一区二区| 成人福利视频在线看| 欧美日韩小视频| 久久久久久久久97黄色工厂| 久久精品免费在线观看| 亚洲久本草在线中文字幕| 日韩成人一级片| 波多野结衣欧美| 欧美福利视频一区| 久久久欧美精品sm网站| 一区二区三区欧美视频| 午夜精品久久久久久| 精一区二区三区| 日本韩国一区二区三区视频| 日韩一级二级三级精品视频| 国产精品久久久久久久久免费桃花| 午夜影视日本亚洲欧洲精品| 精品一区二区在线免费观看| 91蜜桃免费观看视频|