Пример #1
0
  private PutMethod convertHttpServletRequestToPutMethod(String url, HttpServletRequest request) {
    PutMethod method = new PutMethod(url);

    for (Enumeration headers = request.getHeaderNames(); headers.hasMoreElements(); ) {
      String headerName = (String) headers.nextElement();
      String headerValue = (String) request.getHeader(headerName);
      method.addRequestHeader(headerName, headerValue);
    }

    method.removeRequestHeader("Host");
    method.addRequestHeader("Host", request.getRequestURL().toString());

    StringBuilder requestBody = new StringBuilder();
    try {
      BufferedReader reader = request.getReader();
      String line;
      while (null != (line = reader.readLine())) {
        requestBody.append(line);
      }
      reader.close();
    } catch (IOException e) {
      requestBody.append("");
    }

    method.setRequestEntity(new StringRequestEntity(requestBody.toString()));

    return method;
  }
    public static String toString(MapMarker... markers) {
      if (markers.length > 0) {
        StringBuilder sb = new StringBuilder();

        sb.append(MarkersKey).append("=");

        for (int i = 0; i < markers.length; i++) {
          sb.append(markers[i].toString());
          if (i != markers.length - 1) sb.append(MarkerSeparator);
        }

        return sb.toString();
      } else {
        return "";
      }
    }
  // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  // param handling and uri generation
  // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  public String getURI(double lat, double lon, int sizeW, int sizeH, MapMarker... markers) {
    _validateParams(sizeW, sizeH, ZoomDefault);

    // generate the URI
    StringBuilder sb = new StringBuilder();
    sb.append(GmapStaticURI);

    // size key
    sb.append("?").append(SizeKey).append("=").append(sizeW).append(SizeSeparator).append(sizeH);

    // markers key
    sb.append("&").append(MarkerUtils.toString(markers));

    // maps key
    sb.append("&").append(GmapLicenseKey).append("=").append(GmapLicense);

    return sb.toString();
  }
  public String getURI(double lat, double lon, int sizeW, int sizeH, int zoom) {
    _validateParams(sizeW, sizeH, zoom);

    // generate the URI
    StringBuilder sb = new StringBuilder();
    sb.append(GmapStaticURI);

    // center key
    sb.append("?").append(CenterKey).append("=").append(lat).append(",").append(lon);

    // zoom key
    sb.append("&").append(ZoomKey).append("=").append(zoom);

    // size key
    sb.append("&").append(SizeKey).append("=").append(sizeW).append(SizeSeparator).append(sizeH);

    // markers key
    sb.append("&").append(MarkerUtils.toString(new MapMarker(lat, lon)));

    // maps key
    sb.append("&").append(GmapLicenseKey).append("=").append(GmapLicense);

    return sb.toString();
  }
Пример #5
0
  private void init() {
    // Register the trust manager to use when using HTTPS
    Protocol easyhttps =
        new Protocol("https", (ProtocolSocketFactory) new SSLProtocolSocketFactory(this), 443);
    Protocol.registerProtocol("https", easyhttps);

    // Convert XML based provider setup to Database based
    JiveGlobals.migrateProperty("clearspace.uri");
    JiveGlobals.migrateProperty("clearspace.sharedSecret");

    // Make sure that all Clearspace components are set up, unless they were overridden
    // Note that the auth provider is our way of knowing that we are set up with Clearspace,
    // so don't bother checking to set it.
    if (isEnabled()) {
      if (JiveGlobals.getProperty("provider.user.className") == null) {
        JiveGlobals.setProperty(
            "provider.user.className",
            "org.jivesoftware.openfire.clearspace.ClearspaceUserProvider");
      }
      if (JiveGlobals.getProperty("provider.group.className") == null) {
        JiveGlobals.setProperty(
            "provider.group.className",
            "org.jivesoftware.openfire.clearspace.ClearspaceGroupProvider");
      }
      if (JiveGlobals.getProperty("provider.vcard.className") == null) {
        JiveGlobals.setProperty(
            "provider.vcard.className",
            "org.jivesoftware.openfire.clearspace.ClearspaceVCardProvider");
      }
      if (JiveGlobals.getProperty("provider.lockout.className") == null) {
        JiveGlobals.setProperty(
            "provider.lockout.className",
            "org.jivesoftware.openfire.clearspace.ClearspaceLockOutProvider");
      }
      if (JiveGlobals.getProperty("provider.securityAudit.className") == null) {
        JiveGlobals.setProperty(
            "provider.securityAudit.className",
            "org.jivesoftware.openfire.clearspace.ClearspaceSecurityAuditProvider");
      }
      if (JiveGlobals.getProperty("provider.admin.className") == null) {
        JiveGlobals.setProperty(
            "provider.admin.className",
            "org.jivesoftware.openfire.clearspace.ClearspaceAdminProvider");
      }
    }

    this.uri = properties.get("clearspace.uri");
    if (uri != null) {
      if (!this.uri.endsWith("/")) {
        this.uri = this.uri + "/";
      }
      // Updates the host/port attributes based on the uri
      updateHostPort();
    }
    sharedSecret = properties.get("clearspace.sharedSecret");

    // Creates the cache maps
    userIDCache = new DefaultCache<String, Long>("clearspace.userid", 1000, JiveConstants.DAY);
    groupIDCache = new DefaultCache<String, Long>("clearspace.groupid", 1000, JiveConstants.DAY);
    usernameCache = new DefaultCache<Long, String>("clearspace.username", 1000, JiveConstants.DAY);

    if (Log.isDebugEnabled()) {
      StringBuilder buf = new StringBuilder();
      buf.append("Created new ClearspaceManager() instance, fields:\n");
      buf.append("\t URI: ").append(uri).append("\n");
      buf.append("\t sharedSecret: ").append(sharedSecret).append("\n");

      Log.debug("ClearspaceManager: " + buf.toString());
    }

    // Init nonce cache
    nonceCache = CacheFactory.createCache("Clearspace SSO Nonce");
    // Init nonce generator
    nonceGenerator = new Random();
  }