Commit 2ff3a4e8 authored by michael.simon's avatar michael.simon
Browse files

create entity classes for oidc flow handling

parent 767a833e
/*******************************************************************************
* Copyright (c) 2014 Michael Simon.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* Michael Simon - initial
******************************************************************************/
package edu.kit.scc.webreg.dao.jpa.oidc;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Named;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import edu.kit.scc.webreg.dao.jpa.JpaBaseDao;
import edu.kit.scc.webreg.dao.oidc.OidcFlowStateDao;
import edu.kit.scc.webreg.entity.oidc.OidcFlowStateEntity;
import edu.kit.scc.webreg.entity.oidc.OidcFlowStateEntity_;
@Named
@ApplicationScoped
public class JpaOidcFlowStateDao extends JpaBaseDao<OidcFlowStateEntity, Long> implements OidcFlowStateDao {
@Override
public OidcFlowStateEntity findByCode(String code) {
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<OidcFlowStateEntity> criteria = builder.createQuery(OidcFlowStateEntity.class);
Root<OidcFlowStateEntity> root = criteria.from(OidcFlowStateEntity.class);
criteria.where(builder.equal(root.get(OidcFlowStateEntity_.code), code));
criteria.select(root);
return em.createQuery(criteria).getSingleResult();
}
@Override
public OidcFlowStateEntity findByAccessToken(String accessToken, String accessTokenType) {
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<OidcFlowStateEntity> criteria = builder.createQuery(OidcFlowStateEntity.class);
Root<OidcFlowStateEntity> root = criteria.from(OidcFlowStateEntity.class);
criteria.where(builder.and(
builder.equal(root.get(OidcFlowStateEntity_.accessToken), accessToken),
builder.equal(root.get(OidcFlowStateEntity_.accessTokenType), accessTokenType)
));
criteria.select(root);
return em.createQuery(criteria).getSingleResult();
}
@Override
public Class<OidcFlowStateEntity> getEntityClass() {
return OidcFlowStateEntity.class;
}
}
/*******************************************************************************
* Copyright (c) 2014 Michael Simon.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* Michael Simon - initial
******************************************************************************/
package edu.kit.scc.webreg.dao.oidc;
import edu.kit.scc.webreg.dao.BaseDao;
import edu.kit.scc.webreg.entity.oidc.OidcFlowStateEntity;
public interface OidcFlowStateDao extends BaseDao<OidcFlowStateEntity, Long> {
OidcFlowStateEntity findByCode(String code);
OidcFlowStateEntity findByAccessToken(String accessToken, String accessTokenType);
}
package edu.kit.scc.webreg.entity.oidc;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import edu.kit.scc.webreg.entity.AbstractBaseEntity;
@Entity(name = "OidcFlowStateEntity")
@Table(name = "oidc_flow_state")
public class OidcFlowStateEntity extends AbstractBaseEntity {
private static final long serialVersionUID = 1L;
@Column(name = "nonce", length = 256)
private String nonce;
@Column(name = "state", length = 256)
private String state;
@Column(name = "code", length = 256)
private String code;
@Column(name = "response_type", length = 256)
private String responseType;
@Column(name = "client_id", length = 256)
private String clientId;
@Column(name = "redirect_uri", length = 1024)
private String redirectUri;
@Column(name = "access_token", length = 256)
private String accessToken;
@Column(name = "access_token_type", length = 32)
private String accessTokenType;
@Column(name = "valid_until")
private Date validUntil;
public Date getValidUntil() {
return validUntil;
}
public void setValidUntil(Date validUntil) {
this.validUntil = validUntil;
}
public String getNonce() {
return nonce;
}
public void setNonce(String nonce) {
this.nonce = nonce;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getResponseType() {
return responseType;
}
public void setResponseType(String responseType) {
this.responseType = responseType;
}
public String getClientId() {
return clientId;
}
public void setClientId(String clientId) {
this.clientId = clientId;
}
public String getRedirectUri() {
return redirectUri;
}
public void setRedirectUri(String redirectUri) {
this.redirectUri = redirectUri;
}
public String getAccessToken() {
return accessToken;
}
public void setAccessToken(String accessToken) {
this.accessToken = accessToken;
}
public String getAccessTokenType() {
return accessTokenType;
}
public void setAccessTokenType(String accessTokenType) {
this.accessTokenType = accessTokenType;
}
}
package edu.kit.scc.webreg.entity.oidc;
import java.util.Date;
import javax.annotation.Generated;
import javax.persistence.metamodel.SingularAttribute;
import javax.persistence.metamodel.StaticMetamodel;
@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor")
@StaticMetamodel(OidcFlowStateEntity.class)
public abstract class OidcFlowStateEntity_ extends edu.kit.scc.webreg.entity.AbstractBaseEntity_ {
public static volatile SingularAttribute<OidcFlowStateEntity, String> nonce;
public static volatile SingularAttribute<OidcFlowStateEntity, String> state;
public static volatile SingularAttribute<OidcFlowStateEntity, String> code;
public static volatile SingularAttribute<OidcFlowStateEntity, String> accessToken;
public static volatile SingularAttribute<OidcFlowStateEntity, String> accessTokenType;
public static volatile SingularAttribute<OidcFlowStateEntity, Date> validUntil;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment