Package net.solosky.maplefetion.bean

Examples of net.solosky.maplefetion.bean.User


            TransferFactory transferFactory,
            FetionStore fetionStore,
            FetionTimer timer,
            FetionExecutor executor)
  {
    this(new User(account, password, "fetion.com.cn"),
        notifyEventListener,
        transferFactory,
        fetionStore,
        timer,
        executor);
View Full Code Here


   */
  public FetionClient(String account,
            String password,
            NotifyEventListener notifyEventListener)
  {
    this(new User(account, password, "fetion.com.cn"),
        notifyEventListener,
        new AutoTransferFactory(),
        new SimpleFetionStore(),
        new ThreadTimer(),
        new SingleExecutor());
View Full Code Here

   
    FetionStore store = this.context.getFetionStore();
   
    //解析个人信息,飞信真有意思,这里却不简写,map.xml里面全是简写的,所以这里只能手动注入了。
    Element personal = XMLHelper.find(root, "/results/user-info/personal");
    User user = this.context.getFetionUser();
    user.setEmail(personal.getAttributeValue("register-email"));

    int personalVersion = Integer.parseInt(personal.getAttributeValue("version"));
    Element contactList = XMLHelper.find(root, "/results/user-info/contact-list");
    int contactVersion = Integer.parseInt(contactList.getAttributeValue("version"));
   
    //联系人和个人信息版本信息
    store.getStoreVersion().setPersonalVersion(personalVersion);
    store.getStoreVersion().setContactVersion(contactVersion);
    user.getStoreVersion().setPersonalVersion(personalVersion);
    user.getStoreVersion().setContactVersion(contactVersion);
   
    //个人信息
    BeanHelper.toBean(User.class, user, personal);
   
   
    //一定要对飞信列表加锁,防止其他飞信操作获取到空的数据
    synchronized (store) {

      //解析分组列表
      List list = XMLHelper.findAll(root, "/results/user-info/contact-list/buddy-lists/*buddy-list");
      Iterator it = list.iterator();
      while(it.hasNext()) {
        Element e = (Element) it.next();
        store.addCord(new Cord(Integer.parseInt(e.getAttributeValue("id")), e.getAttributeValue("name")));
      }
     
      //解析好友列表
      list = XMLHelper.findAll(root, "/results/user-info/contact-list/buddies/*b");
      it = list.iterator();
      while(it.hasNext()) {
        Element e = (Element) it.next();
        String uri = e.getAttributeValue("u");
       
        Buddy b = UriHelper.createBuddy(uri);
        b.setUserId(Integer.parseInt(e.getAttributeValue("i")));
        b.setLocalName(e.getAttributeValue("n"));
        b.setUri(e.getAttributeValue("u"));
        b.setCordId(e.getAttributeValue("l"));
        b.setRelation(Relation.valueOf(Integer.parseInt(e.getAttributeValue("r"))));
       
        store.addBuddy(b);
      }
     
      //处理 chat-friend..
        //这个chat-friend具体是什么含义我也没搞得太清楚,目前猜测里面的名单可能和用户是陌生人关系
      list = XMLHelper.findAll(root, "/results/user-info/contact-list/chat-friends/*c");
      it = list.iterator();
        while(it.hasNext()){
          Element e = (Element) it.next();
          Buddy b = UriHelper.createBuddy(e.getAttributeValue("u"));
        b.setUserId(Integer.parseInt(e.getAttributeValue("i")));
        b.setUri(e.getAttributeValue("u"));
            b.setRelation(Relation.STRANGER);
            store.addBuddy(b);
        }
       
        //处理Blacklist
        list = XMLHelper.findAll(root, "/results/user-info/contact-list/blacklist/*k");
      it = list.iterator();
        while(it.hasNext()){
          Element e = (Element) it.next();
          String uri = e.getAttributeValue("u");
          Buddy b = store.getBuddyByUri(uri);
          if(b!=null) {
            b.setRelation(Relation.BANNED);
          }
        }
       
       
        //处理Crendeticals
        Element credentialList = XMLHelper.find(root, "/results/credentials");
       
        user.setSsiCredential(this.decryptCredential(credentialList.getAttributeValue("kernel")));
       
        list = XMLHelper.findAll(root, "/results/credentials/*credential");
        it = list.iterator();
        while(it.hasNext()) {
          Element e = (Element) it.next();
View Full Code Here

   
    return super.doActionOK(response);
  }
 
    private String decryptCredential(String c) throws FetionException {
      User user = this.context.getFetionUser();
      try {
            byte[] encrypted = StringHelper.base64Decode(c);
            byte[] decrypted = DigestHelper.AESDecrypt(encrypted, user.getAesKey(), user.getAesIV());
            return new String(decrypted,"utf8");
        } catch (IOException ex) {
          throw new SystemException("decrypt credential failed.", ex);
        }
    }
View Full Code Here

  @Override
  protected ActionEvent doActionOK(SipcResponse response)
      throws FetionException
  {
    Element personal = XMLHelper.build(response.getBody().toSendString()).getChild("personal");
      User user = this.context.getFetionUser();
     
      user.setNickName(personal.getAttributeValue("nickname"));
      user.setImpresa(personal.getAttributeValue("impresa"));
      user.setTrueName(personal.getAttributeValue("name"));
     
      int userId = Integer.parseInt(personal.getAttributeValue("user-id"));
      BeanHelper.setValue(user, "userId", userId);
      long mobile = Long.parseLong(personal.getAttributeValue("mobile-no"));
      BeanHelper.setValue(user, "mobile", mobile);
View Full Code Here

      Element root = XMLHelper.build(response.getBody().toSendString());
      Element credentialList = XMLHelper.find(root, "/results/credentials");
    List list = XMLHelper.findAll(root, "/results/credentials/*credential");
    Iterator it = list.iterator();
    FetionStore store = this.context.getFetionStore();
    User user = this.context.getFetionUser();
   
    user.setSsiCredential(this.decryptCredential(credentialList.getAttributeValue("kernel")));
   
    while(it.hasNext()) {
      Element e = (Element) it.next();
      String domain = e.getAttributeValue("domain");
      Credential c = store.getCredential(domain);
View Full Code Here

     * @param c
     * @return
     * @throws FetionException
     */
    private String decryptCredential(String c) throws FetionException {
      User user = this.context.getFetionUser();
      try {
            byte[] encrypted = StringHelper.base64Decode(c);
            byte[] decrypted = DigestHelper.AESDecrypt(encrypted, user.getAesKey(), user.getAesIV());
            return new String(decrypted,"utf8");
        } catch (IOException ex) {
          throw new SystemException("decrypt credential failed.", ex);
        }
    }
View Full Code Here

TOP

Related Classes of net.solosky.maplefetion.bean.User

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.