String id = responseAttributes.get("id");
String accountName = id + "@google.com";
Account found = OAuthRealm._.getAccount(accountName);
if (found == null) {
Map<SchemaType, String> metadata = new HashMap<SchemaType, String>();
addMetadata(responseAttributes, metadata, GoogleSchemaType.ID, "id");
addMetadata(responseAttributes, metadata, AXSchemaType.FIRSTNAME, "given_name");
addMetadata(responseAttributes, metadata, AXSchemaType.LASTNAME, "family_name");
addMetadata(responseAttributes, metadata, AXSchemaType.FULLNAME, "name");
addMetadata(responseAttributes, metadata, AXSchemaType.TIMEZONE, "timezone");
addMetadata(responseAttributes, metadata, GoogleSchemaType.PICTURE, "picture");
addMetadata(responseAttributes, metadata, GoogleSchemaType.LOCALE, "locale");
addMetadata(responseAttributes, metadata, GoogleSchemaType.LINK, "link");
addMetadata(responseAttributes, metadata, GoogleSchemaType.GENDER, "gender");
found = OAuthRealm._.createAccountInDatabase(accountName, metadata);
}
Account principal = new SubjectAccreditedImpl((AbstractAccount) found, accessToken);
HttpSession session = request.getSession(true);
Subject subject = new Subject();