Adding whole or coursely crushed coffee beans to the fermenter/keg. I like to take around 4 oz, coursely crushed, and throw them into the fermenter for 2-5 days, depending on how much coffee flavor and aroma I want to impart. After the given time frame, I pull and carb. If bottling, you can slide some pantyhose or something on the end of the cane and rack off the beans into a bottling bucket and bottle away.
As for infection, I always sanitize my sack that I use (mostly panty hose), but not the beans. Ive done several coffee infused beers this way and have yet to have an infection. As a matter of fact, Im enjoying an Chocolate Coffee Milk Stout as I type this. Used whole beans for this one, and let them ride for 3 days. Coffee aroma is there but not overly dominant. Flavor is upfront, but still lets the chocolate and malt come through.