/*
(non-Javadoc)
@see org.jdiameter.client.api.controller.IRealmTable#getRealms(java.lang.String)
513799
@Override
  public Collection<Realm> getRealms(String realmName) {
    RealmSet set = this.realmNameToRealmSet.get(realmName);
    if (set != null) {
      Collection<Realm> present = set.values();
      return new ArrayList<Realm>(present);
    }
    return new ArrayList<Realm>(0);
  }
598871
protected String getMessage(String key, Object[] params){
		MessageSource messageSource = ValkyrieRepository.getInstance().getApplicationConfig().messageSource();
		return messageSource.getMessage(key, params, Locale.getDefault());
	}
525255
private String getRealmNameOrFirstBest(Root root) {
        String value = null;
        value = getRealmName(root);
        if (value == null) {
            try {
                value = getRealmName();
            } catch (Exception e) {
                // leave realm at null
            }
        }
        return value;
    }
467241
protected String getRealIdScope()
    {
        ServletRequest request = pageContext.getRequest();
        
        // default to the set idScope.
        String idScope = _idScope;

        // if there isn't a set idScope and generate scope is on, generate the scope id.
        if (_idScope == null && _genScope) {
            int id = getNextId(request);
            idScope = "n" + Integer.toString(id);
            _idScope = idScope;
        }
        
        // if there's still no idScope and we're in a ScopedRequest, use the scope-key from the request.
        if (_idScope == null) {
            ScopedRequest scopedRequest = ScopedServletUtils.unwrapRequest(request);
            if (scopedRequest != null) {
                _idScope = scopedRequest.getScopeKey().toString();
                idScope = _idScope;
            }
        }
        
        return idScope;
    }
512593
@GET
    public Response getMBeans(
            @QueryParam("key") @DefaultValue("root") String key,
            @QueryParam("mode") @DefaultValue("") String mode,
            @QueryParam("jsonp") @DefaultValue("") String jsonp)
            throws Exception {

        LOG.info("key" + key);
        DynaTreeNode root = new DynaTreeNode();
        for (String domain : jmx.getDomainList()) {
            root.putChild(jmx.getDomainTree(domain).setTitle(domain)
                    .setMode("domain"));
        }

        StringWriter out = new StringWriter();
        if (jsonp.isEmpty()) {
            root.getChildrenJSONArray().write(out);
        } else {
            out.append(jsonp).append("(");
            root.getChildrenJSONArray().write(out);
            out.append(");");
        }

        return Response.ok(out.toString()).header("Pragma", "no-cache")
                .header("Cache-Control", "no-cache").header("Expires", "0")
                .build();
    }
1233012
@Override
  public Answer processRequest(IRequest request, IRealm matchedRealm) {
    try {
      Answer ans = request.createAnswer(RESULT_REDIRECT_INDICATION);
      AvpSet set = ans.getAvps();
      String[] destHosts = matchedRealm.getPeerNames();
      for (String host:destHosts) {
        set.addAvp(Avp.REDIRECT_HOST, host, false);
      }

      IAgentConfiguration agentConfiguration = matchedRealm.getAgentConfiguration();
      //default
      int rhuValue = RHU_REALM_AND_APPLICATION;
      if (agentConfiguration != null) {
        Properties p = agentConfiguration.getProperties();
        try {
          rhuValue = Integer.parseInt(p.getProperty(RHU_PROPERTY, "" + rhuValue));
        }
        catch (Exception e) {
          if (logger.isWarnEnabled()) {
            logger.warn("Failed to parse configuration value. ", e);
          }
        }
      }

      set.addAvp(Avp.REDIRECT_HOST_USAGE, rhuValue);
      ans.setError(true);
      super.container.sendMessage((IMessage) ans);
    }
    catch (Exception e) {
      if (logger.isDebugEnabled()) {
        logger.debug("Failure when trying to send Answer", e);
      }
      Answer ans = request.createAnswer(RESULT_INVALID_AVP_VALUE);
      // now lets do the magic.
      if (e instanceof AvpDataException && ((AvpDataException) e).getAvp() != null) {
        // lets add failed if its present
        AvpSet failedAvp = ans.getAvps().addGroupedAvp(Avp.FAILED_AVP);
        failedAvp.addAvp(((AvpDataException) e).getAvp());
      }
      try {
        container.sendMessage((IMessage) ans);
      }
      catch (RouteException re) {
        if (logger.isDebugEnabled()) {
          logger.debug("Failure when trying to send failure answer", re);
        }
      }
      catch (AvpDataException ade) {
        if (logger.isDebugEnabled()) {
          logger.debug("Failure when trying to send failure answer", ade);
        }
      }
      catch (IllegalDiameterStateException idse) {
        if (logger.isDebugEnabled()) {
          logger.debug("Failure when trying to send failure answer", idse);
        }
      }
      catch (IOException ioe) {
        if (logger.isDebugEnabled()) {
          logger.debug("Failure when trying to send failure answer", ioe);
        }
      }
    }
    return null;
  }
735798
public function getRealmWithPermission() {

    $realms = [];

    $contentTypes = $this->getContentTypes();

    foreach ($contentTypes as $bundle) {
      $entity_type = 'node';
      $fields = $this->getEntityAccessFields($entity_type, $bundle);

      /** @var \Drupal\field\Entity\FieldConfig $field */
      foreach ($fields as $field) {
        $field_storage = $field->getFieldStorageDefinition();
        // @TODO Add support for allowed_values_function.
        $allowed_values = $field_storage->getSetting('allowed_values');
        if (!empty($allowed_values)) {
          foreach ($allowed_values as $field_key => $field_label) {
            // e.g. label = node.article.field_content_visibility:public.
            $permission_label = $field->id() . ':' . $field_key;
            $op = 'view';
            $permission = $op . ' ' . $permission_label . ' content';
            $bundle_id = $bundle->id();
            $field_name = $field->getName();
            $realm = $this->getRealmForFieldValue($op, $entity_type, $bundle_id, $field_name, $field_key);
            $realms[$realm] = $permission;
          }
        }
      }
    }

    return $realms;
  }
672269
private static String getDefaultRealm(UserRegistry _userRegistry) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            SibTr.entry(tc, CLASS_NAME + "getDefaultRealm");
        }
        String realm = DEFAULT_REALM;
        if (_userRegistry != null) {
            realm = _userRegistry.getRealm();
        }
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            SibTr.exit(tc, CLASS_NAME + "getDefaultRealm", realm);
        }
        return realm;
    }
700896
public String getParam(String paramName) {
		if (requestParameters == null) {
			return null;
		}
		String[] values = requestParameters.get(paramName);
		if (ArrayUtil.isNotEmpty(values)) {
			return values[0];
		}
		return null;
	}
329501
public static String getRealm(String accessId) {
        Matcher m = matcher(accessId);
        if (m != null) {
            return m.group(2);
        }
        return null;
    }
741916
protected Realm matchRealm(IMessage message, String realm) {
    if (realmExists(realm)) {
      ApplicationId singleId = message.getSingleApplicationId();
      // check on single app id, than we iterate.
      Realm r = getRealm(realm, singleId);
      if (r == null) {
        List<ApplicationId> appIds = message.getApplicationIdAvps();
        for (int index = 0; index < appIds.size(); index++) {
          r = getRealm(realm, appIds.get(index));
          if (r != null) {
            break;
          }
        }
      }

      return r;
    }
    return null;
  }
1307388
public Object[] getHyperValues(MP parms) {
    Object[] result = new Object[_hyper_names.length];
    for (int i = 0; i < _hyper_names.length; i++) {
      result[i] = PojoUtils.getFieldValue(parms, _hyper_names[i], _field_naming_strategy);
    }
    return result;
  }
1160944
public int getRenderIndexFromRealIdx(final int realIdx) {
        if (columnMapping == null || realIdx == -1) {
            return realIdx;
        }

        for (final Entry<Integer, Integer> entry : columnMapping.entrySet()) {
            if (entry.getValue().equals(realIdx)) {
                return entry.getKey();
            }
        }

        return realIdx;
    }
553415
private ArrayList<String> getRealmsFromJson(JSONObject jsonChallenges) {
        Iterator<String> challengesIterator = jsonChallenges.keys();
        ArrayList<String> challenges = new ArrayList<>();

        while (challengesIterator.hasNext()) {
            challenges.add(challengesIterator.next());
        }

        return challenges;
    }
1211170
public function getCurrentRealmsAffections(): array
    {
        $realmsAffections = [];
        foreach ($this->getRealmsAffectionsSum() as $periodName => $periodSum) {
            $realmsAffections[$periodName] = new RealmsAffection([$periodSum, $periodName]);
        }

        return $realmsAffections;
    }
1153033
@Override
    public Serializable getRealObject() throws IOException, ClassNotFoundException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "getRealObject");

        Serializable obj = null;

        // We 'have' a real object, though we may not still have a ref to to it.
        if (hasRealObject) {
            obj = realObject;

            // if it is null it may be because we previously serialized & threw away the strong ref
            if ((obj == null) && (hasSerializedRealObject)) {

                // Unless the value really is a null, we will have set a SoftReference for it
                if (softRefToRealObject != null) {

                    // Can we get it back from the SoftReference?
                    obj = softRefToRealObject.get();
                    // If not, deserialize from the message.
                    if (obj == null) {
                        obj = deserializeToRealObject();
                    }
                }

            }

            // If we hadn't previously serialized the message, then whatever was in realObject is the real
            // value, even if it is null.
        }

        // If we didn't 'have' a real object at all, just deserialize the one in the message
        else {
            obj = deserializeToRealObject();
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "getRealObject", (obj == null ? "null" : obj.getClass()));
        return obj;
    }
424275
def getRealmForDbid(dbid)
      @realm = nil
      if USING_HTTPCLIENT
         begin
            httpclient = HTTPClient.new
            resp = httpclient.get("https://www.quickbase.com/db/#{dbid}")
            location = resp.header['Location'][0]
            location.sub!("https://","")
            parts = location.split(/\./)
            @realm = parts[0]
         rescue StandardError => error
            @realm = nil 
         end
      else
         raise "Please get the HTTPClient gem: gem install httpclient" 
      end   
      @realm
   end