public SshPairImpl generatePair(String owner,String service,String name) throws ServerException, ConflictException {
  KeyPair keyPair;
  try {
    keyPair=KeyPair.genKeyPair(genJSch,2,2048);
  }
 catch (  JSchException e) {
    throw new ServerException("Failed to generate ssh pair.",e);
  }
  ByteArrayOutputStream privateBuff=new ByteArrayOutputStream();
  keyPair.writePrivateKey(privateBuff);
  ByteArrayOutputStream publicBuff=new ByteArrayOutputStream();
  keyPair.writePublicKey(publicBuff,null);
  final SshPairImpl generatedSshPair=new SshPairImpl(owner,service,name,publicBuff.toString(),privateBuff.toString());
  sshDao.create(generatedSshPair);
  return generatedSshPair;
}

public SshPairImpl generatePair ( String owner , String service , String name ) throws ServerException , ConflictException { KeyPair keyPair ; try { keyPair = KeyPair . genKeyPair ( genJSch , 2 , 2048 ) ; } catch ( JSchException e ) { throw new ServerException ( "Failed to generate ssh pair." , e ) ; } ByteArrayOutputStream privateBuff = new ByteArrayOutputStream ( ) ; keyPair . writePrivateKey ( privateBuff ) ; ByteArrayOutputStream publicBuff = new ByteArrayOutputStream ( ) ; keyPair . writePublicKey ( publicBuff , null ) ; final SshPairImpl generatedSshPair = new SshPairImpl ( owner , service , name , publicBuff . toString ( ) , privateBuff . toString ( ) ) ; sshDao . create ( generatedSshPair ) ; return generatedSshPair ; }
generates and stores ssh pair for specified user .
