Package java.security

Examples of java.security.GeneralSecurityException


                        {
                            serverInstance = createBougusServerSSLContext();
                        }
                        catch( Exception ioe )
                        {
                            throw new GeneralSecurityException(
                                    "Can't create Server SSLContext:" + ioe );
                        }
                    }
                }
            }
View Full Code Here


  /**
   * @tests java.security.GeneralSecurityException#GeneralSecurityException()
   */
  public void test_Constructor() {
    // Test for method java.security.GeneralSecurityException()
    GeneralSecurityException e = new GeneralSecurityException();
    assertNotNull("Constructor returned null instance", e);
    assertEquals("Failed toString test for constructed instance", "java.security.GeneralSecurityException", e
        .toString());
  }
View Full Code Here

   * @tests java.security.GeneralSecurityException#GeneralSecurityException(java.lang.String)
   */
  public void test_ConstructorLjava_lang_String() {
    // Test for method
    // java.security.GeneralSecurityException(java.lang.String)
    GeneralSecurityException e = new GeneralSecurityException(
        "test message");
    assertNotNull("Constructor returned null instance", e);
    assertEquals("Failed toString test for constructed instance",
            "java.security.GeneralSecurityException: test message", e
        .toString());
  }
View Full Code Here

    if (requireClientCert || mode == SSLFactory.Mode.SERVER) {
      String locationProperty =
        resolvePropertyName(mode, SSL_KEYSTORE_LOCATION_TPL_KEY);
      String keystoreLocation = conf.get(locationProperty, "");
      if (keystoreLocation.isEmpty()) {
        throw new GeneralSecurityException("The property '" + locationProperty +
          "' has not been set in the ssl configuration file.");
      }
      String passwordProperty =
        resolvePropertyName(mode, SSL_KEYSTORE_PASSWORD_TPL_KEY);
      keystorePassword = conf.get(passwordProperty, "");
      if (keystorePassword.isEmpty()) {
        throw new GeneralSecurityException("The property '" + passwordProperty +
          "' has not been set in the ssl configuration file.");
      }
      LOG.debug(mode.toString() + " KeyStore: " + keystoreLocation);

      InputStream is = new FileInputStream(keystoreLocation);
      try {
        keystore.load(is, keystorePassword.toCharArray());
      } finally {
        is.close();
      }
      LOG.info(mode.toString() + " Loaded KeyStore: " + keystoreLocation);
    } else {
      keystore.load(null, null);
    }
    KeyManagerFactory keyMgrFactory = KeyManagerFactory.getInstance("SunX509");
    keyMgrFactory.init(keystore, (keystorePassword != null) ?
                                 keystorePassword.toCharArray() : null);
    keyManagers = keyMgrFactory.getKeyManagers();

    //trust store
    String truststoreType =
      conf.get(resolvePropertyName(mode, SSL_TRUSTSTORE_TYPE_TPL_KEY),
               DEFAULT_KEYSTORE_TYPE);

    String locationProperty =
      resolvePropertyName(mode, SSL_TRUSTSTORE_LOCATION_TPL_KEY);
    String truststoreLocation = conf.get(locationProperty, "");
    if (truststoreLocation.isEmpty()) {
      throw new GeneralSecurityException("The property '" + locationProperty +
        "' has not been set in the ssl configuration file.");
    }

    String passwordProperty = resolvePropertyName(mode,
                                                  SSL_TRUSTSTORE_PASSWORD_TPL_KEY);
    String truststorePassword = conf.get(passwordProperty, "");
    if (truststorePassword.isEmpty()) {
      throw new GeneralSecurityException("The property '" + passwordProperty +
        "' has not been set in the ssl configuration file.");
    }
    long truststoreReloadInterval =
      conf.getLong(
        resolvePropertyName(mode, SSL_TRUSTSTORE_RELOAD_INTERVAL_TPL_KEY),
View Full Code Here

                        {
                            serverInstance = createBougusServerSSLContext();
                        }
                        catch( Exception ioe )
                        {
                            throw new GeneralSecurityException(
                                    "Can't create Server SSLContext:" + ioe );
                        }
                    }
                }
            }
View Full Code Here

     */
    protected PKIXBuilderParameters getPKIXBuilderParameters(PKIXValidationInformation validationInfo,
            X509Credential untrustedCredential) throws GeneralSecurityException {
        Set<TrustAnchor> trustAnchors = getTrustAnchors(validationInfo);
        if (trustAnchors == null || trustAnchors.isEmpty()) {
            throw new GeneralSecurityException(
                    "Unable to validate X509 certificate, no trust anchors found in the PKIX validation information");
        }

        X509CertSelector selector = new X509CertSelector();
        selector.setCertificate(untrustedCredential.getEntityCertificate());
View Full Code Here

    }

    public SSLContext createSSLContext(String provider, String protocol, String algorithm, String keyStore, String keyAlias, String trustStore, long timeout) throws GeneralSecurityException {

        if (!this.checkForKeystoresAvailability(keyStore, keyAlias, trustStore, timeout)) {
            throw new GeneralSecurityException("Unable to lookup configured keystore and/or truststore");
        }

        KeystoreInstance keyInstance = getKeystore(keyStore);
        if (keyInstance != null && keyInstance.isKeystoreLocked()) {
            throw new KeystoreIsLocked("Keystore '" + keyStore + "' is locked");
View Full Code Here

            }
            if (System.currentTimeMillis() - start < timeout) {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new GeneralSecurityException("Interrupted", e);
                }
            } else {
                return false;
            }
        }
View Full Code Here

    if (requireClientCert || mode == SSLFactory.Mode.SERVER) {
      String locationProperty =
        resolvePropertyName(mode, SSL_KEYSTORE_LOCATION_TPL_KEY);
      String keystoreLocation = conf.get(locationProperty, "");
      if (keystoreLocation.isEmpty()) {
        throw new GeneralSecurityException("The property '" + locationProperty +
          "' has not been set in the ssl configuration file.");
      }
      String passwordProperty =
        resolvePropertyName(mode, SSL_KEYSTORE_PASSWORD_TPL_KEY);
      keystorePassword = conf.get(passwordProperty, "");
      if (keystorePassword.isEmpty()) {
        throw new GeneralSecurityException("The property '" + passwordProperty +
          "' has not been set in the ssl configuration file.");
      }
      LOG.debug(mode.toString() + " KeyStore: " + keystoreLocation);

      InputStream is = new FileInputStream(keystoreLocation);
      try {
        keystore.load(is, keystorePassword.toCharArray());
      } finally {
        is.close();
      }
      LOG.debug(mode.toString() + " Loaded KeyStore: " + keystoreLocation);
    } else {
      keystore.load(null, null);
    }
    KeyManagerFactory keyMgrFactory = KeyManagerFactory
        .getInstance(SSLFactory.SSLCERTIFICATE);
     
    keyMgrFactory.init(keystore, (keystorePassword != null) ?
                                 keystorePassword.toCharArray() : null);
    keyManagers = keyMgrFactory.getKeyManagers();

    //trust store
    String truststoreType =
      conf.get(resolvePropertyName(mode, SSL_TRUSTSTORE_TYPE_TPL_KEY),
               DEFAULT_KEYSTORE_TYPE);

    String locationProperty =
      resolvePropertyName(mode, SSL_TRUSTSTORE_LOCATION_TPL_KEY);
    String truststoreLocation = conf.get(locationProperty, "");
    if (truststoreLocation.isEmpty()) {
      throw new GeneralSecurityException("The property '" + locationProperty +
        "' has not been set in the ssl configuration file.");
    }

    String passwordProperty = resolvePropertyName(mode,
                                                  SSL_TRUSTSTORE_PASSWORD_TPL_KEY);
    String truststorePassword = conf.get(passwordProperty, "");
    if (truststorePassword.isEmpty()) {
      throw new GeneralSecurityException("The property '" + passwordProperty +
        "' has not been set in the ssl configuration file.");
    }
    long truststoreReloadInterval =
      conf.getLong(
        resolvePropertyName(mode, SSL_TRUSTSTORE_RELOAD_INTERVAL_TPL_KEY),
View Full Code Here

        case MAC:
            return new MacDigestManager(ledgerId, passwd);
        case CRC32:
            return new CRC32DigestManager(ledgerId);
        default:
            throw new GeneralSecurityException("Unknown checksum type: " + digestType);
        }
    }
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.