Package java.security

Examples of java.security.PrivateKey


        Document document = builder.parse(sourceDocument);
       
        // Set up the Key
        KeyPairGenerator rsaKeygen = KeyPairGenerator.getInstance("RSA");
        KeyPair kp = rsaKeygen.generateKeyPair();
        PrivateKey priv = kp.getPrivate();
        PublicKey pub = kp.getPublic();

        // Generate a traffic key
        KeyGenerator keygen = KeyGenerator.getInstance("AES");
        keygen.init(256);
View Full Code Here


        Document document = builder.parse(sourceDocument);

        // Set up the Key
        KeyPairGenerator rsaKeygen = KeyPairGenerator.getInstance("RSA");
        KeyPair kp = rsaKeygen.generateKeyPair();
        PrivateKey priv = kp.getPrivate();
        PublicKey pub = kp.getPublic();

        // Generate a traffic key
        KeyGenerator keygen = KeyGenerator.getInstance("AES");
        keygen.init(256);
View Full Code Here

        if (log.isDebugEnabled()) {
            log.debug("Can I resolve " + element.getTagName() + "?");
        }

        if (XMLUtils.elementIsInSignatureSpace(element, Constants._TAG_X509DATA)) {
            PrivateKey privKey = resolveX509Data(element, baseURI);
            if (privKey != null) {
                return privKey;
            }
        } else if (XMLUtils.elementIsInSignatureSpace(element, Constants._TAG_KEYNAME)) {
            log.debug("Can I resolve KeyName?");
View Full Code Here

            X509Data x509Data = new X509Data(element, baseURI);

            int len = x509Data.lengthSKI();
            for (int i = 0; i < len; i++) {
                XMLX509SKI x509SKI = x509Data.itemSKI(i);
                PrivateKey privKey = resolveX509SKI(x509SKI);
                if (privKey != null) {
                    return privKey;
                }
            }

            len = x509Data.lengthIssuerSerial();
            for (int i = 0; i < len; i++) {
                XMLX509IssuerSerial x509Serial = x509Data.itemIssuerSerial(i);
                PrivateKey privKey = resolveX509IssuerSerial(x509Serial);
                if (privKey != null) {
                    return privKey;
                }
            }

            len = x509Data.lengthSubjectName();
            for (int i = 0; i < len; i++) {
                XMLX509SubjectName x509SubjectName = x509Data.itemSubjectName(i);
                PrivateKey privKey = resolveX509SubjectName(x509SubjectName);
                if (privKey != null) {
                    return privKey;
                }
            }

            len = x509Data.lengthCertificate();
            for (int i = 0; i < len; i++) {
                XMLX509Certificate x509Cert = x509Data.itemCertificate(i);
                PrivateKey privKey = resolveX509Certificate(x509Cert);
                if (privKey != null) {
                    return privKey;
                }
            }
        } catch (XMLSecurityException e) {
View Full Code Here

            String identity = in.identity;
            String pem = in.credential;

            // extract private key
            KeyFactory keyFactory = KeyFactory.getInstance("RSA");
            PrivateKey privateKey = keyFactory.generatePrivate(Pems.privateKeySpec(Payloads.newStringPayload(pem)));

            // extract certificate(s)
            Collection<X509Certificate> certs = x509Certificates(pem);

            return new FGCPCredentials.Builder().identity(identity).credential(pem)
View Full Code Here

   }

   @Override
   public SSLContext get() {
      FGCPCredentials currentCreds = checkNotNull(creds.get(), "fgcpcredential supplier returned null");
      PrivateKey privateKey = checkNotNull(currentCreds.privateKey, "fgcpcredential's privateKey is null");
      Collection<X509Certificate> certs = checkNotNull(currentCreds.certificates, "fgcpcredential's certificates returned null");

      try {
         KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
         KeyStore keyStore = KeyStore.getInstance("pkcs12");
View Full Code Here

   
    InputStream in = DigitalSignatureTest.class.getResourceAsStream(keystoreFile);
    assertNotNull(in);
   
    ks.load(in, keystorePass.toCharArray());
    PrivateKey signingKey =
      (PrivateKey) ks.getKey(
        privateKeyAlias,
        privateKeyPass.toCharArray());
    X509Certificate cert =
      (X509Certificate) ks.getCertificate(
View Full Code Here

   
    InputStream in = DigitalSignatureTest.class.getResourceAsStream(keystoreFile);
    assertNotNull(in);
   
    ks.load(in, keystorePass.toCharArray());
    PrivateKey signingKey =
      (PrivateKey) ks.getKey(
        privateKeyAlias,
        privateKeyPass.toCharArray());
    X509Certificate cert =
      (X509Certificate) ks.getCertificate(
View Full Code Here

      throws XMLSecurityException,
             IRISyntaxException {   
    element.setBaseUri(element.getResolvedBaseUri());
    org.w3c.dom.Element dom = fomToDom((Element)element.clone(), options);
    org.w3c.dom.Document domdoc = dom.getOwnerDocument();
    PrivateKey signingKey = options.getSigningKey();
    X509Certificate cert = options.getCertificate();
    IRI baseUri = element.getResolvedBaseUri();
    XMLSignature sig = new XMLSignature(
      domdoc,
      (baseUri != null) ? baseUri.toString() : "",
View Full Code Here

                                         Crypto crypto,
                                         String keyEncAlgo,
                                         String digestAlgo,
                                         Message message) throws WSSecurityException {
        CallbackHandler callback = SecurityUtils.getCallbackHandler(message, this.getClass());
        PrivateKey key = null;
        try {
            key = crypto.getPrivateKey(cert, callback);
        } catch (Exception ex) {
            throwFault("Encrypted key can not be decrypted", ex);
        }
View Full Code Here

TOP

Related Classes of java.security.PrivateKey

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.