Package net.sourceforge.cardme.vcard.types

Examples of net.sourceforge.cardme.vcard.types.KeyType


    sound.setEncodingType(EncodingType.BINARY);
    sound.setAudioMediaType(AudioMediaType.OGG);
    sound.setSoundURI(new File("test/images/smallTux.png").toURI());
    vcard.addSound(sound);
   
    KeyType key = new KeyType();
    key.setKeyTextType(KeyTextType.GPG);
    key.setEncodingType(EncodingType.BINARY);
    key.setCompression(false);
    byte[] keyBytes = Util.getFileAsBytes(new File("test/images/smallTux.png"));
    key.setKey(keyBytes);
    vcard.addKey(key);
   
    ExtendedType xGenerator = new ExtendedType("X-GENERATOR", "Cardme Generator");
    xGenerator.setCharset("UTF-8");
   
View Full Code Here


 
  @Test
  public void testBuildKeyType() throws VCardBuildException {
    VCardImpl vcard = getSimpleVCard();
   
    KeyType keyPlain = new KeyType();
    keyPlain.setKeyTextType(KeyTextType.PGP);
    keyPlain.setKey("plain text key");
    vcard.addKey(keyPlain);
   
    KeyType keyBin = new KeyType();
    keyBin.setKeyTextType(KeyTextType.X509);
    keyBin.setEncodingType(EncodingType.BINARY);
    keyBin.setKey("binary data".getBytes());
    vcard.addKey(keyBin);
   
    VCardWriter vcardWriter = new VCardWriter();
    vcardWriter.setOutputVersion(VCardVersion.V3_0);
    vcardWriter.setCompatibilityMode(CompatibilityMode.RFC2426);
View Full Code Here

    VCardImpl vcard = (VCardImpl)vCardEngine.parse(sb.toString());

    List<KeyType> list = vcard.getKeys();

    KeyType f = list.get(0);
    assertEquals(KeyTextType.PGP, f.getKeyTextType());
    assertArrayEquals("plain text key".getBytes(), f.getKey());
    assertEquals(EncodingType.EIGHT_BIT, f.getEncodingType());

    f = list.get(1);
    assertEquals(KeyTextType.GPG, f.getKeyTextType());
    assertArrayEquals("quoted printable\r\nkey".getBytes(), f.getKey());
    assertEquals(EncodingType.EIGHT_BIT, f.getEncodingType());

    f = list.get(2);
    assertEquals(KeyTextType.X509, f.getKeyTextType());
    assertArrayEquals(Base64Wrapper.decode("YmluYXJ5IGRhdGE="), f.getKey());
    assertEquals(EncodingType.BINARY, f.getEncodingType());
  }
View Full Code Here

   * @param vcard
   * @throws VCardParseException
   */
  private void parseKeyType(String group, String value, List<ParameterType> paramTypeList, VCardImpl vcard) throws VCardParseException {
    try {
      KeyType keyType = new KeyType();
      parseParamTypes(keyType, paramTypeList, value, VCardTypeName.KEY);
     
      if(keyType.isQuotedPrintable()) {
        value = decodeQuotedPrintableValue(keyType, value);
      }
     
      if(keyType.isBinary()) {
        byte[] keyBytes = Base64Wrapper.decode(value);
        keyType.setKey(keyBytes);
      }
      else {
        keyType.setKey(value);
      }
     
      if(group != null) {
        keyType.setGroup(group);
      }
     
      vcard.addKey(keyType);
    }
    catch(Exception ex) {
View Full Code Here

  @Test
  public void testKey() throws VCardBuildException {
    VCardImpl vcard = new VCardImpl();
    appyBasicName(vcard);
   
    KeyType key = new KeyType("plain text key", KeyTextType.PGP);
    vcard.addKey(key);
    key = new KeyType("binary data".getBytes(), KeyTextType.X509);
    vcard.addKey(key);

    String result = getSerializedString(vcard);
    assertTrue(result.contains("KEY;TYPE=PGP:plain text key"));
    assertTrue(result.contains("KEY;ENCODING=B;TYPE=X509:YmluYXJ5IGRhdGE="));
View Full Code Here

TOP

Related Classes of net.sourceforge.cardme.vcard.types.KeyType

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.