コード例 #1
0
  public boolean isUserInAFederatedDomain(String userPrinciaplName) {
    log.info("isUserInAFederatedDomain {0}", userPrinciaplName);

    String[] parts = userPrinciaplName.split("@");

    Office365Domain dom = getDomain(parts[1]);

    if (dom != null) {
      if (dom.getDomainType() == Office365Domain.DOMAIN_TYPE_FEDERATED) {
        return true;
      } else {
        return false;
      }
    } else {
      throw new ConnectorException("Domain for " + userPrinciaplName + " does not exist");
    }
  }
コード例 #2
0
  private void populateVerifiedDomains() {
    log.info("populateVerifiedDomains");
    this.verifiedDomains = new HashMap<String, Office365Domain>();

    JSONObject obj = getRequest("/tenantDetails?api-version=" + Office365Connection.API_VERSION);
    try {
      JSONArray verifiedDomains =
          obj.getJSONArray("value").getJSONObject(0).getJSONArray("verifiedDomains");

      for (int i = 0; i < verifiedDomains.length(); i++) {
        JSONObject domainObj = verifiedDomains.getJSONObject(i);

        Office365Domain domain = null;
        String name = domainObj.getString("name").toLowerCase();
        String type = domainObj.getString("type");
        if (type.equals("Federated")) {
          log.info("Got a Federated domain named {0}", name);
          domain = new Office365FederatedDomain(name);
          this.verifiedDomains.put(name, domain);
        } else if (type.equals("Managed")) {
          log.info("Got a Managed domain named {0}", name);
          domain = new Office365ManagedDomain(name);
          this.verifiedDomains.put(name, domain);
        } else if (type.equals("None")) {
          log.info("Received a None domain for {0},  skipping", name);
        } else {
          log.error("Unrecognised type of {0} passed for domain {1}", type, domain);
          throw new ConnectorException(
              "Unrecognised domain type of " + type + " received for doman " + name);
        }

        if (domain != null) {
          domain.initiliseCapability(domainObj.getString("capabilities").split(","));
          domain.setDefaultDomain(domainObj.getBoolean("default"));
          domain.setId(domainObj.getString("id"));
          domain.setInitial(domainObj.getBoolean("initial"));
        }
      }

      log.info("Finished reading verified domains");
    } catch (JSONException je) {
      log.error(je, "Error populating verified domains");
    }
  }