public static DSAPublicKey loadDSAPublicKeyFile(String uname){
  String filename=ClientConfig.getUserKeysPath() + "/" + uname+ ".pub";
  DSAPublicKey pubKey=null;
  FileInputStream fis=null;
  try {
    fis=new FileInputStream(filename);
    byte[] keyBytes=new byte[fis.available()];
    fis.read(keyBytes);
    KeyFactory keyFactory=KeyFactory.getInstance("DSA","SUN");
    X509EncodedKeySpec pubKeySpec=new X509EncodedKeySpec(keyBytes);
    pubKey=(DSAPublicKey)keyFactory.generatePublic(pubKeySpec);
  }
 catch (  IOException e) {
    Logging.error(e.getMessage());
  }
catch (  NoSuchAlgorithmException e) {
    Logging.error(e.getMessage());
  }
catch (  NoSuchProviderException e) {
    Logging.error(e.getMessage());
  }
catch (  InvalidKeySpecException e) {
    Logging.error(e.getMessage());
  }
 finally {
    CommonMessaging.close(fis);
  }
  return pubKey;
}

public static DSAPublicKey loadDSAPublicKeyFile ( String uname ) { String filename = ClientConfig . getUserKeysPath ( ) + "/" + uname + ".pub" ; DSAPublicKey pubKey = null ; FileInputStream fis = null ; try { fis = new FileInputStream ( filename ) ; byte [ ] keyBytes = new byte [ fis . available ( ) ] ; fis . read ( keyBytes ) ; KeyFactory keyFactory = KeyFactory . getInstance ( "DSA" , "SUN" ) ; X509EncodedKeySpec pubKeySpec = new X509EncodedKeySpec ( keyBytes ) ; pubKey = ( DSAPublicKey ) keyFactory . generatePublic ( pubKeySpec ) ; } catch ( IOException e ) { Logging . error ( e . getMessage ( ) ) ; } catch ( NoSuchAlgorithmException e ) { Logging . error ( e . getMessage ( ) ) ; } catch ( NoSuchProviderException e ) { Logging . error ( e . getMessage ( ) ) ; } catch ( InvalidKeySpecException e ) { Logging . error ( e . getMessage ( ) ) ; } finally { CommonMessaging . close ( fis ) ; } return pubKey ; }
loads a public key from a stored file .
