After much research time and some headaches... I've found a solution: You can obtain the Organization Wide Default Settings of a Custom Object by using the Metadata API (http://www.salesforce.com/us/developer/docs/api_meta/). It is a Soap Web Service which is provided by Salesforce and you can use it to get many of the configurations that you have set up for your organization.
The WSDL is provided in the API section of your setup panel in the Salesforce Portal. But it is not that trivial as compiling the WSDL... You will find some errors related to "anyType" types contained in the WSDL. This can be solved by replacing these "anyType" tokens by "string". Then, after a correct compilation of the WSDL to Apex, you will try to execute some requests which certainly won't work. You would receive some error like "callout response field not found in your ReadResult class: fullName". You can try to manually solve this issue.... but in my opinion it was a waste of time. There's much effort to exert just to make it work. It is better to know that someone has been working on this: https://github.com/financialforcedev/apex-mdapi/blob/master/apex-mdapi/src/classes/MetadataService.cls .
It is very easy, just copy the code of the MetadataService.cls and insert it in a new Apex class of your Force.com organization. Then, you can just perform in your Execute Anonymous something like:
MetadataService.MetadataPort metadataWS = new MetadataService.MetadataPort();
metadataWs.SessionHeader = new MetadataService.SessionHeader_element();
metadataWs.SessionHeader.sessionId = UserInfo.getSessionId();
MetadataService.ReadCustomObjectResult rs = (MetadataService.ReadCustomObjectResult) metadataWS.readMetadata('CustomObject', new String[] {'MyCustomObject__c', 'MyOtherCustomObject__c'});
for (MetadataService.Metadata md : rs.getRecords()) {
if (md != null) {
MetadataService.CustomObject obj = (MetadataService.CustomObject) md;
System.debug('Custom object full name: ' + obj.fullName);
System.debug('Label: ' + obj.label);
System.debug('Sharing model: ' + obj.sharingmodel);
} else {
System.debug('Empty metadata.');
}
}
I hope this may help other people wondering about this same topic as it has been a complex topic for me.