Browse Source

added code challenge method to client model (properly this time)

pull/1108/head
Justin Richer 8 years ago
parent
commit
5dcda2812e
  1. 4
      openid-connect-common/src/main/java/org/mitre/oauth2/model/ClientDetailsEntity.java
  2. 53
      openid-connect-common/src/main/java/org/mitre/oauth2/model/convert/PKCEAlgorithmStringConverter.java
  3. 2
      openid-connect-server-webapp/src/main/resources/db/tables/hsql_database_tables.sql

4
openid-connect-common/src/main/java/org/mitre/oauth2/model/ClientDetailsEntity.java

@ -52,6 +52,7 @@ import org.mitre.oauth2.model.convert.JWEEncryptionMethodStringConverter;
import org.mitre.oauth2.model.convert.JWKSetStringConverter; import org.mitre.oauth2.model.convert.JWKSetStringConverter;
import org.mitre.oauth2.model.convert.JWSAlgorithmStringConverter; import org.mitre.oauth2.model.convert.JWSAlgorithmStringConverter;
import org.mitre.oauth2.model.convert.JWTStringConverter; import org.mitre.oauth2.model.convert.JWTStringConverter;
import org.mitre.oauth2.model.convert.PKCEAlgorithmStringConverter;
import org.mitre.oauth2.model.convert.SimpleGrantedAuthorityStringConverter; import org.mitre.oauth2.model.convert.SimpleGrantedAuthorityStringConverter;
import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.oauth2.provider.ClientDetails; import org.springframework.security.oauth2.provider.ClientDetails;
@ -1017,6 +1018,9 @@ public class ClientDetailsEntity implements ClientDetails {
/** /**
* @return the codeChallengeMethod * @return the codeChallengeMethod
*/ */
@Basic
@Column(name = "code_challenge_method")
@Convert(converter = PKCEAlgorithmStringConverter.class)
public PKCEAlgorithm getCodeChallengeMethod() { public PKCEAlgorithm getCodeChallengeMethod() {
return codeChallengeMethod; return codeChallengeMethod;
} }

53
openid-connect-common/src/main/java/org/mitre/oauth2/model/convert/PKCEAlgorithmStringConverter.java

@ -0,0 +1,53 @@
/*******************************************************************************
* Copyright 2016 The MITRE Corporation
* and the MIT 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.convert;
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
import org.mitre.oauth2.model.PKCEAlgorithm;
/**
* @author jricher
*
*/
@Converter
public class PKCEAlgorithmStringConverter implements AttributeConverter<PKCEAlgorithm, String> {
@Override
public String convertToDatabaseColumn(PKCEAlgorithm attribute) {
if (attribute != null) {
return attribute.getName();
} else {
return null;
}
}
/* (non-Javadoc)
* @see javax.persistence.AttributeConverter#convertToEntityAttribute(java.lang.Object)
*/
@Override
public PKCEAlgorithm convertToEntityAttribute(String dbData) {
if (dbData != null) {
return PKCEAlgorithm.parse(dbData);
} else {
return null;
}
}
}

2
openid-connect-server-webapp/src/main/resources/db/tables/hsql_database_tables.sql

@ -171,6 +171,8 @@ CREATE TABLE IF NOT EXISTS client_details (
software_statement VARCHAR(4096), software_statement VARCHAR(4096),
code_challenge_method VARCHAR(256),
UNIQUE (client_id) UNIQUE (client_id)
); );

Loading…
Cancel
Save