本文整理汇总了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;
}
}
示例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$
}
}
示例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);
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
});
}
示例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);
}
}
示例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;
}
示例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));
}
}
}
}
示例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();
}
示例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);
}
示例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);
}
示例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));
}
}
示例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);
}
示例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;
}