This is how OID can be extracted from a text description of a JCA service providing the desired algorithm. However, the solution is quite inelegant
DERObjectIdentifier oid = null;
String digestAlgorithmName = "SHA-224";
Provider provider = Security.getProvider(BouncyCastleProvider.PROVIDER_NAME);
Service service = provider.getService("MessageDigest", digestAlgorithmName);
if (service != null) {
String string = service.toString();
String array[] = string.split("\n");
if (array.length > 1) {
string = array[array.length - 1];
array = string.split("[\\[\\]]");
if (array.length > 2) {
string = array[array.length - 2];
array = string.split(", ");
Arrays.sort(array);
oid = new ASN1ObjectIdentifier(array[0]);
}
}
}