本文整理汇总了Java中org.apache.harmony.security.internal.nls.Messages.getString方法的典型用法代码示例。如果您正苦于以下问题:Java Messages.getString方法的具体用法?Java Messages.getString怎么用?Java Messages.getString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.harmony.security.internal.nls.Messages
的用法示例。
在下文中一共展示了Messages.getString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRandomBits
import org.apache.harmony.security.internal.nls.Messages; //导入方法依赖的package包/类
/**
* The method returns byte array containing random bits.
*
* @param
* numBytes - length of bytes requested
* @return
* byte array
* @throws
* InvalidArgumentException - if numBytes <= 0 <BR>
* ProviderException - if some problem related to native library is discovered <BR>
*/
public static synchronized byte[] getRandomBits(int numBytes) {
if ( numBytes <= 0 ) {
throw new IllegalArgumentException(Messages.getString("security.195", numBytes)); //$NON-NLS-1$
}
if ( !serviceAvailable ) {
throw new ProviderException(
Messages.getString("security.197") ); //$NON-NLS-1$
}
byte[] myBytes = new byte[numBytes];
if ( !getWindowsRandom(myBytes, numBytes) ) {
// it is unexpected result
throw new ProviderException(
Messages.getString("security.198") ); //$NON-NLS-1$
}
return myBytes;
}
示例2: resolveSigners
import org.apache.harmony.security.internal.nls.Messages; //导入方法依赖的package包/类
/**
* Takes a comma-separated list of aliases and obtains corresponding
* certificates.
* @param ks KeyStore for resolving Certificates, may be <code>null</code>
* @param signers comma-separated list of certificate aliases,
* must be not <code>null</code>
* @return an array of signing Certificates
* @throws Exception if KeyStore is <code>null</code>
* or if it failed to provide a certificate
*/
protected Certificate[] resolveSigners(KeyStore ks, String signers)
throws Exception {
if (ks == null) {
throw new KeyStoreException(Messages.getString("security.146", //$NON-NLS-1$
signers));
}
Collection<Certificate> certs = new HashSet<Certificate>();
StringTokenizer snt = new StringTokenizer(signers, ","); //$NON-NLS-1$
while (snt.hasMoreTokens()) {
//XXX cache found certs ??
certs.add(ks.getCertificate(snt.nextToken().trim()));
}
return certs.toArray(new Certificate[certs.size()]);
}
示例3: engineGenerateCertPath
import org.apache.harmony.security.internal.nls.Messages; //导入方法依赖的package包/类
/**
* @see CertificateFactorySpi#engineGenerateCertPath(InputStream)
* method documentation for more info
*/
public CertPath engineGenerateCertPath(InputStream inStream)
throws CertificateException {
if (inStream == null) {
throw new CertificateException(
Messages.getString("security.153")); //$NON-NLS-1$
}
return engineGenerateCertPath(inStream, "PkiPath"); //$NON-NLS-1$
}
示例4: readEnumerated
import org.apache.harmony.security.internal.nls.Messages; //导入方法依赖的package包/类
/**
* Decodes ASN.1 Enumerated type
*
* @throws IOException - if error occured
*/
public void readEnumerated() throws IOException {
if (tag != ASN1Constants.TAG_ENUM) {
throw new ASN1Exception(
Messages.getString("security.119", tagOffset, //$NON-NLS-1$
Integer.toHexString(tag)));
}
//
// all checks are the same as for ASN.1 integer type
//
// check encoded length
if (length == 0) {
throw new ASN1Exception(Messages.getString("security.11A", tagOffset));//$NON-NLS-1$
}
readContent();
// check encoded content
if (length > 1) {
int bits = buffer[contentOffset] & 0xFF;
if (buffer[contentOffset + 1] < 0) {
bits += 0x100;
}
if (bits == 0 || bits == 0x1FF) {
throw new ASN1Exception(Messages.getString("security.11B", contentOffset)); //$NON-NLS-1$
}
}
}
示例5: readBoolean
import org.apache.harmony.security.internal.nls.Messages; //导入方法依赖的package包/类
/**
* Decodes ASN.1 boolean type
*
* @throws IOException - if error occured
*/
public void readBoolean() throws IOException {
if (tag != ASN1Constants.TAG_BOOLEAN) {
throw new ASN1Exception(Messages.getString("security.11C", //$NON-NLS-1$
tagOffset, Integer.toHexString(tag)));
}
// check encoded length
if (length != 1) {
throw new ASN1Exception(Messages.getString("security.11D", tagOffset));//$NON-NLS-1$
}
readContent();
}
示例6: getValues
import org.apache.harmony.security.internal.nls.Messages; //导入方法依赖的package包/类
protected void getValues(Object object, Object[] values) {
int [] accuracy = (int []) object;
for (int i = 0; i < 3; i++) {
if (i > 0 && (accuracy[i] < 0 || accuracy[i] > 999)) {
throw new RuntimeException(
// Msg: "Time-stamp accuracy value is incorrect: {0}"
Messages.getString("security.1A3", accuracy[i]));
}
values[i] = BigInteger.valueOf(accuracy[i]).toByteArray();
}
}
示例7: readContent
import org.apache.harmony.security.internal.nls.Messages; //导入方法依赖的package包/类
/**
* Reads the next encoded content from the encoded input stream.
* The method MUST be used for reading a primitive encoded content.
*
* @throws IOException - if error occured
*/
public void readContent() throws IOException {
if (offset + length > buffer.length) {
throw new ASN1Exception(Messages.getString("security.13B")); //$NON-NLS-1$
}
if (in == null) {
offset += length;
} else {
int bytesRead = in.read(buffer, offset, length);
if (bytesRead != length) {
// if input stream didn't return all data at once
// try to read it in several blocks
int c = bytesRead;
do {
if (c < 1 || bytesRead > length) {
throw new ASN1Exception(Messages
.getString("security.13C")); //$NON-NLS-1$
}
c = in.read(buffer, offset + bytesRead, length - bytesRead);
bytesRead += c;
} while (bytesRead != length);
}
offset += length;
}
}
示例8: removeIdentity
import org.apache.harmony.security.internal.nls.Messages; //导入方法依赖的package包/类
/**
* @see IdentityScope#removeIdentity(Identity)
*/
public synchronized void removeIdentity(Identity identity)
throws KeyManagementException {
//Exception caught = null;
if (identity == null) {
throw new NullPointerException(Messages.getString("security.92")); //$NON-NLS-1$
}
String name = identity.getName();
if (name == null) {
throw new NullPointerException(Messages.getString("security.95")); //$NON-NLS-1$
}
boolean contains = names.containsKey(name);
names.remove(name);
PublicKey key = identity.getPublicKey();
if (key != null) {
contains = contains || keys.containsKey(key);
keys.remove(key);
}
if (!contains) {
throw new KeyManagementException(Messages.getString("security.96")); //$NON-NLS-1$
}
}
示例9: CRLDistributionPoints
import org.apache.harmony.security.internal.nls.Messages; //导入方法依赖的package包/类
public CRLDistributionPoints(List distributionPoints) {
if ((distributionPoints == null)
|| (distributionPoints.size() == 0)) {
throw new IllegalArgumentException(Messages.getString("security.17D")); //$NON-NLS-1$
}
this.distributionPoints = distributionPoints;
}
示例10: readGeneralizedTime
import org.apache.harmony.security.internal.nls.Messages; //导入方法依赖的package包/类
/**
* @see org.apache.harmony.security.asn1.BerInputStream#readGeneralizedTime()
*/
public void readGeneralizedTime() throws IOException {
if (tag == ASN1Constants.TAG_C_GENERALIZEDTIME) {
// It is a string type and it can be encoded as primitive or constructed.
throw new ASN1Exception(Messages.getString("security.10D", tagOffset)); //$NON-NLS-1$
}
super.readGeneralizedTime();
// FIXME makes sense only if we support all GeneralizedTime formats
// late check syntax: the last char MUST be Z
//if (buffer[offset - 1] != 'Z') {
// throw new ASN1Exception(
// "ASN.1 GeneralizedTime wrongly encoded at ["
// + contentOffset + ']');
//}
// the fractional-seconds elements, if present MUST
// omit all trailing zeros
// FIXME implement me
// if () {
// throw new IOException(
// "DER ASN.1 GeneralizedTime wrongly encoded at ["
// + contentOffset
// + "]. Trailing zeros MUST be omitted");
// }
}
示例11: getByte
import org.apache.harmony.security.internal.nls.Messages; //导入方法依赖的package包/类
protected int getByte(int position) throws IOException {
if ((position + 1) >= length) {
// to avoid ArrayIndexOutOfBoundsException
throw new IOException(
Messages.getString("security.192")); //$NON-NLS-1$
}
int b1, b2;
b1 = chars[position];
if (b1 >= '0' && b1 <= '9') {
b1 = b1 - '0';
} else if (b1 >= 'a' && b1 <= 'f') {
b1 = b1 - 87; // 87 = 'a' - 10
} else if (b1 >= 'A' && b1 <= 'F') {
b1 = b1 - 55; // 55 = 'A' - 10
} else {
throw new IOException(
Messages.getString("security.192")); //$NON-NLS-1$
}
b2 = chars[position + 1];
if (b2 >= '0' && b2 <= '9') {
b2 = b2 - '0';
} else if (b2 >= 'a' && b2 <= 'f') {
b2 = b2 - 87; // 87 = 'a' - 10
} else if (b2 >= 'A' && b2 <= 'F') {
b2 = b2 - 55; // 55 = 'A' - 10
} else {
throw new IOException(
Messages.getString("security.192")); //$NON-NLS-1$
}
return (b1 << 4) + b2;
}
示例12: initVerify
import org.apache.harmony.security.internal.nls.Messages; //导入方法依赖的package包/类
/**
* Initializes this {@code Signature} instance for signature verification,
* using the certificate of the identity whose signature is going to be
* verified.
* <p>
* If the given certificate is an instance of {@link X509Certificate} and
* has a key usage parameter that indicates, that this certificate is not to
* be used for signing, an {@code InvalidKeyException} is thrown.
*
* @param certificate
* the certificate used to verify a signature.
* @throws InvalidKeyException
* if the publicKey in the certificate is not valid or not to be
* used for signing.
*/
public final void initVerify(Certificate certificate)
throws InvalidKeyException {
if (certificate instanceof X509Certificate) {
Set ce = ((X509Certificate) certificate).getCriticalExtensionOIDs();
boolean critical = false;
if (ce != null && !ce.isEmpty()) {
for (Iterator i = ce.iterator(); i.hasNext();) {
if ("2.5.29.15".equals(i.next())) { //$NON-NLS-1$
//KeyUsage OID = 2.5.29.15
critical = true;
break;
}
}
if (critical) {
boolean[] keyUsage = ((X509Certificate) certificate)
.getKeyUsage();
// As specified in RFC 3280 -
// Internet X.509 Public Key Infrastructure
// Certificate and Certificate Revocation List (CRL) Profile.
// (http://www.ietf.org/rfc/rfc3280.txt)
//
// KeyUsage ::= BIT STRING { digitalSignature (0), <skipped> }
if ((keyUsage != null) && (!keyUsage[0])) { // digitalSignature
throw new InvalidKeyException(
Messages.getString("security.26")); //$NON-NLS-1$
}
}
}
}
engineInitVerify(certificate.getPublicKey());
state = VERIFY;
}
示例13: readSequenceOf
import org.apache.harmony.security.internal.nls.Messages; //导入方法依赖的package包/类
/**
* Decodes ASN.1 SequenceOf type
*
* @param sequenceOf - ASN.1 sequence to be decoded
* @throws IOException - if error occured
*/
public void readSequenceOf(ASN1SequenceOf sequenceOf) throws IOException {
if (tag != ASN1Constants.TAG_C_SEQUENCEOF) {
throw new ASN1Exception(Messages.getString("security.135", tagOffset, //$NON-NLS-1$
Integer.toHexString(tag)));
}
decodeValueCollection(sequenceOf);
}
示例14: putContext
import org.apache.harmony.security.internal.nls.Messages; //导入方法依赖的package包/类
/**
* This method to be invoked in the Thread's constructor. The first argument
* (thread) must be Thread's this and the second must be a snapshot of the
* current AccessControlContext:
* <p>
* <code>
* Thread() {<br>
* SecurityUtils.putContext(this,AccessController.getContext());<br>
* ...do the stuff you need...<br>
* }<br>
* </code>
*
* The method throws SecurityException if the method is called more than
* once for a given thread. The first call to <code>putContext</code> is
* always performed in the Thread's constructor so this effectively means
* that no one can replace the snapshot taken.
*
* @throws SecurityException if a context for the passed
* <code>thread</code> already exists in the map.
* @throws NullPointerException if thread is null
* @throws Error if context is null AND if null context is already stored
* in the map
*/
public static void putContext(Thread thread, AccessControlContext context)
throws SecurityException {
if (thread == null) {
throw new NullPointerException(Messages.getString("security.140")); //$NON-NLS-1$
}
synchronized (ACC_CACHE) {
if (ACC_CACHE.containsKey(thread)) {
throw new SecurityException(Messages.getString("security.141")); //$NON-NLS-1$
}
if (context == null) {
// this only allowed once - for the very first thread.
if (ACC_CACHE.containsValue(null)) {
throw new Error(Messages.getString("security.142")); //$NON-NLS-1$
}
}
ACC_CACHE.put(thread, context);
}
}
示例15: nextAT
import org.apache.harmony.security.internal.nls.Messages; //导入方法依赖的package包/类
protected String nextAT() throws IOException {
hasQE = false; // reset
// skip preceding space chars, they can present after
// comma or semicolon (compatibility with RFC 1779)
for (; pos < length && chars[pos] == ' '; pos++) {
}
if (pos == length) {
return null; // reached the end of DN
}
// mark the beginning of attribute type
beg = pos;
// attribute type chars
pos++;
for (; pos < length && chars[pos] != '=' && chars[pos] != ' '; pos++) {
// we don't follow exact BNF syntax here:
// accept any char except space and '='
}
if (pos >= length) {
// unexpected end of DN
throw new IOException(
Messages.getString("security.192")); //$NON-NLS-1$
}
// mark the end of attribute type
end = pos;
// skip trailing space chars between attribute type and '='
// (compatibility with RFC 1779)
if (chars[pos] == ' ') {
for (; pos < length && chars[pos] != '=' && chars[pos] == ' '; pos++) {
}
if (chars[pos] != '=' || pos == length) {
// unexpected end of DN
throw new IOException(
Messages.getString("security.192")); //$NON-NLS-1$
}
}
pos++; //skip '=' char
// skip space chars between '=' and attribute value
// (compatibility with RFC 1779)
for (; pos < length && chars[pos] == ' '; pos++) {
}
// in case of oid attribute type skip its prefix: "oid." or "OID."
// (compatibility with RFC 1779)
if ((end - beg > 4) && (chars[beg + 3] == '.')
&& (chars[beg] == 'O' || chars[beg] == 'o')
&& (chars[beg + 1] == 'I' || chars[beg + 1] == 'i')
&& (chars[beg + 2] == 'D' || chars[beg + 2] == 'd')) {
beg += 4;
}
return new String(chars, beg, end - beg);
}