コード例 #1
0
ファイル: OCPAgent.java プロジェクト: ccbon/ocp
  public void createUser(
      String login, String password, int backupNbr, Captcha captcha, String answer)
      throws Exception {
    LOG.info("creating user: "******", " + password + ", " + backupNbr + ", answer=" + answer);
    LOG.info("captcha=" + captcha);
    OCPUser user = new OCPUser(this, login, backupNbr);
    UserPublicInfo upi = user.getPublicInfo(this);

    ContactMap contactMap = ds().getComponent(ContactMap.class);
    Contact contact = contactMap.getContact(captcha.contactId);

    // 1) create the public part of the user.
    // catpcha is required in order to avoid massive fake user creation
    Data publicUserData = new Data(this, user, ds().serializer.serialize(upi));
    Link publicUserDataLink =
        new Link(user, this, UserPublicInfo.getKey(this, login), publicUserData.getKey(this));

    getClient().createUser(contact, publicUserData, publicUserDataLink, captcha, answer);

    // 2) create the private part of the user.
    // no need captcha because creation of object is checked by the user
    // public info
    Key key = new Key(hash(ucrypt(password, (login + password).getBytes())));
    byte[] content = ucrypt(password, ds().serializer.serialize(user));
    Content privateUserData = new Data(this, user, content);
    Link privateUserDataLink = new Link(user, this, key, privateUserData.getKey(this));

    setWithLink(user, privateUserData, privateUserDataLink);
  }
コード例 #2
0
ファイル: OCPAgent.java プロジェクト: ccbon/ocp
 public Contact removeContact(Contact contact) {
   ContactMap contactMap = ds().getComponent(ContactMap.class);
   OCPContact c = (OCPContact) contactMap.remove(contact);
   try {
     Iterator<Id> it = c.nodeIdSet.iterator();
     while (it.hasNext()) {
       Id id = it.next();
       LOG.info("removing node to nodeMap");
       nodeMap.remove(id);
     }
     return c;
   } catch (Exception e) {
     return null;
   }
 }