The Good Shepherd

A photograph and an audio recording on reel-to-reel tape are dropped off anonymously at the home of Edward Wilson (Matt Damon), a senior CIA officer, after the 1961 Bay of Pigs Invasion of Cuba fails due to an undisclosed leak.
In 1939 Edward is at Yale University and is invited to join Skull and Bones, a secret society. He is compelled to disclose a secret as part of his initiation: he reveals that as a young boy in 1925 he discovered the suicide note left by his father, Thomas (Timothy Hutton), although he says he never read it. After the ceremony, a fraternity brother tells him that Edward's father, an admiral, was to be chosen as Secretary of the Navy, until his loyalties were questioned. Afterwards Edward is recruited by an FBI agent, Sam Murach (Alec Baldwin), who claims that Edward's poetry professor, Dr. Fredericks (Michael Gambon), is a Nazi spy, asking Edward to expose his professor's background. Edward's actions result in Dr. Fredericks' forced resignation from the university.
Edward begins a relationship with a deaf student named Laura (Tammy Blanchard), but while on Deer Island, Edward meets his friend John Russel's (Gabriel Macht) family and is later aggressively seduced by his sister Margaret 'Clover' Russell (Angelina Jolie). General Bill Sullivan (Robert De Niro) asks Edward to join the OSS, offering him a post in London. Later while Edward and Laura are at the beach, Margaret's brother privately reveals that she is pregnant, so Edward marries her. At the wedding reception Edward accepts the London OSS office position, while his new wife remains in the United States. In London he meets Dr. Fredericks again, who is actually with British intelligence. An intelligence officer in the British SOE, Arch Cummings (Billy Crudup), tells Edward that Fredericks' indiscriminate homosexual relationships pose a security risk. Edward is asked to deal with his mentor, who refuses to protect himself by returning to teaching. Shortly afterwards, he is brutally killed and his body is dumped into the Thames, all while Edward watches.
In post-war Berlin, where both Allies and Soviets are recruiting German scientists. Edward encounters his Soviet counterpart, code named "Ulysses", for the first time. After learning from his son, Edward Jr., during a phone call home that his wife is having an affair, Edward has a one-night stand with interpreter Hanna Schiller (Martina Gedeck); the same night, he realizes she is a Soviet agent and she is killed. Edward returns home to his wife and son. His wife confesses her adultery, and Edward confesses his. General Sullivan approaches Edward again to help form a new foreign intelligence organization - the CIA - where he would work with his former colleague, Richard Hayes (Lee Pace), under Phillip Allen (William Hurt). Edward accepts, hiding the details of his position from everyone but his wife.
Edward's first assignment deals with coffee in Central America where the Russians are trying to gain influence. Edward spots Ulysses in the background of footage of the country's leader, but doesn't disclose this. Edward arranges for airplanes to fly over and release locusts during a public event where the Russians (including Ulysses) are present in order to intimidate the Central American leader. An American agent's severed finger is sent to Edward in a coffee can. At a Christmas party, Edward's son wets himself. At the same party, General Sullivan tells Edward that Phillip Allen was going to be on the Mayan Coffee Company's board of directors, prompting Edward to ask Sam Murach to look into Phillip's finances.
A Russian man requests asylum and claims to be high-ranking KGB agent Valentin Mironov. While attending the theater with Mironov and Cummings, Edward encounters his former sweetheart, Laura. They begin seeing each other again. Sometime later, Margaret receives photos of Laura and Edward getting into a taxi together and kissing. After she confronts him, Edward ends the relationship with Laura. Another Russian defector appears, claiming that he is the real Valentin Mironov, the other man being an impostor called Yuri Modin, a KGB operative working for Ulysses. Thinking he is lying, agents torture him, and administer liquid LSD believing it to be a potential truth serum. The second defector does not break, instead telling them how the Soviets' power is just a myth, before hurling himself through a window and down several stories. The first man claiming to be Valentin Mironov, who has watched the entire ordeal together with Edward, offers to take LSD to prove his innocence, but Edward does not take him up on his offer. Edward visits his son, who has, like his father, joined the Skull and Bones society at Yale, and been approached by the CIA, which he joins despite his mother's misgivings, widening the rift between his parents. Edward Jr. overhears his father and Hayes discussing the imminent Bay of Pigs invasion. His father warns him to be silent. Margaret leaves Edward.
Returning to the recording at the beginning of the story, detailed analysis points to Leopoldville, in the Congo. Having tracked down the room where the recording was made, Edward realizes that the source of the leak was his son speaking to his lover, revealed to be a Soviet agent by Ulysses when he appears and plays Edward an unedited version of the recording in an attempt to turn him. Edward confronts his son, who plans to marry the woman. Growing suspicious, Edward discovers evidence that Cummings and Mironov (really Yuri Modin) are double agents. Meeting Ulysses in the National Air and Space Museum, Edward finally refuses his offer, but argues that, having won in Cuba, there is nothing to be gained for the Soviets in hurting his son. On their wedding day, Edward Jr.'s fiancÃ©e is killed by being thrown out of the plane she was taking to the ceremony. When Edward Jr. asks if his father was responsible, he denies it.
Edward meets with Hayes at the new CIA headquarters still under construction. Allen is resigning under a cloud of financial improprieties, and the President has asked Hayes to be the new director. Hayes makes Edward the first head of counter-intelligence, an entire wing of new building. At home, Edward retrieves and reads his father's suicide note. In the letter, his father confesses to having betrayed his country. Edward burns the note. The final scene shows Edward leaving his old office for the new position.

Question: Who realizes that the source of the leak was his son speaking to his lover?
Answer: Edward