Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Decompiled with CFR 0_110.
- *
- * Could not load the following classes:
- * com.fasterxml.jackson.databind.annotation.JsonDeserialize
- * com.fasterxml.jackson.databind.annotation.JsonSerialize
- * com.google.common.collect.Sets
- * com.nimbusds.jwt.JWT
- * javax.persistence.Basic
- * javax.persistence.CascadeType
- * javax.persistence.CollectionTable
- * javax.persistence.Column
- * javax.persistence.Convert
- * javax.persistence.ElementCollection
- * javax.persistence.Entity
- * javax.persistence.FetchType
- * javax.persistence.GeneratedValue
- * javax.persistence.GenerationType
- * javax.persistence.Id
- * javax.persistence.JoinColumn
- * javax.persistence.JoinTable
- * javax.persistence.ManyToOne
- * javax.persistence.NamedQueries
- * javax.persistence.NamedQuery
- * javax.persistence.OneToMany
- * javax.persistence.OneToOne
- * javax.persistence.Table
- * javax.persistence.Temporal
- * javax.persistence.TemporalType
- * javax.persistence.Transient
- * org.codehaus.jackson.map.annotate.JsonDeserialize
- * org.codehaus.jackson.map.annotate.JsonSerialize
- * org.mitre.oauth2.model.AuthenticationHolderEntity
- * org.mitre.oauth2.model.ClientDetailsEntity
- * org.mitre.oauth2.model.OAuth2RefreshTokenEntity
- * org.mitre.oauth2.model.convert.JWTStringConverter
- * org.mitre.uma.model.Permission
- * org.smartplatforms.oauth2.LaunchContextEntity
- * org.springframework.security.oauth2.common.OAuth2AccessToken
- * org.springframework.security.oauth2.common.OAuth2AccessTokenJackson1Deserializer
- * org.springframework.security.oauth2.common.OAuth2AccessTokenJackson1Serializer
- * org.springframework.security.oauth2.common.OAuth2AccessTokenJackson2Deserializer
- * org.springframework.security.oauth2.common.OAuth2AccessTokenJackson2Serializer
- * org.springframework.security.oauth2.common.OAuth2RefreshToken
- */
- package org.mitre.oauth2.model;
- import com.google.common.collect.Sets;
- import com.nimbusds.jwt.JWT;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.Map;
- import java.util.Set;
- import javax.persistence.Basic;
- import javax.persistence.CascadeType;
- import javax.persistence.CollectionTable;
- import javax.persistence.Column;
- import javax.persistence.Convert;
- import javax.persistence.ElementCollection;
- import javax.persistence.Entity;
- import javax.persistence.FetchType;
- import javax.persistence.GeneratedValue;
- import javax.persistence.GenerationType;
- import javax.persistence.Id;
- import javax.persistence.JoinColumn;
- import javax.persistence.JoinTable;
- import javax.persistence.ManyToOne;
- import javax.persistence.NamedQueries;
- import javax.persistence.NamedQuery;
- import javax.persistence.OneToMany;
- import javax.persistence.OneToOne;
- import javax.persistence.Table;
- import javax.persistence.Temporal;
- import javax.persistence.TemporalType;
- import javax.persistence.Transient;
- import org.codehaus.jackson.map.annotate.JsonDeserialize;
- import org.codehaus.jackson.map.annotate.JsonSerialize;
- import org.mitre.oauth2.model.AuthenticationHolderEntity;
- import org.mitre.oauth2.model.ClientDetailsEntity;
- import org.mitre.oauth2.model.OAuth2RefreshTokenEntity;
- import org.mitre.oauth2.model.convert.JWTStringConverter;
- import org.mitre.uma.model.Permission;
- import org.smartplatforms.oauth2.LaunchContextEntity;
- import org.springframework.security.oauth2.common.OAuth2AccessToken;
- import org.springframework.security.oauth2.common.OAuth2AccessTokenJackson1Deserializer;
- import org.springframework.security.oauth2.common.OAuth2AccessTokenJackson1Serializer;
- import org.springframework.security.oauth2.common.OAuth2AccessTokenJackson2Deserializer;
- import org.springframework.security.oauth2.common.OAuth2AccessTokenJackson2Serializer;
- import org.springframework.security.oauth2.common.OAuth2RefreshToken;
- @Entity
- @Table(name="access_token")
- @NamedQueries(value={@NamedQuery(name="OAuth2AccessTokenEntity.getAll", query="select a from OAuth2AccessTokenEntity a"), @NamedQuery(name="OAuth2AccessTokenEntity.getAllExpiredByDate", query="select a from OAuth2AccessTokenEntity a where a.expiration <= :date"), @NamedQuery(name="OAuth2AccessTokenEntity.getByRefreshToken", query="select a from OAuth2AccessTokenEntity a where a.refreshToken = :refreshToken"), @NamedQuery(name="OAuth2AccessTokenEntity.getByClient", query="select a from OAuth2AccessTokenEntity a where a.client = :client"), @NamedQuery(name="OAuth2AccessTokenEntity.getByIdToken", query="select a from OAuth2AccessTokenEntity a where a.idToken = :idToken"), @NamedQuery(name="OAuth2AccessTokenEntity.getByTokenValue", query="select a from OAuth2AccessTokenEntity a where a.jwt = :tokenValue"), @NamedQuery(name="OAuth2AccessTokenEntity.getByResourceSet", query="select a from OAuth2AccessTokenEntity a join a.permissions p where p.resourceSet.id = :rsid")})
- @JsonSerialize(using=OAuth2AccessTokenJackson1Serializer.class)
- @JsonDeserialize(using=OAuth2AccessTokenJackson1Deserializer.class)
- @com.fasterxml.jackson.databind.annotation.JsonSerialize(using=OAuth2AccessTokenJackson2Serializer.class)
- @com.fasterxml.jackson.databind.annotation.JsonDeserialize(using=OAuth2AccessTokenJackson2Deserializer.class)
- public class OAuth2AccessTokenEntity
- implements OAuth2AccessToken {
- public static final String QUERY_BY_TOKEN_VALUE = "OAuth2AccessTokenEntity.getByTokenValue";
- public static final String QUERY_BY_ID_TOKEN = "OAuth2AccessTokenEntity.getByIdToken";
- public static final String QUERY_BY_CLIENT = "OAuth2AccessTokenEntity.getByClient";
- public static final String QUERY_BY_REFRESH_TOKEN = "OAuth2AccessTokenEntity.getByRefreshToken";
- public static final String QUERY_EXPIRED_BY_DATE = "OAuth2AccessTokenEntity.getAllExpiredByDate";
- public static final String QUERY_ALL = "OAuth2AccessTokenEntity.getAll";
- public static final String QUERY_BY_RESOURCE_SET = "OAuth2AccessTokenEntity.getByResourceSet";
- public static final String PARAM_TOKEN_VALUE = "tokenValue";
- public static final String PARAM_ID_TOKEN = "idToken";
- public static final String PARAM_CLIENT = "client";
- public static final String PARAM_REFERSH_TOKEN = "refreshToken";
- public static final String PARAM_DATE = "date";
- public static final String PARAM_RESOURCE_SET_ID = "rsid";
- public static String ID_TOKEN_FIELD_NAME = "id_token";
- private Long id;
- private ClientDetailsEntity client;
- private AuthenticationHolderEntity authenticationHolder;
- private JWT jwtValue;
- private OAuth2AccessTokenEntity idToken;
- private Date expiration;
- private String tokenType = "Bearer";
- private OAuth2RefreshTokenEntity refreshToken;
- private Set<String> scope;
- private Set<Permission> permissions;
- private Set<LaunchContextEntity> launchContextParams = Sets.newHashSet();
- @Id
- @GeneratedValue(strategy=GenerationType.IDENTITY)
- @Column(name="id")
- public Long getId() {
- return this.id;
- }
- public void setId(Long id) {
- this.id = id;
- }
- @Transient
- public Map<String, Object> getAdditionalInformation() {
- HashMap<String, Object> map = new HashMap<String, Object>();
- if (this.getIdToken() != null) {
- map.put(ID_TOKEN_FIELD_NAME, this.getIdTokenString());
- }
- if (this.getLaunchContext() != null) {
- for (LaunchContextEntity cparam : this.getLaunchContext()) {
- String val = cparam.getValue();
- if (val.equals("true")) {
- map.put(cparam.getName(), true);
- continue;
- }
- if (val.equals("false")) {
- map.put(cparam.getName(), false);
- continue;
- }
- map.put(cparam.getName(), val);
- }
- }
- return map;
- }
- @ManyToOne
- @JoinColumn(name="auth_holder_id")
- public AuthenticationHolderEntity getAuthenticationHolder() {
- return this.authenticationHolder;
- }
- public void setAuthenticationHolder(AuthenticationHolderEntity authenticationHolder) {
- this.authenticationHolder = authenticationHolder;
- }
- @ManyToOne
- @JoinColumn(name="client_id")
- public ClientDetailsEntity getClient() {
- return this.client;
- }
- public void setClient(ClientDetailsEntity client) {
- this.client = client;
- }
- @Transient
- public String getValue() {
- return this.jwtValue.serialize();
- }
- @Basic
- @Temporal(value=TemporalType.TIMESTAMP)
- @Column(name="expiration")
- public Date getExpiration() {
- return this.expiration;
- }
- public void setExpiration(Date expiration) {
- this.expiration = expiration;
- }
- @Basic
- @Column(name="token_type")
- public String getTokenType() {
- return this.tokenType;
- }
- public void setTokenType(String tokenType) {
- this.tokenType = tokenType;
- }
- @ManyToOne
- @JoinColumn(name="refresh_token_id")
- public OAuth2RefreshTokenEntity getRefreshToken() {
- return this.refreshToken;
- }
- public void setRefreshToken(OAuth2RefreshTokenEntity refreshToken) {
- this.refreshToken = refreshToken;
- }
- public void setRefreshToken(OAuth2RefreshToken refreshToken) {
- if (!(refreshToken instanceof OAuth2RefreshTokenEntity)) {
- throw new IllegalArgumentException("Not a storable refresh token entity!");
- }
- this.setRefreshToken((OAuth2RefreshTokenEntity)refreshToken);
- }
- @ElementCollection(fetch=FetchType.EAGER)
- @CollectionTable(joinColumns={@JoinColumn(name="owner_id")}, name="token_scope")
- public Set<String> getScope() {
- return this.scope;
- }
- public void setScope(Set<String> scope) {
- this.scope = scope;
- }
- @Transient
- public boolean isExpired() {
- return this.getExpiration() == null ? false : System.currentTimeMillis() > this.getExpiration().getTime();
- }
- @OneToOne(cascade={CascadeType.ALL})
- @JoinColumn(name="id_token_id")
- public OAuth2AccessTokenEntity getIdToken() {
- return this.idToken;
- }
- public void setIdToken(OAuth2AccessTokenEntity idToken) {
- this.idToken = idToken;
- }
- @Transient
- public String getIdTokenString() {
- if (this.idToken != null) {
- return this.idToken.getValue();
- }
- return null;
- }
- @OneToMany(cascade={CascadeType.ALL}, fetch=FetchType.EAGER)
- @JoinColumn(name="access_token_id")
- public Set<LaunchContextEntity> getLaunchContext() {
- return this.launchContextParams;
- }
- public void setLaunchContext(Set<LaunchContextEntity> launchContextParams) {
- this.launchContextParams = launchContextParams;
- }
- @Basic
- @Column(name="token_value")
- @Convert(converter=JWTStringConverter.class)
- public JWT getJwt() {
- return this.jwtValue;
- }
- public void setJwt(JWT jwt) {
- this.jwtValue = jwt;
- }
- @Transient
- public int getExpiresIn() {
- if (this.getExpiration() == null) {
- return -1;
- }
- int secondsRemaining = (int)((this.getExpiration().getTime() - System.currentTimeMillis()) / 1000);
- if (this.isExpired()) {
- return 0;
- }
- return secondsRemaining;
- }
- @OneToMany(fetch=FetchType.EAGER, cascade={CascadeType.ALL})
- @JoinTable(name="access_token_permissions", joinColumns={@JoinColumn(name="access_token_id")}, inverseJoinColumns={@JoinColumn(name="permission_id")})
- public Set<Permission> getPermissions() {
- return this.permissions;
- }
- public void setPermissions(Set<Permission> permissions) {
- this.permissions = permissions;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement