gpt4 book ai didi

org.jxmpp.stringprep.XmppStringprepException类的使用及代码示例

转载 作者:知者 更新时间:2024-03-25 22:43:05 27 4
gpt4 key购买 nike

本文整理了Java中org.jxmpp.stringprep.XmppStringprepException类的一些代码示例,展示了XmppStringprepException类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XmppStringprepException类的具体详情如下:
包路径:org.jxmpp.stringprep.XmppStringprepException
类名称:XmppStringprepException

XmppStringprepException介绍

[英]XMPP Stringprep exceptions signal an error when performing a particular Stringprep profile on a String.
[中]当对字符串执行特定的Stringprep配置文件时,XMPP Stringprep异常会发出错误信号。

代码示例

代码示例来源:origin: org.jxmpp/jxmpp-jid

protected static void assertNotLongerThan1023BytesOrEmpty(String string) throws XmppStringprepException {
  char[] bytes = string.toCharArray();
  // Better throw XmppStringprepException instead of IllegalArgumentException here, because users don't expect an
  // IAE and it also makes the error handling for users easier.
  if (bytes.length > 1023) {
    throw new XmppStringprepException(string, "Given string is longer then 1023 bytes");
  } else if (bytes.length == 0) {
    throw new XmppStringprepException(string, "Argument can't be the empty string");
  }
}

代码示例来源:origin: igniterealtime/Smack

/**
   * Test, if the equals() method works as intended.
   */
  @Test
  public void testEquals() {
    BareJid romeo, juliet, guyUnderTheBalcony;
    try {
      romeo = JidCreate.bareFrom("romeo@shakespeare.lit");
      guyUnderTheBalcony = JidCreate.bareFrom("romeo@shakespeare.lit/underTheBalcony");
      juliet = JidCreate.bareFrom("juliet@shakespeare.lit");
    } catch (XmppStringprepException e) {
      Assert.fail(e.getMessage());
      return;
    }

    OmemoDevice r = new OmemoDevice(romeo, 1);
    OmemoDevice g = new OmemoDevice(guyUnderTheBalcony, 1);
    OmemoDevice r2 = new OmemoDevice(romeo, 2);
    OmemoDevice j = new OmemoDevice(juliet, 3);
    OmemoDevice j2 = new OmemoDevice(juliet, 1);

    assertTrue(r.equals(g));
    assertFalse(r.equals(r2));
    assertFalse(j.equals(j2));
    assertFalse(j2.equals(r2));
  }
}

代码示例来源:origin: org.jxmpp/jxmpp-core

/**
 * Construct a new XMPP Stringprep exception with the given causing String and exception.
 *
 * @param causingString the String causing the exception.
 * @param exception the exception.
 */
public XmppStringprepException(String causingString, Exception exception) {
  super("XmppStringprepException caused by '" + causingString + "': " + exception);
  initCause(exception);
  this.causingString = causingString;
}

代码示例来源:origin: jitsi/jigasi

/**
 * Get the unique identifier for a ConferenceMember, which can be used
 * to see if it corresponds to the name of a ChatRoomMember
 *
 * @param member the ConferenceMember whose ID to retrieve
 * @return the ID of the conference member or null if address cannot be
 * parsed
 */
private String getConferenceMemberResourceID(ConferenceMember member)
{
  // assume address is in the form
  // <room_name>@conference.<jitsi_meet_domain>/<some_unique_id>
  try
  {
    Jid jid = JidCreate.from(member.getAddress());
    if(jid.hasResource())
    {
      return jid.getResourceOrThrow().toString();
    }
  }
  catch (XmppStringprepException e)
  {
    e.printStackTrace();
  }
  return null;
}

代码示例来源:origin: jitsi/jitsi-hammer

logger.error("Error creating to field for presence packet: " + e.toString());

代码示例来源:origin: jitsi/jicofo

e.printStackTrace();

代码示例来源:origin: jitsi/jitsi-hammer

logger.fatal("Error creating bosh config: " + e.toString());
System.exit(1);

代码示例来源:origin: org.jxmpp/jxmpp-core

/**
   * Throws a XMPP Stringprep exception if string is the empty string.
   *
   * @param string
   * @throws XmppStringprepException
   */
  private static void throwIfEmptyString(String string) throws XmppStringprepException {
    // TODO replace with string.isEmpty() once Smack's min Android SDK level is > 8
    if (string.length() == 0) {
      throw new XmppStringprepException(string, "Argument can't be the empty string");
    }
  }
}

代码示例来源:origin: org.jxmpp/jxmpp-stringprep-libidn

@Override
public String domainprep(String string) throws XmppStringprepException {
  try {
    // Don't allow unassigned because this is a "stored string". See
    // RFC3453 7, RFC3490 4 1) and RFC6122 2.2
    return Stringprep.nameprep(string);
  } catch (StringprepException e) {
    throw new XmppStringprepException(string, e);
  }
}

代码示例来源:origin: org.jxmpp/jxmpp-stringprep-libidn

@Override
public String localprep(String string) throws XmppStringprepException {
  try {
    // Allow unassigned codepoints as of RFC6122 A.2
    return Stringprep.nodeprep(string, true);
  } catch (StringprepException e) {
    throw new XmppStringprepException(string, e);
  }
}

代码示例来源:origin: org.jxmpp/jxmpp-stringprep-icu4j

@Override
  public String resourceprep(String string) throws XmppStringprepException {
    try {
      return RESOURCEPREP.prepare(string, StringPrep.DEFAULT);
    } catch (StringPrepParseException e) {
      throw new XmppStringprepException(string, e);
    }
  }
}

代码示例来源:origin: org.jxmpp/jxmpp-core

@Override
public String localprep(String string) throws XmppStringprepException {
  string = simpleStringprep(string);
  for (char charFromString : string.toCharArray()) {
    for (char forbiddenChar : LOCALPART_FURTHER_EXCLUDED_CHARACTERS) {
      if (charFromString == forbiddenChar) {
        throw new XmppStringprepException(string, "Localpart must not contain '" + forbiddenChar + "'");
      }
    }
  }
  return string;
}

代码示例来源:origin: org.jxmpp/jxmpp-stringprep-libidn

@Override
  public String resourceprep(String string) throws XmppStringprepException {
    try {
      // Allow unassigned codepoints as of RFC6122 B.2
      return Stringprep.resourceprep(string, true);
    } catch (StringprepException e) {
      throw new XmppStringprepException(string, e);
    }
  }
}

代码示例来源:origin: org.jxmpp/jxmpp-stringprep-icu4j

@Override
public String localprep(String string) throws XmppStringprepException {
  try {
    return NODEPREP.prepare(string, StringPrep.DEFAULT);
  } catch (StringPrepParseException e) {
    throw new XmppStringprepException(string, e);
  }
}

代码示例来源:origin: org.jxmpp/jxmpp-stringprep-icu4j

@Override
public String domainprep(String string) throws XmppStringprepException {
  try {
    return DOMAINPREP.prepare(string, StringPrep.DEFAULT);
  } catch (StringPrepParseException e) {
    throw new XmppStringprepException(string, e);
  }
}

代码示例来源:origin: org.jxmpp/jxmpp-jid

/**
 * Get a {@link EntityFullJid} constructed from the given parts.
 *
 * @param localpart a localpart.
 * @param domainpart a domainpart.
 * @param resource a resourcepart.
 * @return a full JID.
 * @throws XmppStringprepException if an error occurs.
 */
public static EntityFullJid entityFullFrom(String localpart, String domainpart, String resource) throws XmppStringprepException {
  EntityFullJid fullJid;
  try {
    fullJid = new LocalDomainAndResourcepartJid(localpart, domainpart, resource);
  } catch (XmppStringprepException e) {
    throw new XmppStringprepException(localpart + '@' + domainpart + '/' + resource, e);
  }
  return fullJid;
}

代码示例来源:origin: org.jxmpp/jxmpp-jid

/**
 * Get a {@link FullJid} constructed from the given parts.
 *
 * @param localpart a optional localpart.
 * @param domainpart a domainpart.
 * @param resource a resourcepart.
 * @return a full JID.
 * @throws XmppStringprepException if an error occurs.
 */
public static FullJid fullFrom(String localpart, String domainpart, String resource) throws XmppStringprepException {
  FullJid fullJid;
  try {
    if (localpart == null || localpart.length() == 0) {
      fullJid = new DomainAndResourcepartJid(domainpart, resource);
    } else {
      fullJid = new LocalDomainAndResourcepartJid(localpart, domainpart, resource);
    }
  } catch (XmppStringprepException e) {
    throw new XmppStringprepException(localpart + '@' + domainpart + '/' + resource, e);
  }
  return fullJid;
}

代码示例来源:origin: org.jxmpp/jxmpp-jid

/**
   * Get the {@link Domainpart} representing the input String.
   *
   * @param domain the input String.
   * @return the domainpart.
   * @throws XmppStringprepException if an error occurs.
   */
  public static Domainpart from(String domain) throws XmppStringprepException {
    if (domain == null) {
      throw new XmppStringprepException(domain, "Input 'domain' must not be null");
    }
    // TODO cache
    // RFC 6122 § 2.2 "If the domainpart includes a final character considered to be a label
    // separator (dot) by [IDNA2003] or [DNS], this character MUST be stripped …"
    if (domain.length() > 0 && domain.charAt(domain.length() - 1) == '.') {
      domain = domain.substring(0, domain.length() - 1);
    }
    domain = XmppStringPrepUtil.domainprep(domain);
    // First prep the String, then assure the limits of the *result*
    assertNotLongerThan1023BytesOrEmpty(domain);
    return new Domainpart(domain);
  }
}

代码示例来源:origin: jitsi/jicofo

/**
   * Constructs the jid for the room by taking the last '@' part as domain
   * and everything before it as the node part. Doing validation on the node
   * part for allowed chars.
   *
   * @param unescapedValue the unescaped jid as received in the iq
   * @return a bare JID constructed from the given parts.
   * @throws XmppStringprepException if an error occurs.
   */
  private EntityBareJid getRoomJid(String unescapedValue)
    throws XmppStringprepException
  {
    // the node part of the jid may contain '@' which is not allowed
    // and passing the correct node value to Localpart.from will check
    // for all not allowed jid characters
    int ix = unescapedValue.lastIndexOf("@");

    if (ix == -1)
      throw new XmppStringprepException(unescapedValue,
        "wrong room name jid format");

    String domainPart = unescapedValue.substring(ix + 1);
    String localPart = unescapedValue.substring(0, ix);

    return JidCreate.entityBareFrom(
      Localpart.from(localPart), Domainpart.from(domainPart));
  }
}

代码示例来源:origin: org.jxmpp/jxmpp-jid

throw new XmppStringprepException("Does not contain a localpart", jidString);
  throw new XmppStringprepException(jidString, e);
  domainpart = Domainpart.from(domainpartString);
} catch (XmppStringprepException e) {
  throw new XmppStringprepException(jidString, e);
    resourcepart = Resourcepart.from(resourceString);
  } catch (XmppStringprepException e) {
    throw new XmppStringprepException(jidString, e);

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com