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


Java Messages类代码示例

本文整理汇总了Java中org.apache.harmony.security.internal.nls.Messages的典型用法代码示例。如果您正苦于以下问题:Java Messages类的具体用法?Java Messages怎么用?Java Messages使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Messages类属于org.apache.harmony.security.internal.nls包,在下文中一共展示了Messages类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: read

import org.apache.harmony.security.internal.nls.Messages; //导入依赖的package包/类
/**
 * Reads the next encoded byte from the encoded input stream.
 *
 * @return the next encoded byte
 * @throws IOException - if error occured
 */
protected int read() throws IOException {

    if (offset == buffer.length) {
        throw new ASN1Exception(Messages.getString("security.13B")); //$NON-NLS-1$
    }

    if (in == null) {
        return buffer[offset++] & 0xFF;
    } else {
        int octet = in.read();
        if (octet == -1) {
            throw new ASN1Exception(Messages.getString("security.13B")); //$NON-NLS-1$
        }
        
        buffer[offset++] = (byte) octet;
        
        return octet;
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:26,代码来源:BerInputStream.java

示例2: checkURI

import org.apache.harmony.security.internal.nls.Messages; //导入依赖的package包/类
/**
 * Checks the correctness of the string representation of URI name.
 * The correctness is checked as pointed out in RFC 3280 p. 34.
 */
public static void checkURI(String uri) throws IOException {
    try {
        URI ur = new URI(uri);
        if ((ur.getScheme() == null) 
                || (ur.getRawSchemeSpecificPart().length() == 0)) {
            throw new IOException(Messages.getString("security.187", uri)); //$NON-NLS-1$
        }
        if (!ur.isAbsolute()) {
            throw new IOException(Messages.getString("security.188", uri)); //$NON-NLS-1$
        }
    } catch (URISyntaxException e) {
        throw (IOException) new IOException(
                Messages.getString("security.189", uri)).initCause(e);//$NON-NLS-1$
                
    }
}
 
开发者ID:nextopio,项目名称:nextop-client,代码行数:21,代码来源:GeneralName.java

示例3: getInstance

import org.apache.harmony.security.internal.nls.Messages; //导入依赖的package包/类
/**
 * Returns a new instance of {@code AlgorithmParameterGenerator} from the
 * specified provider for the specified algorithm.
 * 
 * @param algorithm
 *            the name of the algorithm to use.
 * @param provider
 *            the provider of the {@code AlgorithmParameterGenerator}.
 * @return a new instance of {@code AlgorithmParameterGenerator} for the
 *         specified algorithm.
 * @throws NoSuchAlgorithmException
 *             if the specified algorithm is not available.
 * @throws NullPointerException
 *             if {@code algorithm} is {@code null}.
 */
public static AlgorithmParameterGenerator getInstance(String algorithm,
        Provider provider) throws NoSuchAlgorithmException {
    if (provider == null) {
        throw new IllegalArgumentException(Messages.getString("security.04")); //$NON-NLS-1$
    }
    if (algorithm == null) {
        throw new NullPointerException(Messages.getString("security.01")); //$NON-NLS-1$
    }
    synchronized (engine) {
        engine.getInstance(algorithm, provider, null);
        return new AlgorithmParameterGenerator(
                (AlgorithmParameterGeneratorSpi) engine.spi, provider,
                algorithm);
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:31,代码来源:AlgorithmParameterGenerator.java

示例4: getInstance

import org.apache.harmony.security.internal.nls.Messages; //导入依赖的package包/类
/**
 * Returns a new instance of {@code KeyPairGenerator} that utilizes the
 * specified algorithm.
 * 
 * @param algorithm
 *            the name of the algorithm to use
 * @return a new instance of {@code KeyPairGenerator} that utilizes the
 *         specified algorithm
 * @throws NoSuchAlgorithmException if the specified algorithm is not available
 * @throws NullPointerException
 *             if {@code algorithm} is {@code null}
 */
public static KeyPairGenerator getInstance(String algorithm)
        throws NoSuchAlgorithmException {
    if (algorithm == null) {
        throw new NullPointerException(Messages.getString("security.01")); //$NON-NLS-1$
    }
    KeyPairGenerator result;
    synchronized (engine) {
        engine.getInstance(algorithm, null);
        if (engine.spi instanceof KeyPairGenerator) {
            result = (KeyPairGenerator) engine.spi;
            result.algorithm = algorithm;
            result.provider = engine.provider;
            return result;
        }
        result = new KeyPairGeneratorImpl((KeyPairGeneratorSpi) engine.spi,
                engine.provider, algorithm);
        return result;
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:32,代码来源:KeyPairGenerator.java

示例5: getEncoded

import org.apache.harmony.security.internal.nls.Messages; //导入依赖的package包/类
/**
 * @see CertPath#getEncoded(String)
 * method documentation for more info
 */
public byte[] getEncoded(String encoding)
    throws CertificateEncodingException {
    if (!encodings.contains(encoding)) {
        throw new CertificateEncodingException(
                Messages.getString("security.15F", encoding)); //$NON-NLS-1$
    }
    if (encodingsArr[0].equals(encoding)) {
        // PkiPath encoded form
        return getEncoded();
    } else {
        // PKCS7 encoded form
        if (pkcs7Encoding == null) {
            pkcs7Encoding = PKCS7_SIGNED_DATA_OBJECT.encode(this);
        }
        byte[] result = new byte[pkcs7Encoding.length];
        System.arraycopy(pkcs7Encoding, 0, result, 0,
                                    pkcs7Encoding.length);
        return result;
    }
}
 
开发者ID:nextopio,项目名称:nextop-client,代码行数:25,代码来源:X509CertPathImpl.java

示例6: DRLCertFactory

import org.apache.harmony.security.internal.nls.Messages; //导入依赖的package包/类
/**
 * Constructs the instance of the certificate factory provider.
 */
public DRLCertFactory() {
    // specification of the provider name, version, and description.
    // security.151=Certificate Factory supports CRLs and Certificates in (PEM) ASN.1 DER encoded form, and Certification Paths in PkiPath and PKCS7 formats.
    super("DRLCertFactory", 1.0, Messages.getString("security.151")); //$NON-NLS-1$ //$NON-NLS-2$
            
    AccessController.doPrivileged(new java.security.PrivilegedAction<Void>() {
        public Void run() {
            // register the service
            put("CertificateFactory.X509", //$NON-NLS-1$
                "org.apache.harmony.security.provider.cert.X509CertFactoryImpl"); //$NON-NLS-1$
            // mapping the alias
            put("Alg.Alias.CertificateFactory.X.509", "X509"); //$NON-NLS-1$ //$NON-NLS-2$
                return null;
        }
    });
}
 
开发者ID:nextopio,项目名称:nextop-client,代码行数:20,代码来源:DRLCertFactory.java

示例7: getInstance

import org.apache.harmony.security.internal.nls.Messages; //导入依赖的package包/类
/**
 * Returns a new instance of {@code MessageDigest} that utilizes the
 * specified algorithm.
 * 
 * @param algorithm
 *            the name of the algorithm to use
 * @return a new instance of {@code MessageDigest} that utilizes the
 *         specified algorithm
 * @throws NoSuchAlgorithmException
 *             if the specified algorithm is not available
 * @throws NullPointerException
 *             if {@code algorithm} is {@code null}
 */
public static MessageDigest getInstance(String algorithm)
        throws NoSuchAlgorithmException {
    if (algorithm == null) {
        throw new NullPointerException(Messages.getString("security.01")); //$NON-NLS-1$
    }
    MessageDigest result;
    synchronized (engine) {
        engine.getInstance(algorithm, null);
        if (engine.spi instanceof MessageDigest) {
            result = (MessageDigest) engine.spi;
            result.algorithm = algorithm;
            result.provider = engine.provider;
            return result;
        }
        return new MessageDigestImpl((MessageDigestSpi) engine.spi,
                engine.provider, algorithm);
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:32,代码来源:MessageDigest.java

示例8: engineGenerateSeed

import org.apache.harmony.security.internal.nls.Messages; //导入依赖的package包/类
/**
 * Returns a required number of random bytes. <BR>
 *
 * The method overrides "engineGenerateSeed (int)" in class SecureRandomSpi. <BR>
 *
 * @param
 *       numBytes - number of bytes to return; should be >= 0.
 * @return
 *       byte array containing bits in order from left to right
 * @throws
 *       InvalidParameterException - if numBytes < 0
 */
protected byte[] engineGenerateSeed(int numBytes) {

    byte[] myBytes; // byte[] for bytes returned by "nextBytes()"

    if (numBytes < 0) {
        throw new NegativeArraySizeException(Messages.getString("security.171", numBytes)); //$NON-NLS-1$
    }
    if (numBytes == 0) {
        return new byte[0];
    }

    if (myRandom == null) {
        myRandom = new SHA1PRNG_SecureRandomImpl();
        myRandom.engineSetSeed(RandomBitsSupplier
                .getRandomBits(DIGEST_LENGTH));
    }

    myBytes = new byte[numBytes];
    myRandom.engineNextBytes(myBytes);

    return myBytes;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:35,代码来源:SHA1PRNG_SecureRandomImpl.java

示例9: writeObject

import org.apache.harmony.security.internal.nls.Messages; //导入依赖的package包/类
/**
 * Outputs {@code type},{@code name},{@code actions}
 * fields via default mechanism; next manually writes certificates in the
 * following format: <br>
 *
 * <ol>
 * <li> int : number of certs or zero </li>
 * <li> each cert in the following format
 *     <ol>
 *     <li> String : certificate type </li>
 *     <li> int : length in bytes of certificate </li>
 *     <li> byte[] : certificate encoding </li>
 *     </ol>
 * </li>
 * </ol>
 *
 *  @see  <a href="http://java.sun.com/j2se/1.5.0/docs/api/serialized-form.html#java.security.UnresolvedPermission">Java Spec</a>
 */
private void writeObject(ObjectOutputStream out) throws IOException {
    out.defaultWriteObject();
    if (targetCerts == null) {
        out.writeInt(0);
    } else {
        out.writeInt(targetCerts.length);
        for (int i = 0; i < targetCerts.length; i++) {
            try {
                byte[] enc = targetCerts[i].getEncoded();
                out.writeUTF(targetCerts[i].getType());
                out.writeInt(enc.length);
                out.write(enc);
            } catch (CertificateEncodingException cee) {
                throw ((IOException)new NotSerializableException(
                    Messages.getString("security.30",  //$NON-NLS-1$
                    targetCerts[i])).initCause(cee));
            }
        }
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:39,代码来源:UnresolvedPermission.java

示例10: expand

import org.apache.harmony.security.internal.nls.Messages; //导入依赖的package包/类
/**
 * Substitutes all entries like ${some.key}, found in specified string, 
 * for specified values.
 * If some key is unknown, throws ExpansionFailedException. 
 * @param str the string to be expanded
 * @param properties available key-value mappings 
 * @return expanded string
 * @throws ExpansionFailedException
 */
public static String expand(String str, Properties properties)
        throws ExpansionFailedException {
    final String START_MARK = "${"; //$NON-NLS-1$
    final String END_MARK = "}"; //$NON-NLS-1$
    final int START_OFFSET = START_MARK.length();
    final int END_OFFSET = END_MARK.length();

    StringBuilder result = new StringBuilder(str);
    int start = result.indexOf(START_MARK);
    while (start >= 0) {
        int end = result.indexOf(END_MARK, start);
        if (end >= 0) {
            String key = result.substring(start + START_OFFSET, end);
            String value = properties.getProperty(key);
            if (value != null) {
                result.replace(start, end + END_OFFSET, value);
                start += value.length();
            } else {
                throw new ExpansionFailedException(Messages.getString("security.14F", key)); //$NON-NLS-1$
            }
        }
        start = result.indexOf(START_MARK, start);
    }
    return result.toString();
}
 
开发者ID:shannah,项目名称:cn1,代码行数:35,代码来源:PolicyUtils.java

示例11: addCertificate

import org.apache.harmony.security.internal.nls.Messages; //导入依赖的package包/类
/**
 * Adds a {@code Certificate} to this {@code Identity}.
 * <p>
 * If a {@code SecurityManager} is installed, code calling this method needs
 * the {@code SecurityPermission} {@code addIdentityCertificate} to be
 * granted, otherwise a {@code SecurityException} will be thrown.
 *
 * @param certificate
 *            the {@code Certificate} to be added to this {@code Identity}.
 * @throws KeyManagementException
 *             if the certificate is not valid.
 * @throws SecurityException
 *             if a {@code SecurityManager} is installed and the caller does
 *             not have permission to invoke this method.
 */
public void addCertificate(Certificate certificate)
        throws KeyManagementException {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        sm.checkSecurityAccess("addIdentityCertificate"); //$NON-NLS-1$
    }
    PublicKey certPK = certificate.getPublicKey();
    if (publicKey != null) {
        if (!checkKeysEqual(publicKey, certPK)) {
            throw new KeyManagementException(Messages.getString("security.13")); //$NON-NLS-1$
        }
    } else {
        publicKey = certPK;
    }
    if (certificates == null) {
        certificates = new Vector<Certificate>();
    }
    certificates.add(certificate);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:35,代码来源:Identity.java

示例12: decode

import org.apache.harmony.security.internal.nls.Messages; //导入依赖的package包/类
/**
 * TODO
 */
public Object decode(BerInputStream in) throws IOException {
    if (!checkTag(in.tag)) {
        // FIXME need look for tagging type
        throw new ASN1Exception(Messages.getString("security.100", //$NON-NLS-1$
                new Object[] { in.tagOffset, Integer.toHexString(id),
                        Integer.toHexString(in.tag) }));
    }

    // substitute indentifier for further decoding
    if (id == in.tag) {
        in.tag = type.id;
    } else {
        in.tag = type.constrId;
    }
    in.content = type.decode(in);

    if (in.isVerify) {
        return null;
    }
    return getDecodedObject(in);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:25,代码来源:ASN1Implicit.java

示例13: getPrincipalByAlias

import org.apache.harmony.security.internal.nls.Messages; //导入依赖的package包/类
/**
 * Returns a subject's X500Principal of an X509Certificate, 
 * which is associated with the specified keystore alias. 
 * @param ks KeyStore for resolving Certificate, may be <code>null</code>
 * @param alias alias to a certificate
 * @return X500Principal with a subject distinguished name
 * @throws KeyStoreException if KeyStore is <code>null</code> 
 * or if it failed to provide a certificate
 * @throws CertificateException if found certificate is not 
 * an X509Certificate 
 */
protected Principal getPrincipalByAlias(KeyStore ks, String alias)
        throws KeyStoreException, CertificateException {

    if (ks == null) {
        throw new KeyStoreException(
                Messages.getString("security.147", alias)); //$NON-NLS-1$
    }
    //XXX cache found certs ??
    Certificate x509 = ks.getCertificate(alias);
    if (x509 instanceof X509Certificate) {
        return ((X509Certificate) x509).getSubjectX500Principal();
    } else {
        throw new CertificateException(Messages.getString("security.148", //$NON-NLS-1$
                alias, x509));
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:28,代码来源:DefaultPolicyParser.java

示例14: decode

import org.apache.harmony.security.internal.nls.Messages; //导入依赖的package包/类
public Object decode(BerInputStream in) throws IOException {

        int index = Arrays.binarySearch(identifiers[0], in.tag);
        if (index < 0) {
            throw new ASN1Exception(Messages.getString("security.110", //$NON-NLS-1$
                    getClass().getName()));// FIXME message
        }

        index = identifiers[1][index];

        in.content = type[index].decode(in);

        // set index for getDecodedObject method
        in.choiceIndex = index;

        if (in.isVerify) {
            return null;
        }
        return getDecodedObject(in);
    }
 
开发者ID:nextopio,项目名称:nextop-client,代码行数:21,代码来源:ASN1Choice.java

示例15: getDecodedObject

import org.apache.harmony.security.internal.nls.Messages; //导入依赖的package包/类
protected Object getDecodedObject(BerInputStream in) {
    Object[] values = (Object[]) in.content;
    
    int [] accuracy = new int [3];
    for (int i = 0; i < 3; i++) {
        if (values[i] != null) {
            accuracy[i] = ASN1Integer.toIntValue(values[i]);
            if (i > 0 && (accuracy[i] < 0 || accuracy[i] > 999)) {
                throw new RuntimeException(
                // Msg: "Time-stamp accuracy value is incorrect: {}"
                        Messages.getString("security.1A3", accuracy[i]));
            }
        }
    }
    return accuracy;
}
 
开发者ID:nextopio,项目名称:nextop-client,代码行数:17,代码来源:TSTInfo.java


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