refactoring submodule common - part 4
parent
273106f76b
commit
c8ddea070e
|
@ -37,7 +37,6 @@ import com.google.gson.JsonElement;
|
|||
|
||||
/**
|
||||
* @author jricher
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "claim")
|
||||
|
@ -51,129 +50,86 @@ public class Claim {
|
|||
private Set<String> claimTokenFormat;
|
||||
private Set<String> issuer;
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
/**
|
||||
* @param id the id to set
|
||||
*/
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
|
||||
@Basic
|
||||
@Column(name = "name")
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
/**
|
||||
* @param name the name to set
|
||||
*/
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the friendlyName
|
||||
*/
|
||||
|
||||
@Basic
|
||||
@Column(name = "friendly_name")
|
||||
public String getFriendlyName() {
|
||||
return friendlyName;
|
||||
}
|
||||
/**
|
||||
* @param friendlyName the friendlyName to set
|
||||
*/
|
||||
|
||||
public void setFriendlyName(String friendlyName) {
|
||||
this.friendlyName = friendlyName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the claimType
|
||||
*/
|
||||
@Basic
|
||||
@Column(name = "claim_type")
|
||||
public String getClaimType() {
|
||||
return claimType;
|
||||
}
|
||||
/**
|
||||
* @param claimType the claimType to set
|
||||
*/
|
||||
|
||||
public void setClaimType(String claimType) {
|
||||
this.claimType = claimType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the claimTokenFormat
|
||||
*/
|
||||
@ElementCollection(fetch = FetchType.EAGER)
|
||||
@Column(name = "claim_token_format")
|
||||
@CollectionTable(
|
||||
name = "claim_token_format",
|
||||
joinColumns = @JoinColumn(name = "owner_id")
|
||||
)
|
||||
@CollectionTable(name = "claim_token_format", joinColumns = @JoinColumn(name = "owner_id"))
|
||||
public Set<String> getClaimTokenFormat() {
|
||||
return claimTokenFormat;
|
||||
}
|
||||
/**
|
||||
* @param claimTokenFormat the claimTokenFormat to set
|
||||
*/
|
||||
|
||||
public void setClaimTokenFormat(Set<String> claimTokenFormat) {
|
||||
this.claimTokenFormat = claimTokenFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the issuer
|
||||
*/
|
||||
@ElementCollection(fetch = FetchType.EAGER)
|
||||
@Column(name = "issuer")
|
||||
@CollectionTable(
|
||||
name = "claim_issuer",
|
||||
joinColumns = @JoinColumn(name = "owner_id")
|
||||
)
|
||||
@CollectionTable(name = "claim_issuer", joinColumns = @JoinColumn(name = "owner_id"))
|
||||
public Set<String> getIssuer() {
|
||||
return issuer;
|
||||
}
|
||||
/**
|
||||
* @param issuer the issuer to set
|
||||
*/
|
||||
|
||||
public void setIssuer(Set<String> issuer) {
|
||||
this.issuer = issuer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the value
|
||||
*/
|
||||
@Basic
|
||||
@Column(name = "claim_value")
|
||||
@Convert(converter = JsonElementStringConverter.class)
|
||||
public JsonElement getValue() {
|
||||
return value;
|
||||
}
|
||||
/**
|
||||
* @param value the value to set
|
||||
*/
|
||||
|
||||
public void setValue(JsonElement value) {
|
||||
this.value = value;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Claim [id=" + id + ", name=" + name + ", friendlyName=" + friendlyName + ", claimType=" + claimType + ", value=" + value + ", claimTokenFormat=" + claimTokenFormat + ", issuer=" + issuer + "]";
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
|
@ -187,9 +143,7 @@ public class Claim {
|
|||
result = prime * result + ((value == null) ? 0 : value.hashCode());
|
||||
return result;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
|
@ -253,4 +207,5 @@ public class Claim {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.util.Collection;
|
|||
* Data shuttle to return results of the claims processing service.
|
||||
*
|
||||
* @author jricher
|
||||
*
|
||||
*/
|
||||
public class ClaimProcessingResult {
|
||||
|
||||
|
@ -30,64 +29,38 @@ public class ClaimProcessingResult {
|
|||
private Collection<Claim> unmatched;
|
||||
private Policy matched;
|
||||
|
||||
/**
|
||||
* Create an unmatched result. isSatisfied is false.
|
||||
* @param unmatched
|
||||
*/
|
||||
public ClaimProcessingResult(Collection<Claim> unmatched) {
|
||||
this.satisfied = false;
|
||||
this.unmatched = unmatched;
|
||||
this.matched = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a matched result. isSatisfied is true.
|
||||
* @param matched
|
||||
*/
|
||||
public ClaimProcessingResult(Policy matched) {
|
||||
this.satisfied = true;
|
||||
this.matched = matched;
|
||||
this.unmatched = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the satisfied
|
||||
*/
|
||||
public boolean isSatisfied() {
|
||||
return satisfied;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param satisfied the satisfied to set
|
||||
*/
|
||||
public void setSatisfied(boolean satisfied) {
|
||||
this.satisfied = satisfied;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the unmatched
|
||||
*/
|
||||
public Collection<Claim> getUnmatched() {
|
||||
return unmatched;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param unmatched the unmatched to set
|
||||
*/
|
||||
public void setUnmatched(Collection<Claim> unmatched) {
|
||||
this.unmatched = unmatched;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the matched
|
||||
*/
|
||||
public Policy getMatched() {
|
||||
return matched;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param matched the matched to set
|
||||
*/
|
||||
public void setMatched(Policy matched) {
|
||||
this.matched = matched;
|
||||
}
|
||||
|
|
|
@ -41,9 +41,6 @@ public class Permission {
|
|||
private ResourceSet resourceSet;
|
||||
private Set<String> scopes;
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
|
@ -51,46 +48,29 @@ public class Permission {
|
|||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id the id to set
|
||||
*/
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the resourceSet
|
||||
*/
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "resource_set_id")
|
||||
public ResourceSet getResourceSet() {
|
||||
return resourceSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param resourceSet the resourceSet to set
|
||||
*/
|
||||
public void setResourceSet(ResourceSet resourceSet) {
|
||||
this.resourceSet = resourceSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the scopes
|
||||
*/
|
||||
@ElementCollection(fetch = FetchType.EAGER)
|
||||
@Column(name = "scope")
|
||||
@CollectionTable(
|
||||
name = "permission_scope",
|
||||
joinColumns = @JoinColumn(name = "owner_id")
|
||||
)
|
||||
@CollectionTable(name = "permission_scope", joinColumns = @JoinColumn(name = "owner_id"))
|
||||
public Set<String> getScopes() {
|
||||
return scopes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param scopes the scopes to set
|
||||
*/
|
||||
public void setScopes(Set<String> scopes) {
|
||||
this.scopes = scopes;
|
||||
}
|
||||
|
||||
}
|
|
@ -66,9 +66,6 @@ public class PermissionTicket {
|
|||
private Date expiration;
|
||||
private Collection<Claim> claimsSupplied;
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
|
@ -76,48 +73,30 @@ public class PermissionTicket {
|
|||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id the id to set
|
||||
*/
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the permission
|
||||
*/
|
||||
@OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
|
||||
@JoinColumn(name = "permission_id")
|
||||
public Permission getPermission() {
|
||||
return permission;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param permission the permission to set
|
||||
*/
|
||||
public void setPermission(Permission permission) {
|
||||
this.permission = permission;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ticket
|
||||
*/
|
||||
@Basic
|
||||
@Column(name = "ticket")
|
||||
public String getTicket() {
|
||||
return ticket;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ticket the ticket to set
|
||||
*/
|
||||
public void setTicket(String ticket) {
|
||||
this.ticket = ticket;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the expiration
|
||||
*/
|
||||
@Basic
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
@Column(name = "expiration")
|
||||
|
@ -125,32 +104,19 @@ public class PermissionTicket {
|
|||
return expiration;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param expiration the expiration to set
|
||||
*/
|
||||
public void setExpiration(Date expiration) {
|
||||
this.expiration = expiration;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the claimsSupplied
|
||||
*/
|
||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||
@JoinTable(
|
||||
name = "claim_to_permission_ticket",
|
||||
joinColumns = @JoinColumn(name = "permission_ticket_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "claim_id")
|
||||
)
|
||||
@JoinTable(name = "claim_to_permission_ticket", joinColumns = @JoinColumn(name = "permission_ticket_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "claim_id"))
|
||||
public Collection<Claim> getClaimsSupplied() {
|
||||
return claimsSupplied;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param claimsSupplied the claimsSupplied to set
|
||||
*/
|
||||
public void setClaimsSupplied(Collection<Claim> claimsSupplied) {
|
||||
this.claimsSupplied = claimsSupplied;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -38,7 +38,6 @@ import javax.persistence.Table;
|
|||
* A set of claims required to fulfill a given permission.
|
||||
*
|
||||
* @author jricher
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "policy")
|
||||
|
@ -49,9 +48,6 @@ public class Policy {
|
|||
private Collection<Claim> claimsRequired;
|
||||
private Set<String> scopes;
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
|
@ -59,80 +55,47 @@ public class Policy {
|
|||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id the id to set
|
||||
*/
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
@Basic
|
||||
@Column(name = "name")
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name the name to set
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the claimsRequired
|
||||
*/
|
||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||
@JoinTable(
|
||||
name = "claim_to_policy",
|
||||
joinColumns = @JoinColumn(name = "policy_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "claim_id")
|
||||
)
|
||||
@JoinTable(name = "claim_to_policy", joinColumns = @JoinColumn(name = "policy_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "claim_id"))
|
||||
public Collection<Claim> getClaimsRequired() {
|
||||
return claimsRequired;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param claimsRequired the claimsRequired to set
|
||||
*/
|
||||
public void setClaimsRequired(Collection<Claim> claimsRequired) {
|
||||
this.claimsRequired = claimsRequired;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the scopes
|
||||
*/
|
||||
@ElementCollection(fetch = FetchType.EAGER)
|
||||
@Column(name = "scope")
|
||||
@CollectionTable(
|
||||
name = "policy_scope",
|
||||
joinColumns = @JoinColumn(name = "owner_id")
|
||||
)
|
||||
@CollectionTable(name = "policy_scope", joinColumns = @JoinColumn(name = "owner_id"))
|
||||
public Set<String> getScopes() {
|
||||
return scopes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param scopes the scopes to set
|
||||
*/
|
||||
public void setScopes(Set<String> scopes) {
|
||||
this.scopes = scopes;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Policy [id=" + id + ", name=" + name + ", claimsRequired=" + claimsRequired + ", scopes=" + scopes + "]";
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
|
@ -144,9 +107,6 @@ public class Policy {
|
|||
return result;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
|
|
|
@ -59,15 +59,11 @@ public class ResourceSet {
|
|||
private String type;
|
||||
private Set<String> scopes = new HashSet<>();
|
||||
private String iconUri;
|
||||
|
||||
private String owner; // username of the person responsible for the registration (either directly or via OAuth token)
|
||||
private String clientId; // client id of the protected resource that registered this resource set via OAuth token
|
||||
|
||||
private Collection<Policy> policies = new HashSet<>();
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
|
@ -75,156 +71,96 @@ public class ResourceSet {
|
|||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id the id to set
|
||||
*/
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
@Basic
|
||||
@Column(name = "name")
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name the name to set
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the uri
|
||||
*/
|
||||
@Basic
|
||||
@Column(name = "uri")
|
||||
public String getUri() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param uri the uri to set
|
||||
*/
|
||||
public void setUri(String uri) {
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the type
|
||||
*/
|
||||
@Basic
|
||||
@Column(name = "rs_type")
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type the type to set
|
||||
*/
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the scopes
|
||||
*/
|
||||
@ElementCollection(fetch = FetchType.EAGER)
|
||||
@Column(name = "scope")
|
||||
@CollectionTable(
|
||||
name = "resource_set_scope",
|
||||
joinColumns = @JoinColumn(name = "owner_id")
|
||||
)
|
||||
@CollectionTable(name = "resource_set_scope", joinColumns = @JoinColumn(name = "owner_id"))
|
||||
public Set<String> getScopes() {
|
||||
return scopes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param scopes the scopes to set
|
||||
*/
|
||||
public void setScopes(Set<String> scopes) {
|
||||
this.scopes = scopes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the iconUri
|
||||
*/
|
||||
@Basic
|
||||
@Column(name = "icon_uri")
|
||||
public String getIconUri() {
|
||||
return iconUri;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param iconUri the iconUri to set
|
||||
*/
|
||||
public void setIconUri(String iconUri) {
|
||||
this.iconUri = iconUri;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the owner
|
||||
*/
|
||||
@Basic
|
||||
@Column(name = "owner")
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param owner the owner to set
|
||||
*/
|
||||
public void setOwner(String owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the clientId
|
||||
*/
|
||||
@Basic
|
||||
@Column(name = "client_id")
|
||||
public String getClientId() {
|
||||
return clientId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param clientId the clientId to set
|
||||
*/
|
||||
public void setClientId(String clientId) {
|
||||
this.clientId = clientId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the claimsRequired
|
||||
*/
|
||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "resource_set_id")
|
||||
public Collection<Policy> getPolicies() {
|
||||
return policies;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param policies the claimsRequired to set
|
||||
*/
|
||||
public void setPolicies(Collection<Policy> policies) {
|
||||
this.policies = policies;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ResourceSet [id=" + id + ", name=" + name + ", uri=" + uri + ", type=" + type + ", scopes=" + scopes + ", iconUri=" + iconUri + ", owner=" + owner + ", clientId=" + clientId + ", policies=" + policies + "]";
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
|
@ -322,8 +258,4 @@ public class ResourceSet {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@ import org.mitre.uma.model.convert.RegisteredClientStringConverter;
|
|||
|
||||
/**
|
||||
* @author jricher
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "saved_registered_client")
|
||||
|
@ -40,9 +39,6 @@ public class SavedRegisteredClient {
|
|||
private String issuer;
|
||||
private RegisteredClient registeredClient;
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
|
@ -50,33 +46,20 @@ public class SavedRegisteredClient {
|
|||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param id the id to set
|
||||
*/
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the issuer
|
||||
*/
|
||||
@Basic
|
||||
@Column(name = "issuer")
|
||||
public String getIssuer() {
|
||||
return issuer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param issuer the issuer to set
|
||||
*/
|
||||
public void setIssuer(String issuer) {
|
||||
this.issuer = issuer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the registeredClient
|
||||
*/
|
||||
@Basic
|
||||
@Column(name = "registered_client")
|
||||
@Convert(converter = RegisteredClientStringConverter.class)
|
||||
|
@ -84,13 +67,8 @@ public class SavedRegisteredClient {
|
|||
return registeredClient;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param registeredClient the registeredClient to set
|
||||
*/
|
||||
public void setRegisteredClient(RegisteredClient registeredClient) {
|
||||
this.registeredClient = registeredClient;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -21,39 +21,22 @@ import javax.persistence.Converter;
|
|||
|
||||
import org.mitre.oauth2.model.RegisteredClient;
|
||||
import org.mitre.openid.connect.ClientDetailsEntityJsonProcessor;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* @author jricher
|
||||
*
|
||||
*/
|
||||
@Converter
|
||||
public class RegisteredClientStringConverter implements AttributeConverter<RegisteredClient, String>{
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see javax.persistence.AttributeConverter#convertToDatabaseColumn(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public String convertToDatabaseColumn(RegisteredClient attribute) {
|
||||
if (attribute == null || attribute.getSource() == null) {
|
||||
return null;
|
||||
} else {
|
||||
return attribute.getSource().toString();
|
||||
}
|
||||
|
||||
return attribute == null || attribute.getSource() == null ? null : attribute.getSource().toString();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see javax.persistence.AttributeConverter#convertToEntityAttribute(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public RegisteredClient convertToEntityAttribute(String dbData) {
|
||||
if (Strings.isNullOrEmpty(dbData)) {
|
||||
return null;
|
||||
} else {
|
||||
return ClientDetailsEntityJsonProcessor.parseRegistered(dbData);
|
||||
}
|
||||
return StringUtils.isEmpty(dbData) ? null : ClientDetailsEntityJsonProcessor.parseRegistered(dbData);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,63 +24,21 @@ import org.mitre.uma.model.ResourceSet;
|
|||
|
||||
/**
|
||||
* @author jricher
|
||||
*
|
||||
*/
|
||||
public interface PermissionRepository {
|
||||
|
||||
/**
|
||||
*
|
||||
* Save a permission ticket.
|
||||
*
|
||||
* @param p
|
||||
* @return
|
||||
*/
|
||||
public PermissionTicket save(PermissionTicket p);
|
||||
PermissionTicket save(PermissionTicket p);
|
||||
|
||||
/**
|
||||
* Get the permission indicated by its ticket value.
|
||||
*
|
||||
* @param ticket
|
||||
* @return
|
||||
*/
|
||||
public PermissionTicket getByTicket(String ticket);
|
||||
PermissionTicket getByTicket(String ticket);
|
||||
|
||||
/**
|
||||
* Get all the tickets in the system (used by the import/export API)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Collection<PermissionTicket> getAll();
|
||||
Collection<PermissionTicket> getAll();
|
||||
|
||||
/**
|
||||
* Save a permission object with no associated ticket (used by the import/export API)
|
||||
*
|
||||
* @param p
|
||||
* @return
|
||||
*/
|
||||
public Permission saveRawPermission(Permission p);
|
||||
Permission saveRawPermission(Permission p);
|
||||
|
||||
/**
|
||||
* Get a permission object by its ID (used by the import/export API)
|
||||
*
|
||||
* @param permissionId
|
||||
* @return
|
||||
*/
|
||||
public Permission getById(Long permissionId);
|
||||
Permission getById(Long permissionId);
|
||||
|
||||
/**
|
||||
* Get all permission tickets issued against a resource set (called when RS is deleted)
|
||||
*
|
||||
* @param rs
|
||||
* @return
|
||||
*/
|
||||
public Collection<PermissionTicket> getPermissionTicketsForResourceSet(ResourceSet rs);
|
||||
Collection<PermissionTicket> getPermissionTicketsForResourceSet(ResourceSet rs);
|
||||
|
||||
/**
|
||||
* Remove the specified ticket.
|
||||
*
|
||||
* @param ticket
|
||||
*/
|
||||
public void remove(PermissionTicket ticket);
|
||||
void remove(PermissionTicket ticket);
|
||||
|
||||
}
|
||||
|
|
|
@ -22,22 +22,21 @@ import org.mitre.uma.model.ResourceSet;
|
|||
|
||||
/**
|
||||
* @author jricher
|
||||
*
|
||||
*/
|
||||
public interface ResourceSetRepository {
|
||||
|
||||
public ResourceSet save(ResourceSet rs);
|
||||
ResourceSet save(ResourceSet rs);
|
||||
|
||||
public ResourceSet getById(Long id);
|
||||
ResourceSet getById(Long id);
|
||||
|
||||
public void remove(ResourceSet rs);
|
||||
void remove(ResourceSet rs);
|
||||
|
||||
public Collection<ResourceSet> getAllForOwner(String owner);
|
||||
Collection<ResourceSet> getAllForOwner(String owner);
|
||||
|
||||
public Collection<ResourceSet> getAllForOwnerAndClient(String owner, String clientId);
|
||||
Collection<ResourceSet> getAllForOwnerAndClient(String owner, String clientId);
|
||||
|
||||
public Collection<ResourceSet> getAll();
|
||||
Collection<ResourceSet> getAll();
|
||||
|
||||
public Collection<ResourceSet> getAllForClient(String clientId);
|
||||
Collection<ResourceSet> getAllForClient(String clientId);
|
||||
|
||||
}
|
||||
|
|
|
@ -21,11 +21,9 @@ import org.mitre.uma.model.PermissionTicket;
|
|||
import org.mitre.uma.model.ResourceSet;
|
||||
|
||||
/**
|
||||
*
|
||||
* Processes claims presented during an UMA transaction.
|
||||
*
|
||||
* @author jricher
|
||||
*
|
||||
*/
|
||||
public interface ClaimsProcessingService {
|
||||
|
||||
|
@ -39,6 +37,6 @@ public interface ClaimsProcessingService {
|
|||
* @param ticket the supplied claims to test
|
||||
* @return the result of the claims processing action
|
||||
*/
|
||||
public ClaimProcessingResult claimsAreSatisfied(ResourceSet rs, PermissionTicket ticket);
|
||||
ClaimProcessingResult claimsAreSatisfied(ResourceSet rs, PermissionTicket ticket);
|
||||
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ import org.springframework.security.oauth2.common.exceptions.InsufficientScopeEx
|
|||
|
||||
/**
|
||||
* @author jricher
|
||||
*
|
||||
*/
|
||||
public interface PermissionService {
|
||||
|
||||
|
@ -35,16 +34,15 @@ public interface PermissionService {
|
|||
* @return the created (and stored) permission object, with ticket
|
||||
* @throws InsufficientScopeException if the scopes in scopes don't match those in resourceSet.getScopes
|
||||
*/
|
||||
public PermissionTicket createTicket(ResourceSet resourceSet, Set<String> scopes);
|
||||
PermissionTicket createTicket(ResourceSet resourceSet, Set<String> scopes);
|
||||
|
||||
/**
|
||||
*
|
||||
* Read the permission associated with the given ticket.
|
||||
*
|
||||
* @param the ticket value to search on
|
||||
* @return the permission object, or null if none is found
|
||||
*/
|
||||
public PermissionTicket getByTicket(String ticket);
|
||||
PermissionTicket getByTicket(String ticket);
|
||||
|
||||
/**
|
||||
* Save the updated permission ticket to the database. Does not create a new ticket.
|
||||
|
@ -52,6 +50,6 @@ public interface PermissionService {
|
|||
* @param ticket
|
||||
* @return
|
||||
*/
|
||||
public PermissionTicket updateTicket(PermissionTicket ticket);
|
||||
PermissionTicket updateTicket(PermissionTicket ticket);
|
||||
|
||||
}
|
||||
|
|
|
@ -21,26 +21,24 @@ import org.mitre.oauth2.model.ClientDetailsEntity;
|
|||
import org.mitre.uma.model.ResourceSet;
|
||||
|
||||
/**
|
||||
*
|
||||
* Manage registered resource sets at this authorization server.
|
||||
*
|
||||
* @author jricher
|
||||
*
|
||||
*/
|
||||
public interface ResourceSetService {
|
||||
|
||||
public ResourceSet saveNew(ResourceSet rs);
|
||||
ResourceSet saveNew(ResourceSet rs);
|
||||
|
||||
public ResourceSet getById(Long id);
|
||||
ResourceSet getById(Long id);
|
||||
|
||||
public ResourceSet update(ResourceSet oldRs, ResourceSet newRs);
|
||||
ResourceSet update(ResourceSet oldRs, ResourceSet newRs);
|
||||
|
||||
public void remove(ResourceSet rs);
|
||||
void remove(ResourceSet rs);
|
||||
|
||||
public Collection<ResourceSet> getAllForOwner(String owner);
|
||||
Collection<ResourceSet> getAllForOwner(String owner);
|
||||
|
||||
public Collection<ResourceSet> getAllForOwnerAndClient(String owner, String authClientId);
|
||||
Collection<ResourceSet> getAllForOwnerAndClient(String owner, String authClientId);
|
||||
|
||||
public Collection<ResourceSet> getAllForClient(ClientDetailsEntity client);
|
||||
Collection<ResourceSet> getAllForClient(ClientDetailsEntity client);
|
||||
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ import org.mitre.uma.model.SavedRegisteredClient;
|
|||
|
||||
/**
|
||||
* @author jricher
|
||||
*
|
||||
*/
|
||||
public interface SavedRegisteredClientService {
|
||||
|
||||
|
|
|
@ -31,8 +31,7 @@ public interface UmaTokenService {
|
|||
|
||||
/**
|
||||
* Create the RPT from the given authentication and ticket.
|
||||
*
|
||||
*/
|
||||
public OAuth2AccessTokenEntity createRequestingPartyToken(OAuth2Authentication o2auth, PermissionTicket ticket, Policy policy);
|
||||
OAuth2AccessTokenEntity createRequestingPartyToken(OAuth2Authentication o2auth, PermissionTicket ticket, Policy policy);
|
||||
|
||||
}
|
||||
|
|
|
@ -51,14 +51,10 @@ import com.nimbusds.jose.JWSAlgorithm;
|
|||
* A collection of null-safe converters from common classes and JSON elements, using GSON.
|
||||
*
|
||||
* @author jricher
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings(value = {"rawtypes", "unchecked"})
|
||||
public class JsonUtils {
|
||||
|
||||
/**
|
||||
* Logger for this class
|
||||
*/
|
||||
private static final Logger logger = LoggerFactory.getLogger(JsonUtils.class);
|
||||
|
||||
private static Gson gson = new Gson();
|
||||
|
@ -72,7 +68,6 @@ public class JsonUtils {
|
|||
return getAsArray(value, false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Translate a set of strings to a JSON array, optionally preserving the empty array. Otherwise (default) empty array is returned as null.
|
||||
* @param value
|
||||
|
@ -109,11 +104,7 @@ public class JsonUtils {
|
|||
*/
|
||||
public static JWEAlgorithm getAsJweAlgorithm(JsonObject o, String member) {
|
||||
String s = getAsString(o, member);
|
||||
if (s != null) {
|
||||
return JWEAlgorithm.parse(s);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return s != null ? JWEAlgorithm.parse(s) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -121,11 +112,7 @@ public class JsonUtils {
|
|||
*/
|
||||
public static EncryptionMethod getAsJweEncryptionMethod(JsonObject o, String member) {
|
||||
String s = getAsString(o, member);
|
||||
if (s != null) {
|
||||
return EncryptionMethod.parse(s);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return s != null ? EncryptionMethod.parse(s) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -133,11 +120,7 @@ public class JsonUtils {
|
|||
*/
|
||||
public static JWSAlgorithm getAsJwsAlgorithm(JsonObject o, String member) {
|
||||
String s = getAsString(o, member);
|
||||
if (s != null) {
|
||||
return JWSAlgorithm.parse(s);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return s != null ? JWSAlgorithm.parse(s) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -148,11 +131,7 @@ public class JsonUtils {
|
|||
*/
|
||||
public static PKCEAlgorithm getAsPkceAlgorithm(JsonObject o, String member) {
|
||||
String s = getAsString(o, member);
|
||||
if (s != null) {
|
||||
return PKCEAlgorithm.parse(s);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return s != null ? PKCEAlgorithm.parse(s) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -286,7 +265,7 @@ public class JsonUtils {
|
|||
reader.beginObject();
|
||||
while(reader.hasNext()) {
|
||||
String name = reader.nextName();
|
||||
Object value = null;
|
||||
Object value;
|
||||
switch(reader.peek()) {
|
||||
case STRING:
|
||||
value = reader.nextString();
|
||||
|
@ -309,7 +288,7 @@ public class JsonUtils {
|
|||
}
|
||||
|
||||
public static Set readSet(JsonReader reader) throws IOException {
|
||||
Set arraySet = null;
|
||||
Set arraySet;
|
||||
reader.beginArray();
|
||||
switch (reader.peek()) {
|
||||
case STRING:
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.mitre.data.PageCriteria;
|
|||
* Time: 2:13 PM
|
||||
*/
|
||||
public class JpaUtil {
|
||||
|
||||
public static <T> T getSingleResult(List<T> list) {
|
||||
switch(list.size()) {
|
||||
case 0:
|
||||
|
@ -41,7 +42,6 @@ public class JpaUtil {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a page of results from the specified TypedQuery
|
||||
* by using the given PageCriteria to limit the query
|
||||
|
@ -60,9 +60,10 @@ public class JpaUtil {
|
|||
return query.getResultList();
|
||||
}
|
||||
|
||||
public static <T, I> T saveOrUpdate(I id, EntityManager entityManager, T entity) {
|
||||
public static <T, I> T saveOrUpdate(EntityManager entityManager, T entity) {
|
||||
T tmp = entityManager.merge(entity);
|
||||
entityManager.flush();
|
||||
return tmp;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ public class JpaAuthenticationHolderRepository implements AuthenticationHolderRe
|
|||
@Override
|
||||
@Transactional(value="defaultTransactionManager")
|
||||
public AuthenticationHolderEntity save(AuthenticationHolderEntity a) {
|
||||
return JpaUtil.saveOrUpdate(a.getId(), manager, a);
|
||||
return JpaUtil.saveOrUpdate(manager, a);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -54,7 +54,7 @@ public class JpaAuthorizationCodeRepository implements AuthorizationCodeReposito
|
|||
@Transactional(value="defaultTransactionManager")
|
||||
public AuthorizationCodeEntity save(AuthorizationCodeEntity authorizationCode) {
|
||||
|
||||
return JpaUtil.saveOrUpdate(authorizationCode.getId(), manager, authorizationCode);
|
||||
return JpaUtil.saveOrUpdate(manager, authorizationCode);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ public class JpaDeviceCodeRepository implements DeviceCodeRepository {
|
|||
@Override
|
||||
@Transactional(value="defaultTransactionManager")
|
||||
public DeviceCode save(DeviceCode scope) {
|
||||
return saveOrUpdate(scope.getId(), em, scope);
|
||||
return saveOrUpdate(em, scope);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -68,7 +68,7 @@ public class JpaOAuth2ClientRepository implements OAuth2ClientRepository {
|
|||
*/
|
||||
@Override
|
||||
public ClientDetailsEntity saveClient(ClientDetailsEntity client) {
|
||||
return JpaUtil.saveOrUpdate(client.getClientId(), manager, client);
|
||||
return JpaUtil.saveOrUpdate(manager, client);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -89,7 +89,7 @@ public class JpaOAuth2ClientRepository implements OAuth2ClientRepository {
|
|||
// sanity check
|
||||
client.setId(id);
|
||||
|
||||
return JpaUtil.saveOrUpdate(id, manager, client);
|
||||
return JpaUtil.saveOrUpdate(manager, client);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -93,7 +93,7 @@ public class JpaOAuth2TokenRepository implements OAuth2TokenRepository {
|
|||
@Override
|
||||
@Transactional(value="defaultTransactionManager")
|
||||
public OAuth2AccessTokenEntity saveAccessToken(OAuth2AccessTokenEntity token) {
|
||||
return JpaUtil.saveOrUpdate(token.getId(), manager, token);
|
||||
return JpaUtil.saveOrUpdate(manager, token);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -138,7 +138,7 @@ public class JpaOAuth2TokenRepository implements OAuth2TokenRepository {
|
|||
@Override
|
||||
@Transactional(value="defaultTransactionManager")
|
||||
public OAuth2RefreshTokenEntity saveRefreshToken(OAuth2RefreshTokenEntity refreshToken) {
|
||||
return JpaUtil.saveOrUpdate(refreshToken.getId(), manager, refreshToken);
|
||||
return JpaUtil.saveOrUpdate(manager, refreshToken);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -96,7 +96,7 @@ public class JpaSystemScopeRepository implements SystemScopeRepository {
|
|||
@Override
|
||||
@Transactional(value="defaultTransactionManager")
|
||||
public SystemScope save(SystemScope scope) {
|
||||
return saveOrUpdate(scope.getId(), em, scope);
|
||||
return saveOrUpdate(em, scope);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ public class JpaApprovedSiteRepository implements ApprovedSiteRepository {
|
|||
@Override
|
||||
@Transactional(value="defaultTransactionManager")
|
||||
public ApprovedSite save(ApprovedSite approvedSite) {
|
||||
return saveOrUpdate(approvedSite.getId(), manager, approvedSite);
|
||||
return saveOrUpdate(manager, approvedSite);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -84,7 +84,7 @@ public class JpaBlacklistedSiteRepository implements BlacklistedSiteRepository {
|
|||
@Override
|
||||
@Transactional(value="defaultTransactionManager")
|
||||
public BlacklistedSite save(BlacklistedSite blacklistedSite) {
|
||||
return saveOrUpdate(blacklistedSite.getId(), manager, blacklistedSite);
|
||||
return saveOrUpdate(manager, blacklistedSite);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -95,7 +95,7 @@ public class JpaBlacklistedSiteRepository implements BlacklistedSiteRepository {
|
|||
public BlacklistedSite update(BlacklistedSite oldBlacklistedSite, BlacklistedSite blacklistedSite) {
|
||||
|
||||
blacklistedSite.setId(oldBlacklistedSite.getId());
|
||||
return saveOrUpdate(oldBlacklistedSite.getId(), manager, blacklistedSite);
|
||||
return saveOrUpdate(manager, blacklistedSite);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ public class JpaPairwiseIdentifierRepository implements PairwiseIdentifierReposi
|
|||
@Override
|
||||
@Transactional(value="defaultTransactionManager")
|
||||
public void save(PairwiseIdentifier pairwise) {
|
||||
saveOrUpdate(pairwise.getId(), manager, pairwise);
|
||||
saveOrUpdate(manager, pairwise);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ public class JpaWhitelistedSiteRepository implements WhitelistedSiteRepository {
|
|||
@Override
|
||||
@Transactional(value="defaultTransactionManager")
|
||||
public WhitelistedSite save(WhitelistedSite whiteListedSite) {
|
||||
return saveOrUpdate(whiteListedSite.getId(), manager, whiteListedSite);
|
||||
return saveOrUpdate(manager, whiteListedSite);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -80,7 +80,7 @@ public class JpaWhitelistedSiteRepository implements WhitelistedSiteRepository {
|
|||
// sanity check
|
||||
whitelistedSite.setId(oldWhitelistedSite.getId());
|
||||
|
||||
return saveOrUpdate(oldWhitelistedSite.getId(), manager, whitelistedSite);
|
||||
return saveOrUpdate(manager, whitelistedSite);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -43,7 +43,7 @@ public class JpaPermissionRepository implements PermissionRepository {
|
|||
@Override
|
||||
@Transactional(value="defaultTransactionManager")
|
||||
public PermissionTicket save(PermissionTicket p) {
|
||||
return JpaUtil.saveOrUpdate(p.getId(), em, p);
|
||||
return JpaUtil.saveOrUpdate(em, p);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -71,7 +71,7 @@ public class JpaPermissionRepository implements PermissionRepository {
|
|||
@Override
|
||||
@Transactional(value="defaultTransactionManager")
|
||||
public Permission saveRawPermission(Permission p) {
|
||||
return JpaUtil.saveOrUpdate(p.getId(), em, p);
|
||||
return JpaUtil.saveOrUpdate(em, p);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -44,7 +44,7 @@ public class JpaResourceSetRepository implements ResourceSetRepository {
|
|||
@Override
|
||||
@Transactional(value="defaultTransactionManager")
|
||||
public ResourceSet save(ResourceSet rs) {
|
||||
return JpaUtil.saveOrUpdate(rs.getId(), em, rs);
|
||||
return JpaUtil.saveOrUpdate(em, rs);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue