Package java.security

Examples of java.security.GeneralSecurityException


        SSLEngine result = context.createSSLEngine();
        result.setUseClientMode(false);
        if (ANONYMOUS.equals(authenticationMode)) {
            if (!(Arrays.asList(result.getSupportedCipherSuites()).contains(SocketUtil.ANON_CIPHER_SUITE))) {
              throw new GeneralSecurityException(RuntimePlugin.Util.getString("SSLConfiguration.no_anonymous")); //$NON-NLS-1$
            }
            result.setEnabledCipherSuites(new String[] {
                SocketUtil.ANON_CIPHER_SUITE
            });
        }
View Full Code Here


                break;
            case TRUST_THIS_SESSION_ONLY:
                temporalyAllowed.add(cert);
                break;
            default:
                throw new GeneralSecurityException(
                    "Cannot add a certificate to truststore "
                        + "when no trust is requested.");
        }
    }
View Full Code Here

      } else {
        signKey = keys[0];
      }

      if (signKey == null) {
        throw new GeneralSecurityException("No signature key selected.");
      }
    }

    if(signKey == null &&  (cryptoType == PGP_SIGN || cryptoType == PGP_BOTH)){
      Key[] keys = cryptoManager.getPrivateKeysForAddress(from.getAddress(), EncryptionManager.PGP,  true);
      if (keys == null || keys.length == 0) {
        // show dialog
        signKey = CryptoKeySelector.selectPrivateKey(Pooka.getProperty("Pooka.crypto.privateKey.forSign", "Select key to sign this message."), EncryptionManager.PGP, true);

      } else {
        signKey = keys[0];
      }

      if (signKey == null) {
        throw new GeneralSecurityException("No signature key selected.");
      }
    }

    List encKeys = new LinkedList();

    //TODO: get the encKey from the available public keys
    if (cryptoType == SMIME_ENCRYPT || cryptoType == SMIME_BOTH || cryptoType == PGP_ENCRYPT || cryptoType == PGP_BOTH) {
      String type = (cryptoType == SMIME_ENCRYPT || cryptoType == SMIME_BOTH) ? EncryptionManager.SMIME : EncryptionManager.PGP;
      // Get the public key of the senders
      Address[] froms = mm.getFrom();
      for (int i = 0; i < froms.length; i++) {
        from = (InternetAddress) froms[i];
        Key[] keys = cryptoManager.getPublicKeys(from.getAddress(), type, false);
        if (keys != null && keys.length > 0) {
          encKeys.add(keys[0]);
        }
      }

      // Get the public key of the receivers
      Address[] receivers = mm.getAllRecipients();
      for (int i = 0; i < receivers.length; i++) {
        InternetAddress rec = (InternetAddress) receivers[i];
        Key[] keys = cryptoManager.getPublicKeys(rec.getAddress(), type, false);
        if (keys != null && keys.length > 0) {
          encKeys.add(keys[0]);
        } else {
          Key key = CryptoKeySelector.selectPublicKey(Pooka.getProperty("Pooka.crypto.publicKey.forEncrypt", "Select key to encrypt this message."), EncryptionManager.PGP, false);
          if (key != null)
            encKeys.add(key);
          else
            throw new GeneralSecurityException("found no certificate for " + rec.getAddress());
        }
      }
      /*Key encKey = CryptoKeySelector.selectPublicKey(
        Pooka.getProperty("Pooka.crypto.publicKey.forEncrypt",
        "Select key to encrypt this message."),
View Full Code Here

                if (keyManagers[idx] instanceof X509KeyManager) {
                    try {
                        keyManagers[idx] = new AliasedX509ExtendedKeyManager(
                            tlsClientParameters.getCertAlias(), (X509KeyManager)keyManagers[idx]);
                    } catch (Exception e) {
                        throw new GeneralSecurityException(e);
                    }
                }
            }
        }
    }
View Full Code Here

                if (keyManagers[idx] instanceof X509KeyManager) {
                    try {
                        ret[idx] = new AliasedX509ExtendedKeyManager(tlsClientParameters.getCertAlias(),
                                                                             (X509KeyManager)keyManagers[idx]);
                    } catch (Exception e) {
                        throw new GeneralSecurityException(e);
                    }
                } else {
                    ret[idx] = keyManagers[idx];
                }
            }
View Full Code Here

                return kmf.getKeyManagers();
            }
        }
        catch (IOException e)
        {
            throw new GeneralSecurityException(e);
        }
    }
View Full Code Here

                c.proveIdentity(sharedSecret,key);
                if (c.readBoolean())
                    return serverIdentity;  // succeeded
            }
            if (privateKeys.iterator().hasNext())
                throw new GeneralSecurityException("Authentication failed. No private key accepted.");
            else
                throw new GeneralSecurityException("No private key is available for use in authentication");
        } finally {
            c.close();
        }
    }
View Full Code Here

        int sessionTimeoutInt = Integer.parseInt(this.parsePropertyValue(sessionTimeout));
       
        if (sessionContext != null) {
            sessionContext.setSessionTimeout(sessionTimeoutInt);
        } else {
            throw new GeneralSecurityException(
                    "The SSLContext does not support SSLSessionContext, "
                            + "but a session timeout is configured. Set sessionTimeout to null "
                            + "to avoid this error.");
        }
    }
View Full Code Here

            throw new IOException("Version of the underlying RandomAccessBuffer is "
                + "incompatible with this ERATType");
          }

          if(!verifyHeader()){
            throw new GeneralSecurityException("MAC is incorrect");
          }
        }
        ParametersWithIV tempPram = null;
        try{
            KeyParameter cipherKey = new KeyParameter(KeyGenUtils.deriveSecretKey(unencryptedBaseKey,
View Full Code Here

        try {
            CryptByteBuffer crypt = new CryptByteBuffer(type.encryptType, headerEncKey,
                    headerEncIV);
            encryptedKey = crypt.encryptCopy(unencryptedBaseKey.getEncoded());
        } catch (InvalidKeyException e) {
            throw new GeneralSecurityException("Something went wrong with key generation. please "
                    + "report", e.fillInStackTrace());
        } catch (InvalidAlgorithmParameterException e) {
            throw new GeneralSecurityException("Something went wrong with key generation. please "
                    + "report", e.fillInStackTrace());
        }
        System.arraycopy(encryptedKey, 0, header, offset, encryptedKey.length);
        offset += encryptedKey.length;

        byte[] ver = ByteBuffer.allocate(4).putInt(version).array();
        try {
            MessageAuthCode mac = new MessageAuthCode(type.macType, headerMacKey);
            byte[] macResult = Fields.copyToArray(mac.genMac(headerEncIV, unencryptedBaseKey.getEncoded(), ver));
            System.arraycopy(macResult, 0, header, offset, macResult.length);
            offset += macResult.length;
        } catch (InvalidKeyException e) {
            throw new GeneralSecurityException("Something went wrong with key generation. please "
                    + "report", e.fillInStackTrace());
        }
       
        System.arraycopy(ver, 0, header, offset, ver.length);
        offset +=ver.length;
View Full Code Here

TOP

Related Classes of java.security.GeneralSecurityException

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.