From 6078c68f969342c111d0b1facc6abe9357601b95 Mon Sep 17 00:00:00 2001 From: Amanda Anganes Date: Fri, 9 Dec 2011 16:09:41 -0500 Subject: [PATCH] Starting to flesh out some of the model and endpoints. I've added several "empty.txt" files in order to push the complete directory layout to Git - it won't push empty directories. --- .classpath | 28 +- .project | 102 ++++---- .../mitre/openid/connect/model/IdToken.java | 111 +++++++- .../mitre/openid/connect/model/UserInfo.java | 240 +++++++++++++++++- .../openid/connect/web/CheckIDEndpoint.java | 13 + .../openid/connect/web/UserInfoEndpoint.java | 35 ++- .../spring/appServlet/servlet-context.xml | 11 + 7 files changed, 449 insertions(+), 91 deletions(-) diff --git a/.classpath b/.classpath index a7834f3b7..500722f0e 100644 --- a/.classpath +++ b/.classpath @@ -1,14 +1,14 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/.project b/.project index 811ddddc8..57efee624 100644 --- a/.project +++ b/.project @@ -1,51 +1,51 @@ - - - OpenIDConnect - - - Servers - - - - org.eclipse.wst.jsdt.core.javascriptValidator - - - - - org.eclipse.ajdt.core.ajbuilder - - - - - org.eclipse.wst.common.project.facet.core.builder - - - - - org.eclipse.wst.validation.validationbuilder - - - - - org.springframework.ide.eclipse.core.springbuilder - - - - - org.maven.ide.eclipse.maven2Builder - - - - - - org.eclipse.ajdt.ui.ajnature - org.eclipse.jem.workbench.JavaEMFNature - org.eclipse.jdt.core.javanature - org.eclipse.wst.common.project.facet.core.nature - org.eclipse.wst.common.modulecore.ModuleCoreNature - org.eclipse.wst.jsdt.core.jsNature - org.springframework.ide.eclipse.core.springnature - com.springsource.sts.roo.core.nature - org.maven.ide.eclipse.maven2Nature - - + + + OpenIDConnect + + + Servers + + + + org.eclipse.wst.jsdt.core.javascriptValidator + + + + + org.eclipse.ajdt.core.ajbuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.springframework.ide.eclipse.core.springbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.ajdt.ui.ajnature + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.jdt.core.javanature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.wst.jsdt.core.jsNature + org.springframework.ide.eclipse.core.springnature + com.springsource.sts.roo.core.nature + org.eclipse.m2e.core.maven2Nature + + diff --git a/src/main/java/org/mitre/openid/connect/model/IdToken.java b/src/main/java/org/mitre/openid/connect/model/IdToken.java index 8766ac628..734f6bd9e 100644 --- a/src/main/java/org/mitre/openid/connect/model/IdToken.java +++ b/src/main/java/org/mitre/openid/connect/model/IdToken.java @@ -1,8 +1,103 @@ -package org.mitre.openid.connect.model; - -import javax.persistence.Entity; - -@Entity -public class IdToken { - -} +package org.mitre.openid.connect.model; + +import javax.persistence.Entity; + +/* + * TODO: This class needs to be encoded as a JWT + */ +@Entity +public class IdToken { + + private String iss; + private String user_id; + private String aud; + private String exp; + private String iso29115; + private String nonce; + private String auth_time; + /** + * @return the iss + */ + public String getIss() { + return iss; + } + /** + * @param iss the iss to set + */ + public void setIss(String iss) { + this.iss = iss; + } + /** + * @return the user_id + */ + public String getUser_id() { + return user_id; + } + /** + * @param user_id the user_id to set + */ + public void setUser_id(String user_id) { + this.user_id = user_id; + } + /** + * @return the aud + */ + public String getAud() { + return aud; + } + /** + * @param aud the aud to set + */ + public void setAud(String aud) { + this.aud = aud; + } + /** + * @return the exp + */ + public String getExp() { + return exp; + } + /** + * @param exp the exp to set + */ + public void setExp(String exp) { + this.exp = exp; + } + /** + * @return the iso29115 + */ + public String getIso29115() { + return iso29115; + } + /** + * @param iso29115 the iso29115 to set + */ + public void setIso29115(String iso29115) { + this.iso29115 = iso29115; + } + /** + * @return the nonce + */ + public String getNonce() { + return nonce; + } + /** + * @param nonce the nonce to set + */ + public void setNonce(String nonce) { + this.nonce = nonce; + } + /** + * @return the auth_time + */ + public String getAuth_time() { + return auth_time; + } + /** + * @param auth_time the auth_time to set + */ + public void setAuth_time(String auth_time) { + this.auth_time = auth_time; + } + +} diff --git a/src/main/java/org/mitre/openid/connect/model/UserInfo.java b/src/main/java/org/mitre/openid/connect/model/UserInfo.java index bd2959425..e230d4758 100644 --- a/src/main/java/org/mitre/openid/connect/model/UserInfo.java +++ b/src/main/java/org/mitre/openid/connect/model/UserInfo.java @@ -1,8 +1,232 @@ -package org.mitre.openid.connect.model; - -import javax.persistence.Entity; - -@Entity -public class UserInfo { - -} +package org.mitre.openid.connect.model; + +import javax.persistence.Entity; + +@Entity +public class UserInfo { + + private String user_id; + private String name; + private String given_name; + private String family_name; + private String middle_name; + private String nickname; + private String profile; + private String picture; + private String website; + private String email; + private Boolean verified; + private String gender; + private String zoneinfo; + private String locale; + private String phone_number; + private Address address; + private String updated_time; + + + /** + * @return the user_id + */ + public String getUser_id() { + return user_id; + } + /** + * @param user_id the user_id to set + */ + public void setUser_id(String user_id) { + this.user_id = user_id; + } + /** + * @return the name + */ + public String getName() { + return name; + } + /** + * @param name the name to set + */ + public void setName(String name) { + this.name = name; + } + /** + * @return the given_name + */ + public String getGiven_name() { + return given_name; + } + /** + * @param given_name the given_name to set + */ + public void setGiven_name(String given_name) { + this.given_name = given_name; + } + /** + * @return the family_name + */ + public String getFamily_name() { + return family_name; + } + /** + * @param family_name the family_name to set + */ + public void setFamily_name(String family_name) { + this.family_name = family_name; + } + /** + * @return the middle_name + */ + public String getMiddle_name() { + return middle_name; + } + /** + * @param middle_name the middle_name to set + */ + public void setMiddle_name(String middle_name) { + this.middle_name = middle_name; + } + /** + * @return the nickname + */ + public String getNickname() { + return nickname; + } + /** + * @param nickname the nickname to set + */ + public void setNickname(String nickname) { + this.nickname = nickname; + } + /** + * @return the profile + */ + public String getProfile() { + return profile; + } + /** + * @param profile the profile to set + */ + public void setProfile(String profile) { + this.profile = profile; + } + /** + * @return the picture + */ + public String getPicture() { + return picture; + } + /** + * @param picture the picture to set + */ + public void setPicture(String picture) { + this.picture = picture; + } + /** + * @return the website + */ + public String getWebsite() { + return website; + } + /** + * @param website the website to set + */ + public void setWebsite(String website) { + this.website = website; + } + /** + * @return the email + */ + public String getEmail() { + return email; + } + /** + * @param email the email to set + */ + public void setEmail(String email) { + this.email = email; + } + /** + * @return the verified + */ + public Boolean getVerified() { + return verified; + } + /** + * @param verified the verified to set + */ + public void setVerified(Boolean verified) { + this.verified = verified; + } + /** + * @return the gender + */ + public String getGender() { + return gender; + } + /** + * @param gender the gender to set + */ + public void setGender(String gender) { + this.gender = gender; + } + /** + * @return the zoneinfo + */ + public String getZoneinfo() { + return zoneinfo; + } + /** + * @param zoneinfo the zoneinfo to set + */ + public void setZoneinfo(String zoneinfo) { + this.zoneinfo = zoneinfo; + } + /** + * @return the locale + */ + public String getLocale() { + return locale; + } + /** + * @param locale the locale to set + */ + public void setLocale(String locale) { + this.locale = locale; + } + /** + * @return the phone_number + */ + public String getPhone_number() { + return phone_number; + } + /** + * @param phone_number the phone_number to set + */ + public void setPhone_number(String phone_number) { + this.phone_number = phone_number; + } + /** + * @return the address + */ + public Address getAddress() { + return address; + } + /** + * @param address the address to set + */ + public void setAddress(Address address) { + this.address = address; + } + /** + * @return the updated_time + */ + public String getUpdated_time() { + return updated_time; + } + /** + * @param updated_time the updated_time to set + */ + public void setUpdated_time(String updated_time) { + this.updated_time = updated_time; + } + +} diff --git a/src/main/java/org/mitre/openid/connect/web/CheckIDEndpoint.java b/src/main/java/org/mitre/openid/connect/web/CheckIDEndpoint.java index 26268691e..935509d85 100644 --- a/src/main/java/org/mitre/openid/connect/web/CheckIDEndpoint.java +++ b/src/main/java/org/mitre/openid/connect/web/CheckIDEndpoint.java @@ -1,10 +1,23 @@ package org.mitre.openid.connect.web; +import org.mitre.openid.connect.model.IdToken; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.servlet.ModelAndView; @Controller @RequestMapping("/checkid") public class CheckIDEndpoint { + @RequestMapping("/") + public ModelAndView checkID(@RequestParam("id_token") String idToken, ModelAndView mav) { + + IdToken token = new IdToken(); + + //TODO: Set claims + + return new ModelAndView("jsonIdTokenView", "checkId", token); + } + } diff --git a/src/main/java/org/mitre/openid/connect/web/UserInfoEndpoint.java b/src/main/java/org/mitre/openid/connect/web/UserInfoEndpoint.java index 2f4d6e494..43d76f0d1 100644 --- a/src/main/java/org/mitre/openid/connect/web/UserInfoEndpoint.java +++ b/src/main/java/org/mitre/openid/connect/web/UserInfoEndpoint.java @@ -1,10 +1,25 @@ -package org.mitre.openid.connect.web; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; - -@Controller -@RequestMapping("/userinfo") -public class UserInfoEndpoint { - -} +package org.mitre.openid.connect.web; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.servlet.ModelAndView; + +@Controller +@RequestMapping("/userinfo") +public class UserInfoEndpoint { + + @RequestMapping("/") + public ModelAndView getInfo(@RequestParam("access_token") String accessToken, @RequestParam("schema") String schema, ModelAndView mav) { + + UserInfo userInfo = new UserInfo(); + + //populate with info + + //If returning JSON + return new ModelAndView("jsonUserInfoView", "userInfo", userInfo); + + //TODO: If returning JWT? + } + +} diff --git a/src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml b/src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml index 5f0c9d531..78a3800b9 100644 --- a/src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml +++ b/src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml @@ -19,10 +19,21 @@ + + + + + + + + + + +