use of sun.security.util.ObjectIdentifier in project Payara by payara.
the class GSSUtils method getOID.
/*
* Return the OID corresponding to an OID represented in DER format as follows: 0x06 -- Tag for
* OBJECT IDENTIFIER derOID.length -- length in octets of OID DER value of OID -- written as
* specified byte the DER representation for an ObjectIdentifier.
*/
public static ObjectIdentifier getOID(byte[] derOID) throws IOException {
DerInputStream dis = new DerInputStream(derOID);
ObjectIdentifier oid = dis.getOID();
/*
* Note: getOID() method call generates an IOException if derOID contains any malformed data
*/
return oid;
}
use of sun.security.util.ObjectIdentifier in project Payara by payara.
the class GSSUtils method verifyMechOID.
/* verify if exportedName is of object ObjectIdentifier. */
public static boolean verifyMechOID(ObjectIdentifier oid, byte[] externalName) throws IOException {
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "Attempting to verify mechanism independent name");
_logger.log(Level.FINE, dumpHex(externalName));
}
IOException e = new IOException("Invalid Name");
if (externalName[0] != 0x04)
throw e;
if (externalName[1] != 0x01)
throw e;
int mechoidlen = ((externalName[2]) << 8) + (externalName[3] & 0xff);
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "Mech OID length = " + mechoidlen);
}
if (externalName.length < (4 + mechoidlen + 4))
throw e;
/*
* get the mechanism OID and verify it is the same as oid passed as an argument.
*/
byte[] deroid = new byte[mechoidlen];
System.arraycopy(externalName, 4, deroid, 0, mechoidlen);
ObjectIdentifier oid1 = getOID(deroid);
if (!oid1.equals(oid))
return false;
else
return true;
}
use of sun.security.util.ObjectIdentifier in project Bytecoder by mirkosertic.
the class CertificateRevokedException method readObject.
/**
* Deserialize the {@code CertificateRevokedException} instance.
*/
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
// Read in the non-transient fields
// (revocationDate, reason, authority)
ois.defaultReadObject();
// Defensively copy the revocation date
revocationDate = new Date(revocationDate.getTime());
// Read in the size (number of mappings) of the extensions map
// and create the extensions map
int size = ois.readInt();
if (size == 0) {
extensions = Collections.emptyMap();
} else {
extensions = new HashMap<>(size);
}
// Read in the extensions and put the mappings in the extensions map
for (int i = 0; i < size; i++) {
String oid = (String) ois.readObject();
boolean critical = ois.readBoolean();
int length = ois.readInt();
byte[] extVal = new byte[length];
ois.readFully(extVal);
Extension ext = sun.security.x509.Extension.newExtension(new ObjectIdentifier(oid), critical, extVal);
extensions.put(oid, ext);
}
}
use of sun.security.util.ObjectIdentifier in project Bytecoder by mirkosertic.
the class Pair method doPrintCertReq.
private void doPrintCertReq(InputStream in, PrintStream out) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
StringBuffer sb = new StringBuffer();
boolean started = false;
while (true) {
String s = reader.readLine();
if (s == null)
break;
if (!started) {
if (s.startsWith("-----")) {
started = true;
}
} else {
if (s.startsWith("-----")) {
break;
}
sb.append(s);
}
}
PKCS10 req = new PKCS10(Pem.decode(new String(sb)));
PublicKey pkey = req.getSubjectPublicKeyInfo();
out.printf(rb.getString("PKCS.10.with.weak"), req.getSubjectName(), pkey.getFormat(), withWeak(pkey), withWeak(req.getSigAlg()));
for (PKCS10Attribute attr : req.getAttributes().getAttributes()) {
ObjectIdentifier oid = attr.getAttributeId();
if (oid.equals(PKCS9Attribute.EXTENSION_REQUEST_OID)) {
CertificateExtensions exts = (CertificateExtensions) attr.getAttributeValue();
if (exts != null) {
printExtensions(rb.getString("Extension.Request."), exts, out);
}
} else {
out.println("Attribute: " + attr.getAttributeId());
PKCS9Attribute pkcs9Attr = new PKCS9Attribute(attr.getAttributeId(), attr.getAttributeValue());
out.print(pkcs9Attr.getName() + ": ");
Object attrVal = attr.getAttributeValue();
out.println(attrVal instanceof String[] ? Arrays.toString((String[]) attrVal) : attrVal);
}
}
if (debug) {
// Just to see more, say, public key length...
out.println(req);
}
checkWeak(rb.getString("the.certificate.request"), req);
}
use of sun.security.util.ObjectIdentifier in project Bytecoder by mirkosertic.
the class TSRequest method encode.
public byte[] encode() throws IOException {
DerOutputStream request = new DerOutputStream();
// encode version
request.putInteger(version);
// encode messageImprint
DerOutputStream messageImprint = new DerOutputStream();
hashAlgorithmId.encode(messageImprint);
messageImprint.putOctetString(hashValue);
request.write(DerValue.tag_Sequence, messageImprint);
if (policyId != null) {
request.putOID(new ObjectIdentifier(policyId));
}
if (nonce != null) {
request.putInteger(nonce);
}
if (returnCertificate) {
request.putBoolean(true);
}
DerOutputStream out = new DerOutputStream();
out.write(DerValue.tag_Sequence, request);
return out.toByteArray();
}
Aggregations