From b1c317a713f462604a191bb0066adaee622a28aa Mon Sep 17 00:00:00 2001 From: koboldeveloper Date: Tue, 2 Sep 2014 16:45:31 -0400 Subject: [PATCH] oauth2 models creation via factory --- .../model/AuthenticationHolderEntity.java | 40 +++++++ .../oauth2/model/OAuth2AccessTokenEntity.java | 109 +++++++++++++++++ .../model/OAuth2RefreshTokenEntity.java | 94 +++++++++++++++ .../org/mitre/oauth2/model/SystemScope.java | 113 ++++++++++++++++++ 4 files changed, 356 insertions(+) create mode 100644 openid-connect-common/src/main/java/org/mitre/oauth2/model/AuthenticationHolderEntity.java create mode 100644 openid-connect-common/src/main/java/org/mitre/oauth2/model/OAuth2AccessTokenEntity.java create mode 100644 openid-connect-common/src/main/java/org/mitre/oauth2/model/OAuth2RefreshTokenEntity.java create mode 100644 openid-connect-common/src/main/java/org/mitre/oauth2/model/SystemScope.java diff --git a/openid-connect-common/src/main/java/org/mitre/oauth2/model/AuthenticationHolderEntity.java b/openid-connect-common/src/main/java/org/mitre/oauth2/model/AuthenticationHolderEntity.java new file mode 100644 index 000000000..450ef1969 --- /dev/null +++ b/openid-connect-common/src/main/java/org/mitre/oauth2/model/AuthenticationHolderEntity.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright 2014 The MITRE Corporation + * and the MIT Kerberos and Internet Trust Consortium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ + +package org.mitre.oauth2.model; + +import org.springframework.security.oauth2.provider.OAuth2Authentication; + +/** + * @author jricher + * + */ +public interface AuthenticationHolderEntity { + + Long getId(); + + void setId(Long id); + + Long getOwnerId(); + + void setOwnerId(Long owner_id); + + OAuth2Authentication getAuthentication(); + + void setAuthentication(OAuth2Authentication authentication); + +} diff --git a/openid-connect-common/src/main/java/org/mitre/oauth2/model/OAuth2AccessTokenEntity.java b/openid-connect-common/src/main/java/org/mitre/oauth2/model/OAuth2AccessTokenEntity.java new file mode 100644 index 000000000..e96eb26b9 --- /dev/null +++ b/openid-connect-common/src/main/java/org/mitre/oauth2/model/OAuth2AccessTokenEntity.java @@ -0,0 +1,109 @@ +/******************************************************************************* + * Copyright 2014 The MITRE Corporation + * and the MIT Kerberos and Internet Trust Consortium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ + +package org.mitre.oauth2.model; + +import java.text.ParseException; +import java.util.Date; +import java.util.Set; + +import org.springframework.security.oauth2.common.OAuth2AccessToken; + +import com.nimbusds.jwt.JWT; + +/** + * @author jricher + * + */ +public interface OAuth2AccessTokenEntity extends OAuth2AccessToken { + + /** + * @return the id + */ + Long getId(); + + /** + * @param id the id to set + */ + void setId(Long id); + + /** + * The authentication in place when this token was created. + * @return the authentication + */ + AuthenticationHolderEntity getAuthenticationHolder(); + + /** + * @param authentication the authentication to set + */ + void setAuthenticationHolder(AuthenticationHolderEntity authenticationHolder); + + /** + * @return the client + */ + ClientDetailsEntity getClient(); + + /** + * @param client the client to set + */ + void setClient(ClientDetailsEntity client); + + /** + * Set the "value" of this Access Token + * + * @param value the JWT string + * @throws ParseException if "value" is not a properly formatted JWT string + */ + void setValue(String value) throws ParseException; + + void setExpiration(Date expiration); + + void setTokenType(String tokenType); + + void setRefreshToken(OAuth2RefreshTokenEntity refreshToken); + + @Override + OAuth2RefreshTokenEntity getRefreshToken(); + + void setScope(Set scope); + + /** + * @return the idToken + */ + OAuth2AccessTokenEntity getIdToken(); + + /** + * @param idToken the idToken to set + */ + void setIdToken(OAuth2AccessTokenEntity idToken); + + /** + * @return the idTokenString + */ + String getIdTokenString(); + + /** + * @return the jwtValue + */ + JWT getJwt(); + + /** + * @param jwtValue the jwtValue to set + */ + void setJwt(JWT jwt); + +} \ No newline at end of file diff --git a/openid-connect-common/src/main/java/org/mitre/oauth2/model/OAuth2RefreshTokenEntity.java b/openid-connect-common/src/main/java/org/mitre/oauth2/model/OAuth2RefreshTokenEntity.java new file mode 100644 index 000000000..1a5e9acc5 --- /dev/null +++ b/openid-connect-common/src/main/java/org/mitre/oauth2/model/OAuth2RefreshTokenEntity.java @@ -0,0 +1,94 @@ +/******************************************************************************* + * Copyright 2014 The MITRE Corporation + * and the MIT Kerberos and Internet Trust Consortium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ + +package org.mitre.oauth2.model; + +import java.text.ParseException; +import java.util.Date; + +import org.springframework.security.oauth2.common.OAuth2RefreshToken; + +import com.nimbusds.jwt.JWT; + +/** + * @author jricher + * + */ +public interface OAuth2RefreshTokenEntity extends OAuth2RefreshToken { + + /** + * @return the id + */ + Long getId(); + + /** + * @param id the id to set + */ + void setId(Long id); + + /** + * The authentication in place when the original access token was + * created + * + * @return the authentication + */ + AuthenticationHolderEntity getAuthenticationHolder(); + + /** + * @param authentication the authentication to set + */ + void setAuthenticationHolder(AuthenticationHolderEntity authenticationHolder); + + /** + * Set the value of this token as a string. Parses the string into a JWT. + * @param value + * @throws ParseException if the value is not a valid JWT string + */ + void setValue(String value) throws ParseException; + + Date getExpiration(); + + void setExpiration(Date expiration); + + /** + * Has this token expired? + * @return true if it has a timeout set and the timeout has passed + */ + boolean isExpired(); + + /** + * @return the client + */ + ClientDetailsEntity getClient(); + + /** + * @param client the client to set + */ + void setClient(ClientDetailsEntity client); + + /** + * Get the JWT object directly + * @return the jwt + */ + JWT getJwt(); + + /** + * @param jwt the jwt to set + */ + void setJwt(JWT jwt); + +} diff --git a/openid-connect-common/src/main/java/org/mitre/oauth2/model/SystemScope.java b/openid-connect-common/src/main/java/org/mitre/oauth2/model/SystemScope.java new file mode 100644 index 000000000..2b4574de9 --- /dev/null +++ b/openid-connect-common/src/main/java/org/mitre/oauth2/model/SystemScope.java @@ -0,0 +1,113 @@ +/******************************************************************************* + * Copyright 2014 The MITRE Corporation + * and the MIT Kerberos and Internet Trust Consortium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ + +package org.mitre.oauth2.model; + +/** + * @author jricher + * + */ +public interface SystemScope { + + /** + * @return the id + */ + Long getId(); + + /** + * @param id the id to set + */ + void setId(Long id); + + /** + * @return the value + */ + String getValue(); + + /** + * @param value the value to set + */ + void setValue(String value); + + /** + * @return the description + */ + String getDescription(); + + /** + * @param description the description to set + */ + void setDescription(String description); + + /** + * @return the icon + */ + String getIcon(); + + /** + * @param icon the icon to set + */ + void setIcon(String icon); + + /** + * @return the allowDynReg + */ + boolean isAllowDynReg(); + + /** + * @param allowDynReg the allowDynReg to set + */ + void setAllowDynReg(boolean allowDynReg); + + /** + * @return the defaultScope + */ + boolean isDefaultScope(); + + /** + * @param defaultScope the defaultScope to set + */ + void setDefaultScope(boolean defaultScope); + + /** + * @return the isStructured status + */ + boolean isStructured(); + + /** + * @param structured the structured to set + */ + void setStructured(boolean structured); + + String getStructuredParamDescription(); + + /** + * @param isStructured the isStructured to set + */ + void setStructuredParamDescription(String d); + + /** + * @return the structuredValue + */ + String getStructuredValue(); + + /** + * @param structuredValue the structuredValue to set + */ + void setStructuredValue(String structuredValue); + +}