Package fr.dyade.aaa.agent

Examples of fr.dyade.aaa.agent.AgentId


  /**
   * Specializes this <code>Topic</code> reaction.
   */
  protected void doUnknownAgent(UnknownAgent uA) {
    AgentId agId = uA.agent;
    Notification not = uA.not;

    // For admin requests, notifying the administrator.
    if (not instanceof AdminRequestNot) {
      String reqId = ((AdminRequestNot) not).getId();

      if (reqId != null) {
        AgentId replyTo = (AgentId) requestsTable.remove(reqId);

        strbuf.append("Request [").append(not.getClass().getName());
        strbuf.append("], sent to AdminTopic on server [").append(serverId);
        strbuf.append("], successful [false]: unknown agent [").append(agId).append(']');

View Full Code Here


    while (messages.hasNext()) {
      Message msg = (Message) messages.next();
      nbMsgsReceiveSinceCreation += 1;

      String msgId = msg.id;
      AgentId replyTo = AgentId.fromString(msg.replyToId);
      AdminRequest request = (AdminRequest) msg.getAdminMessage();

      if (logger.isLoggable(BasicLevel.DEBUG))
        logger.log(BasicLevel.DEBUG, "--- " + this + ": got " + request);
View Full Code Here

   * deletion of a destination.
   */
  private void doProcess(DeleteDestination request,
                         AgentId replyTo,
                         String msgId) throws UnknownServerException {
    AgentId destId = AgentId.fromString(request.getId());

    // If the destination is not local, doing nothing:
    if (checkServerId(destId.getTo())) {
      // The destination is  local, process the request.
      String info;

      Iterator destinations = destinationsTable.values().iterator();
      while (destinations.hasNext()) {
        DestinationDesc destDesc = (DestinationDesc) destinations.next();
        if (destDesc.getId().equals(destId)) {
          destinationsTable.remove(destDesc.getName());
          break;
        }
      }

      forward(destId, new DeleteNot());

      info = strbuf.append("Request [").append(request.getClass().getName())
      .append("], sent to AdminTopic on server [").append(serverId)
      .append("], successful [true]: destination [").append(destId)
      .append("], successfuly notified for deletion").toString();
      strbuf.setLength(0);

      distributeReply(replyTo, msgId, new AdminReply(true, info));

      if (logger.isLoggable(BasicLevel.DEBUG))
        logger.log(BasicLevel.DEBUG, info);
    } else {
      // Forward the request to the right AdminTopic agent.
      forward(getDefault(destId.getTo()),
              new FwdAdminRequestNot(request, replyTo, msgId));
    }
  }
View Full Code Here

    if (checkServerId(request.getServerId())) {
      // If this server is the target server, process the request.
      Identity identity = request.getIdentity();
      String name = identity.getUserName();

      AgentId proxId = (AgentId) proxiesTable.get(name);
      String info;

      // The user has already been set.
      if (proxId != null) {
        Identity userIdentity = (Identity) usersTable.get(name);
        if (logger.isLoggable(BasicLevel.INFO))
          logger.log(BasicLevel.INFO, "User [" + name + "] already exists : " + userIdentity);
        try {
          if (! userIdentity.check(identity)) {
            throw new RequestException("User [" + name + "] already exists"
                                       + " but with a different password.");
          }
        } catch (Exception e) {
          throw new RequestException("User [" + name + "] already exists :: Exception :" + e.getMessage());
        }
        info = strbuf.append("Request [").append(request.getClass().getName())
        .append("], processed by AdminTopic on server [").append(serverId)
        .append("], successful [true]: proxy [").append(proxId.toString())
        .append("] of user [").append(name)
        .append("] has been retrieved").toString();
        strbuf.setLength(0);
      } else {
//        try {
//          if (! identity.validate()) {
//            throw new RequestException("User [" + name + "] security validate failed.");
//          }
//        } catch (Exception e) {
//          throw new RequestException(e.getMessage());
//        }

        UserAgent proxy = new UserAgent();
        proxy.setName(name);
        proxId = proxy.getId();
       
        // set interceptors.
        proxy.setInterceptors(request.getProperties());
       
        try {
          // deploy UserAgent
          proxy.deploy();
          if (logger.isLoggable(BasicLevel.DEBUG))
            logger.log(BasicLevel.DEBUG, "doProcess CreateUserRequest:: store (in usersTable) this identity = " + identity);
          usersTable.put(name, identity);
          proxiesTable.put(name, proxy.getId());

          info = strbuf.append("Request [").append(request.getClass().getName())
          .append("], processed by AdminTopic on server [").append(serverId)
          .append("], successful [true]: proxy [")
          .append(proxId.toString()).append("] for user [").append(name)
          .append("] has been created and deployed").toString();
          strbuf.setLength(0);
        }
        catch (Exception exc) {
          if (logger.isLoggable(BasicLevel.ERROR))
            logger.log(BasicLevel.ERROR, "EXCEPTION:: createUser [" + name + "]", exc);
          throw new RequestException("User proxy not deployed: " + exc);
        }
      }

      if (logger.isLoggable(BasicLevel.DEBUG))
        logger.log(BasicLevel.DEBUG, info);

      distributeReply(replyTo,
                      msgId,
                      new CreateUserReply(proxId.toString(), info));
    } else {
      // Forward the request to the right AdminTopic agent.
      forward(getDefault((short) request.getServerId()),
              new FwdAdminRequestNot(request, replyTo, msgId));
    }
View Full Code Here

  private void doProcess(UpdateUser request,
                         AgentId replyTo,
                         String msgId)
  throws RequestException, UnknownServerException {
    String name = request.getUserName();
    AgentId proxId = AgentId.fromString(request.getProxId());

    if (checkServerId(proxId.getTo())) {
      // If the user belong to this server, process the request.
      String info;

      // If the user does not exist: throwing an exception:
      if (! usersTable.containsKey(name))
        throw new RequestException("User [" + name + "] does not exist");

      Identity newIdentity = request.getNewIdentity();
      // If the new name is already taken by an other user than the modified
      // one:
      if (! newIdentity.getUserName().equals(name)
          && (usersTable.containsKey(newIdentity.getUserName())))
        throw new RequestException("Name [" + newIdentity.getUserName() + "] already used");

      if (usersTable.containsKey(name)) {
        usersTable.remove(name);
        proxiesTable.remove(name);
        if (logger.isLoggable(BasicLevel.DEBUG))
          logger.log(BasicLevel.DEBUG, "doProcess UpdateUser:: store (in usersTable) this identity = " + newIdentity);
        usersTable.put(newIdentity.getUserName(), newIdentity);
        proxiesTable.put(newIdentity.getUserName(), proxId);
      }

      info = strbuf.append("Request [").append(request.getClass().getName())
      .append("], processed by AdminTopic on server [").append(serverId)
      .append("], successful [true]: user [").append(name)
      .append("] has been updated to [").append(newIdentity.getUserName()).
      append("]").toString();
      strbuf.setLength(0);

      distributeReply(replyTo, msgId, new AdminReply(true, info));

      if (logger.isLoggable(BasicLevel.DEBUG))
        logger.log(BasicLevel.DEBUG, info);
    } else {
      // Forward the request to the right AdminTopic agent.
      forward(getDefault(proxId.getTo()),
              new FwdAdminRequestNot(request, replyTo, msgId));
    }
  }
View Full Code Here

   * Processes a <code>DeleteUser</code> instance requesting the deletion
   * of a user.
   */
  private void doProcess(DeleteUser request, AgentId replyTo, String msgId) throws UnknownServerException {
    String name = request.getUserName();
    AgentId proxId = AgentId.fromString(request.getProxId());

    if (checkServerId(proxId.getTo())) {
      // If the user belong to this server, process the request.
      if (usersTable.containsKey(name)) {
        if (logger.isLoggable(BasicLevel.DEBUG))
          logger.log(BasicLevel.DEBUG, "Forward delete request to proxy " + proxId);
        forward(proxId, new FwdAdminRequestNot(request, replyTo, msgId, createMessageId()));
      } else {
        String info = strbuf.append("Request [").append(request.getClass().getName())
            .append("], sent to AdminTopic on server [").append(serverId)
            .append("], successful [false]: user [").append(name).append("] does not exist").toString();
        strbuf.setLength(0);
        if (logger.isLoggable(BasicLevel.DEBUG))
          logger.log(BasicLevel.DEBUG, info);
        distributeReply(replyTo, msgId, new AdminReply(AdminReply.NAME_UNKNOWN, info));
      }

    } else {
      // Forward the request to the right AdminTopic agent.
      forward(getDefault(proxId.getTo()), new FwdAdminRequestNot(request, replyTo, msgId));
    }
  }
View Full Code Here

   * If the AgentId of the DMQ is NullId unset the DMQ.
   *
   * @exception UnknownServerException  If the target server does not exist.
   */
  private void doProcess(SetDMQRequest request, AgentId replyTo, String msgId) throws UnknownServerException {
    AgentId destId = AgentId.fromString(request.getDestId());

    if (destId.isNullId()) {
      // This request ask to set the default DMQ
      if (checkServerId(destId.getTo())) {
        // Set the default DMQ for local server
        Queue.defaultDMQId = null;
        if (request.getDmqId() != null)
          Queue.defaultDMQId = AgentId.fromString(request.getDmqId());

        distributeReply(replyTo, msgId, new AdminReply(true, null));
      } else {
        // Forward the request to the right AdminTopic agent.
        forward(getDefault(destId.getTo()),
                new FwdAdminRequestNot(request, replyTo, msgId));
      }
    } else {
      // Send the request to the destination or User.
      forward(destId, new FwdAdminRequestNot(request, replyTo, msgId, createMessageId()));
View Full Code Here

   * @exception UnknownServerException  If the target server does not exist.
   */
  private void doProcess(SetThresholdRequest request,
                         AgentId replyTo,
                         String msgId) throws UnknownServerException {
    AgentId destId = AgentId.fromString(request.getDestId());

    if (destId.isNullId()) {
      // Set the default Threshold
      if (checkServerId(destId.getTo())) {
        // Set the default Threshold for local server
        Queue.defaultThreshold = 0;
        if (request.getThreshold() > 0)
          Queue.defaultThreshold = request.getThreshold();

        distributeReply(replyTo, msgId, new AdminReply(true, null));
      } else {
        // Forward the request to the right AdminTopic agent.
        forward(getDefault(destId.getTo()),
                new FwdAdminRequestNot(request, replyTo, msgId));
      }
    } else {
      // Forward the request to the target.
      forward(destId, new FwdAdminRequestNot(request, replyTo, msgId, createMessageId()));
View Full Code Here

   * to its target destination, if local.
   */
  private void doProcess(GetRightsRequest request,
                         AgentId replyTo,
                         String msgId) throws UnknownServerException {
    AgentId destId = AgentId.fromString(request.getDest());

    // Be careful, this request must be sent to the AdminTopic of the server where
    // the destination is, because the information about users is handled locally.
    // It the reply is handled by this AdminTopic it is bad !!
    // This issue should disappear with roles based security.
   if (checkServerId(destId.getTo())) {
      // The destination is local, process the request.
      forward(destId, new GetRightsRequestNot(msgId));
      if (replyTo != null) requestsTable.put(msgId, replyTo);
    } else {
      // Forward the request to the right AdminTopic agent.
      forward(getDefault(destId.getTo()),
              new FwdAdminRequestNot(request, replyTo, msgId));
    }
  }
View Full Code Here

   * @exception UnknownServerException  If the target server does not exist.
   */
  private void doProcess(GetDMQSettingsRequest request,
                         AgentId replyTo,
                         String msgId) throws UnknownServerException {
    AgentId targetId = AgentId.fromString(request.getTarget());
   
    if (targetId.isNullId()) {
      // Get the default DMQ setting
      if (checkServerId(targetId.getTo())) {
        // Get the default DMQ setting for local server
        String dmqId = null;
        if (Queue.defaultDMQId != null)
          dmqId = Queue.defaultDMQId.toString();
        GetDMQSettingsReply reply = new GetDMQSettingsReply(dmqId, Queue.defaultThreshold);
        distributeReply(replyTo, msgId, reply);
      } else {
        // Forward the request to the right AdminTopic agent.
        forward(getDefault(targetId.getTo()),
                new FwdAdminRequestNot(request, replyTo, msgId));
      }
    } else {
      // Forward the request to the target
      forward(targetId, new FwdAdminRequestNot(request, replyTo, msgId, createMessageId()));
View Full Code Here

TOP

Related Classes of fr.dyade.aaa.agent.AgentId

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.