Example usage for org.bouncycastle.cms Recipient Recipient

List of usage examples for org.bouncycastle.cms Recipient Recipient

Introduction

In this page you can find the example usage for org.bouncycastle.cms Recipient Recipient.

Prototype

Recipient

Source Link

Usage

From source file:org.apache.tika.parser.microsoft.OutlookExtractor.java

License:Apache License

private List<Recipient> buildRecipients() {
    RecipientChunks[] recipientChunks = msg.getRecipientDetailsChunks();
    if (recipientChunks == null) {
        return Collections.EMPTY_LIST;
    }/*from  w ww .  ja va  2 s .c  o  m*/
    List<Recipient> recipients = new LinkedList<>();

    for (RecipientChunks chunks : recipientChunks) {
        Recipient r = new Recipient();
        r.displayName = (chunks.recipientDisplayNameChunk != null) ? chunks.recipientDisplayNameChunk.toString()
                : null;
        r.name = (chunks.recipientNameChunk != null) ? chunks.recipientNameChunk.toString() : null;
        r.emailAddress = chunks.getRecipientEmailAddress();
        List<PropertyValue> vals = chunks.getProperties().get(MAPIProperty.RECIPIENT_TYPE);

        RECIPIENT_TYPE recipientType = RECIPIENT_TYPE.UNSPECIFIED;
        if (vals != null && vals.size() > 0) {
            Object val = vals.get(0).getValue();
            if (val instanceof Integer) {
                recipientType = RECIPIENT_TYPE.getTypeFromVal((int) val);
            }
        }
        r.recipientType = recipientType;

        vals = chunks.getProperties().get(MAPIProperty.ADDRTYPE);
        if (vals != null && vals.size() > 0) {
            String val = vals.get(0).toString();
            if (val != null) {
                val = val.toLowerCase(Locale.US);
                //need to find example of this for testing
                if (val.equals("ex")) {
                    r.addressType = ADDRESS_TYPE.EX;
                } else if (val.equals("smtp")) {
                    r.addressType = ADDRESS_TYPE.SMTP;
                }
            }
        }
        recipients.add(r);
    }
    return recipients;
}