当前位置: 首页>>代码示例>>Java>>正文


Java IPAddress.isValid方法代码示例

本文整理汇总了Java中org.bouncycastle.util.IPAddress.isValid方法的典型用法代码示例。如果您正苦于以下问题:Java IPAddress.isValid方法的具体用法?Java IPAddress.isValid怎么用?Java IPAddress.isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bouncycastle.util.IPAddress的用法示例。


在下文中一共展示了IPAddress.isValid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testIP

import org.bouncycastle.util.IPAddress; //导入方法依赖的package包/类
private void testIP(String[] valid, String[] invalid)
{
    for (int i = 0; i < valid.length; i++)
    {
        if (!IPAddress.isValid(valid[i]))
        {
            fail("Valid input string not accepted: " + valid[i] + ".");
        }
    }
    for (int i = 0; i < invalid.length; i++)
    {
        if (IPAddress.isValid(invalid[i]))
        {
            fail("Invalid input string accepted: " + invalid[i] + ".");
        }
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:18,代码来源:IPTest.java

示例2: GeneralName

import org.bouncycastle.util.IPAddress; //导入方法依赖的package包/类
/**
 * Create a GeneralName for the given tag from the passed in String.
 * <p>
 * This constructor can handle:
 * <ul>
 * <li>rfc822Name
 * <li>iPAddress
 * <li>directoryName
 * <li>dNSName
 * <li>uniformResourceIdentifier
 * <li>registeredID
 * </ul>
 * For x400Address, otherName and ediPartyName there is no common string
 * format defined.
 * <p>
 * Note: A directory name can be encoded in different ways into a byte
 * representation. Be aware of this if the byte representation is used for
 * comparing results.
 *
 * @param tag tag number
 * @param name string representation of name
 * @throws IllegalArgumentException if the string encoding is not correct or     *             not supported.
 */
public GeneralName(
    int       tag,
    String    name)
{
    this.tag = tag;

    if (tag == rfc822Name || tag == dNSName || tag == uniformResourceIdentifier)
    {
        this.obj = new DERIA5String(name);
    }
    else if (tag == registeredID)
    {
        this.obj = new DERObjectIdentifier(name);
    }
    else if (tag == directoryName)
    {
        this.obj = new X509Name(name);
    }
    else if (tag == iPAddress)
    {
        if (IPAddress.isValid(name))
        {
            this.obj = new DEROctetString(Strings.toUTF8ByteArray(name));
        }
        else
        {
            throw new IllegalArgumentException("IP Address is invalid");
        }
    }
    else
    {
        throw new IllegalArgumentException("can't process String for tag: " + tag);
    }
}
 
开发者ID:thangbn,项目名称:Direct-File-Downloader,代码行数:58,代码来源:GeneralName.java


注:本文中的org.bouncycastle.util.IPAddress.isValid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。