/**
   * Perform a remote setProperty on the Session using the remote Service URL.
   *
   * <p>{@inheritDoc}
   */
  public void setProperty(Session session, String name, String value) throws SessionException {
    if (debug.messageEnabled()) {
      debug.message(MessageFormat.format("Remote setProperty {0} {1}={2}", session, name, value));
    }

    SessionID sessionID = session.getID();
    SessionRequest sreq =
        new SessionRequest(SessionRequest.SetProperty, sessionID.toString(), false);
    sreq.setPropertyName(name);
    sreq.setPropertyValue(value);
    if (SystemProperties.isServerMode() && InternalSession.isProtectedProperty(name)) {
      try {
        SSOToken admSSOToken = SessionUtils.getAdminToken();
        sreq.setRequester(RestrictedTokenContext.marshal(admSSOToken));
      } catch (SSOException e) {
        throw new SessionException(e);
      } catch (Exception e) {
        throw new SessionException(e);
      }

      if (debug.messageEnabled()) {
        debug.message(
            "Session.setProperty: "
                + "added admSSOToken in sreq to set "
                + "externalProtectedProperty in remote server");
      }
    }
    requests.sendRequestWithRetry(session.getSessionServiceURL(), sreq, session);
  }
 private void createAttributeMapping() {
   // this does not apply client mode because client's property
   // never get store in SMS services
   if (SystemProperties.isServerMode()) {
     Map attributeMap = SystemProperties.getAttributeMap();
     for (Iterator i = attributeMap.values().iterator(); i.hasNext(); ) {
       AttributeStruct a = (AttributeStruct) i.next();
       migratedServiceNames.add(a.getServiceName());
     }
   }
 }
  /**
   * Returns Session Service URL for a Session ID.
   *
   * @param sid Session ID
   * @return Session Service URL.
   * @exception SessionException
   */
  public URL getSessionServiceURL(SessionID sid) throws SessionException {
    String primaryId;

    if (SystemProperties.isServerMode()) {

      /**
       * Validate that the SessionID contains valid Server and Site references. This check is not
       * appropriate for client side code as only the Site reference is exposed to client code.
       */
      sid.validate();

      SessionService ss = InjectorHolder.getInstance(SessionService.class);
      if (ss.isSiteEnabled() && ss.isLocalSite(sid)) {
        if (ss.isSessionFailoverEnabled()) {
          return getSessionServiceURL(ss.getCurrentHostServer(sid));
        } else {
          primaryId = sid.getExtension().getPrimaryID();
          return getSessionServiceURL(primaryId);
        }
      }
    } else {
      primaryId = sid.getExtension().getPrimaryID();
      if (primaryId != null) {
        String secondarysites = WebtopNaming.getSecondarySites(primaryId);

        String serverID = SessionService.getAMServerID();
        if ((secondarysites != null) && (serverID != null)) {
          if (secondarysites.indexOf(serverID) != -1) {
            return getSessionServiceURL(serverID);
          }
        }
      }
    }

    return getSessionServiceURL(
        sid.getSessionServerProtocol(),
        sid.getSessionServer(),
        sid.getSessionServerPort(),
        sid.getSessionServerURI());
  }