Examples of KeyStore


Examples of java.security.KeyStore

   
    private static void saveKey(String file, SecretKey key) throws CryptoException, IOException {
      ArgCheck.isNotNull(file);
      FileOutputStream fos = new FileOutputStream(file);
      try {
          KeyStore store = KeyStore.getInstance("JCEKS"); //$NON-NLS-1$
          store.load(null,null);
        store.setKeyEntry(DEFAULT_ALIAS, key, DEFAULT_STORE_PASSWORD.toCharArray(),null);
        store.store(fos, DEFAULT_STORE_PASSWORD.toCharArray());
      } catch (GeneralSecurityException e) {
        throw new CryptoException(e);
      } finally {
        fos.close();
     
View Full Code Here

Examples of java.security.KeyStore

          // doesn't look very empty, bail!
       
        return;
      }
     
      KeyStore keystore = getTrustStore();
     
      if ( keystore.size() == 0 ){
       
        File cacerts = new File( new File( new File( System.getProperty( "java.home" ), "lib" ), "security" ), "cacerts" );
       
        if ( cacerts.exists()){
         
View Full Code Here

Examples of java.security.KeyStore

     
      return( false );
    }
   
    try{
      KeyStore key_store = loadKeyStore();
     
      Enumeration enumx = key_store.aliases();
     
      if ( !enumx.hasMoreElements()){
        Logger.logTextResource(new LogAlert(LogAlert.UNREPEATABLE,
            LogAlert.AT_ERROR, "Security.keystore.empty"),
            new String[] { keystore_name });
View Full Code Here

Examples of java.security.KeyStore

    String  name )
  {
    try{
      this_mon.enter();
   
      KeyStore keystore = KeyStore.getInstance( KEYSTORE_TYPE );
     
      if ( !new File(name).exists()){
   
        keystore.load(null,null);
     
        FileOutputStream  out = null;
       
        try{
          out = new FileOutputStream(name);
     
          keystore.store(out, SESecurityManager.SSL_PASSWORD.toCharArray());
     
        }finally{
         
          if ( out != null ){
           
View Full Code Here

Examples of java.security.KeyStore

  public KeyStore
  getTrustStore()
 
    throws Exception
  {
    KeyStore keystore = KeyStore.getInstance( KEYSTORE_TYPE );
   
    if ( !new File(truststore_name).exists()){
 
      keystore.load(null,null);
     
    }else{
   
      FileInputStream    in   = null;

      try{
        in = new FileInputStream(truststore_name);
   
        keystore.load(in, SESecurityManager.SSL_PASSWORD.toCharArray());
       
      }finally{
       
        if ( in != null ){
         
View Full Code Here

Examples of java.security.KeyStore

  loadKeyStore(
    KeyManagerFactory  keyManagerFactory )
   
    throws Exception
  {
    KeyStore key_store = KeyStore.getInstance( KEYSTORE_TYPE );
   
    if ( !new File(keystore_name).exists()){
     
      key_store.load(null,null);
     
    }else{
     
      InputStream kis = null;
     
      try{
        kis = new FileInputStream(keystore_name);
     
        key_store.load(kis, SESecurityManager.SSL_PASSWORD.toCharArray());
       
      }finally{
       
        if ( kis != null ){
         
View Full Code Here

Examples of java.security.KeyStore

 
    throws Exception
  {
    // Create the key manager factory used to extract the server key
       
    KeyStore key_store = loadKeyStore();
   
    final Key key = key_store.getKey( alias, SESecurityManager.SSL_PASSWORD.toCharArray());
   
    if ( key == null ){
     
      return( null );
    }
   
    java.security.cert.Certificate[]  chain = key_store.getCertificateChain( alias );

    final X509Certificate[]  res = new X509Certificate[chain.length];
   
    for (int i=0;i<chain.length;i++){
     
View Full Code Here

Examples of java.security.KeyStore

  getSSLSocketFactory()
  {
    try{
      this_mon.enter();
   
      KeyStore keystore = getTrustStore();
           
      TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
     
      tmf.init(keystore);
     
View Full Code Here

Examples of java.security.KeyStore

       
        Object[]  handler = (Object[])certificate_handlers.get( url_s );
       
        String  alias = host.concat(":").concat(String.valueOf(port));
       
        KeyStore keystore = getTrustStore();

        byte[]  new_encoded = x509_cert.getEncoded();
       
        int  count = 0;
       
        while( count < 256 ){
         
          String  test_alias = count==0?alias:(alias + "." + count );
         
          Certificate existing = keystore.getCertificate( test_alias );
       
          if ( existing != null ){
         
            if ( Arrays.equals( new_encoded, existing.getEncoded())){
           
View Full Code Here

Examples of java.security.KeyStore

    throws Exception
  {
    try{
      this_mon.enter();
   
      KeyStore keystore = getTrustStore();
     
      if ( cert != null ){
       
        if ( keystore.containsAlias( alias )){
       
          keystore.deleteEntry( alias );
        }
             
        keystore.setCertificateEntry(alias, cert);
 
        FileOutputStream  out = null;
       
        try{
          out = new FileOutputStream(truststore_name);
     
          keystore.store(out, SESecurityManager.SSL_PASSWORD.toCharArray());
     
        }finally{
         
          if ( out != null ){
           
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.