diff --git a/openid-connect-common/src/main/java/org/mitre/uma/model/Claim.java b/openid-connect-common/src/main/java/org/mitre/uma/model/Claim.java index d93e99c9c..d6d30b64d 100644 --- a/openid-connect-common/src/main/java/org/mitre/uma/model/Claim.java +++ b/openid-connect-common/src/main/java/org/mitre/uma/model/Claim.java @@ -37,7 +37,6 @@ import com.google.gson.JsonElement; /** * @author jricher - * */ @Entity @Table(name = "claim") @@ -51,129 +50,86 @@ public class Claim { private Set claimTokenFormat; private Set 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 getClaimTokenFormat() { return claimTokenFormat; } - /** - * @param claimTokenFormat the claimTokenFormat to set - */ + public void setClaimTokenFormat(Set 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 getIssuer() { return issuer; } - /** - * @param issuer the issuer to set - */ + public void setIssuer(Set 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; } + } diff --git a/openid-connect-common/src/main/java/org/mitre/uma/model/ClaimProcessingResult.java b/openid-connect-common/src/main/java/org/mitre/uma/model/ClaimProcessingResult.java index 0c0065330..8642b1b20 100644 --- a/openid-connect-common/src/main/java/org/mitre/uma/model/ClaimProcessingResult.java +++ b/openid-connect-common/src/main/java/org/mitre/uma/model/ClaimProcessingResult.java @@ -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 unmatched; private Policy matched; - /** - * Create an unmatched result. isSatisfied is false. - * @param unmatched - */ public ClaimProcessingResult(Collection 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 getUnmatched() { return unmatched; } - /** - * @param unmatched the unmatched to set - */ public void setUnmatched(Collection 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; } diff --git a/openid-connect-common/src/main/java/org/mitre/uma/model/Permission.java b/openid-connect-common/src/main/java/org/mitre/uma/model/Permission.java index 42fd2d7f7..a384cd9aa 100644 --- a/openid-connect-common/src/main/java/org/mitre/uma/model/Permission.java +++ b/openid-connect-common/src/main/java/org/mitre/uma/model/Permission.java @@ -41,9 +41,6 @@ public class Permission { private ResourceSet resourceSet; private Set 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 getScopes() { return scopes; } - /** - * @param scopes the scopes to set - */ public void setScopes(Set scopes) { this.scopes = scopes; } -} \ No newline at end of file + +} diff --git a/openid-connect-common/src/main/java/org/mitre/uma/model/PermissionTicket.java b/openid-connect-common/src/main/java/org/mitre/uma/model/PermissionTicket.java index 8b89ef5fd..3bc7040c5 100644 --- a/openid-connect-common/src/main/java/org/mitre/uma/model/PermissionTicket.java +++ b/openid-connect-common/src/main/java/org/mitre/uma/model/PermissionTicket.java @@ -66,9 +66,6 @@ public class PermissionTicket { private Date expiration; private Collection 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 getClaimsSupplied() { return claimsSupplied; } - /** - * @param claimsSupplied the claimsSupplied to set - */ public void setClaimsSupplied(Collection claimsSupplied) { this.claimsSupplied = claimsSupplied; } - } diff --git a/openid-connect-common/src/main/java/org/mitre/uma/model/Policy.java b/openid-connect-common/src/main/java/org/mitre/uma/model/Policy.java index 32098e2fb..064f9e0d8 100644 --- a/openid-connect-common/src/main/java/org/mitre/uma/model/Policy.java +++ b/openid-connect-common/src/main/java/org/mitre/uma/model/Policy.java @@ -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 claimsRequired; private Set 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 getClaimsRequired() { return claimsRequired; } - /** - * @param claimsRequired the claimsRequired to set - */ public void setClaimsRequired(Collection 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 getScopes() { return scopes; } - /** - * @param scopes the scopes to set - */ public void setScopes(Set 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) { diff --git a/openid-connect-common/src/main/java/org/mitre/uma/model/ResourceSet.java b/openid-connect-common/src/main/java/org/mitre/uma/model/ResourceSet.java index 6303d377f..ed73d1c73 100644 --- a/openid-connect-common/src/main/java/org/mitre/uma/model/ResourceSet.java +++ b/openid-connect-common/src/main/java/org/mitre/uma/model/ResourceSet.java @@ -59,15 +59,11 @@ public class ResourceSet { private String type; private Set 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 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 getScopes() { return scopes; } - /** - * @param scopes the scopes to set - */ public void setScopes(Set 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 getPolicies() { return policies; } - /** - * @param policies the claimsRequired to set - */ public void setPolicies(Collection 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; } - - - - } diff --git a/openid-connect-common/src/main/java/org/mitre/uma/model/SavedRegisteredClient.java b/openid-connect-common/src/main/java/org/mitre/uma/model/SavedRegisteredClient.java index 4b0ed9555..34bf8c222 100644 --- a/openid-connect-common/src/main/java/org/mitre/uma/model/SavedRegisteredClient.java +++ b/openid-connect-common/src/main/java/org/mitre/uma/model/SavedRegisteredClient.java @@ -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; } - - } diff --git a/openid-connect-common/src/main/java/org/mitre/uma/model/convert/RegisteredClientStringConverter.java b/openid-connect-common/src/main/java/org/mitre/uma/model/convert/RegisteredClientStringConverter.java index 6a68f9da3..542cf75d2 100644 --- a/openid-connect-common/src/main/java/org/mitre/uma/model/convert/RegisteredClientStringConverter.java +++ b/openid-connect-common/src/main/java/org/mitre/uma/model/convert/RegisteredClientStringConverter.java @@ -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{ - /* (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); } } diff --git a/openid-connect-common/src/main/java/org/mitre/uma/repository/PermissionRepository.java b/openid-connect-common/src/main/java/org/mitre/uma/repository/PermissionRepository.java index 825453dcb..2431e3fe7 100644 --- a/openid-connect-common/src/main/java/org/mitre/uma/repository/PermissionRepository.java +++ b/openid-connect-common/src/main/java/org/mitre/uma/repository/PermissionRepository.java @@ -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 getAll(); + Collection 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 getPermissionTicketsForResourceSet(ResourceSet rs); + Collection getPermissionTicketsForResourceSet(ResourceSet rs); - /** - * Remove the specified ticket. - * - * @param ticket - */ - public void remove(PermissionTicket ticket); + void remove(PermissionTicket ticket); } diff --git a/openid-connect-common/src/main/java/org/mitre/uma/repository/ResourceSetRepository.java b/openid-connect-common/src/main/java/org/mitre/uma/repository/ResourceSetRepository.java index 7c5a1cb73..f3aac1da2 100644 --- a/openid-connect-common/src/main/java/org/mitre/uma/repository/ResourceSetRepository.java +++ b/openid-connect-common/src/main/java/org/mitre/uma/repository/ResourceSetRepository.java @@ -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 getAllForOwner(String owner); + Collection getAllForOwner(String owner); - public Collection getAllForOwnerAndClient(String owner, String clientId); + Collection getAllForOwnerAndClient(String owner, String clientId); - public Collection getAll(); + Collection getAll(); - public Collection getAllForClient(String clientId); + Collection getAllForClient(String clientId); } diff --git a/openid-connect-common/src/main/java/org/mitre/uma/service/ClaimsProcessingService.java b/openid-connect-common/src/main/java/org/mitre/uma/service/ClaimsProcessingService.java index da88c4a7c..a8a18a71b 100644 --- a/openid-connect-common/src/main/java/org/mitre/uma/service/ClaimsProcessingService.java +++ b/openid-connect-common/src/main/java/org/mitre/uma/service/ClaimsProcessingService.java @@ -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); } diff --git a/openid-connect-common/src/main/java/org/mitre/uma/service/PermissionService.java b/openid-connect-common/src/main/java/org/mitre/uma/service/PermissionService.java index ab7ea2e3f..d79dc154a 100644 --- a/openid-connect-common/src/main/java/org/mitre/uma/service/PermissionService.java +++ b/openid-connect-common/src/main/java/org/mitre/uma/service/PermissionService.java @@ -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 scopes); + PermissionTicket createTicket(ResourceSet resourceSet, Set 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); } diff --git a/openid-connect-common/src/main/java/org/mitre/uma/service/ResourceSetService.java b/openid-connect-common/src/main/java/org/mitre/uma/service/ResourceSetService.java index 8da2ce017..ef76ce1cb 100644 --- a/openid-connect-common/src/main/java/org/mitre/uma/service/ResourceSetService.java +++ b/openid-connect-common/src/main/java/org/mitre/uma/service/ResourceSetService.java @@ -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 getAllForOwner(String owner); + Collection getAllForOwner(String owner); - public Collection getAllForOwnerAndClient(String owner, String authClientId); + Collection getAllForOwnerAndClient(String owner, String authClientId); - public Collection getAllForClient(ClientDetailsEntity client); + Collection getAllForClient(ClientDetailsEntity client); } diff --git a/openid-connect-common/src/main/java/org/mitre/uma/service/SavedRegisteredClientService.java b/openid-connect-common/src/main/java/org/mitre/uma/service/SavedRegisteredClientService.java index 4b8745c96..4509db9a5 100644 --- a/openid-connect-common/src/main/java/org/mitre/uma/service/SavedRegisteredClientService.java +++ b/openid-connect-common/src/main/java/org/mitre/uma/service/SavedRegisteredClientService.java @@ -23,7 +23,6 @@ import org.mitre.uma.model.SavedRegisteredClient; /** * @author jricher - * */ public interface SavedRegisteredClientService { diff --git a/openid-connect-common/src/main/java/org/mitre/uma/service/UmaTokenService.java b/openid-connect-common/src/main/java/org/mitre/uma/service/UmaTokenService.java index 8ee6c86b1..1cea187a9 100644 --- a/openid-connect-common/src/main/java/org/mitre/uma/service/UmaTokenService.java +++ b/openid-connect-common/src/main/java/org/mitre/uma/service/UmaTokenService.java @@ -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); } diff --git a/openid-connect-common/src/main/java/org/mitre/util/JsonUtils.java b/openid-connect-common/src/main/java/org/mitre/util/JsonUtils.java index b17f150be..be4e80e84 100644 --- a/openid-connect-common/src/main/java/org/mitre/util/JsonUtils.java +++ b/openid-connect-common/src/main/java/org/mitre/util/JsonUtils.java @@ -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: diff --git a/openid-connect-common/src/main/java/org/mitre/util/jpa/JpaUtil.java b/openid-connect-common/src/main/java/org/mitre/util/jpa/JpaUtil.java index f15e4c371..1a601ad86 100644 --- a/openid-connect-common/src/main/java/org/mitre/util/jpa/JpaUtil.java +++ b/openid-connect-common/src/main/java/org/mitre/util/jpa/JpaUtil.java @@ -30,6 +30,7 @@ import org.mitre.data.PageCriteria; * Time: 2:13 PM */ public class JpaUtil { + public static T getSingleResult(List 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 saveOrUpdate(I id, EntityManager entityManager, T entity) { + public static T saveOrUpdate(EntityManager entityManager, T entity) { T tmp = entityManager.merge(entity); entityManager.flush(); return tmp; } + } diff --git a/openid-connect-server/src/main/java/org/mitre/oauth2/repository/impl/JpaAuthenticationHolderRepository.java b/openid-connect-server/src/main/java/org/mitre/oauth2/repository/impl/JpaAuthenticationHolderRepository.java index 269db6217..7dcbef06d 100644 --- a/openid-connect-server/src/main/java/org/mitre/oauth2/repository/impl/JpaAuthenticationHolderRepository.java +++ b/openid-connect-server/src/main/java/org/mitre/oauth2/repository/impl/JpaAuthenticationHolderRepository.java @@ -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 diff --git a/openid-connect-server/src/main/java/org/mitre/oauth2/repository/impl/JpaAuthorizationCodeRepository.java b/openid-connect-server/src/main/java/org/mitre/oauth2/repository/impl/JpaAuthorizationCodeRepository.java index ad7788b6c..8209800d3 100644 --- a/openid-connect-server/src/main/java/org/mitre/oauth2/repository/impl/JpaAuthorizationCodeRepository.java +++ b/openid-connect-server/src/main/java/org/mitre/oauth2/repository/impl/JpaAuthorizationCodeRepository.java @@ -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); } diff --git a/openid-connect-server/src/main/java/org/mitre/oauth2/repository/impl/JpaDeviceCodeRepository.java b/openid-connect-server/src/main/java/org/mitre/oauth2/repository/impl/JpaDeviceCodeRepository.java index 65b1f03b2..50304adab 100644 --- a/openid-connect-server/src/main/java/org/mitre/oauth2/repository/impl/JpaDeviceCodeRepository.java +++ b/openid-connect-server/src/main/java/org/mitre/oauth2/repository/impl/JpaDeviceCodeRepository.java @@ -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) diff --git a/openid-connect-server/src/main/java/org/mitre/oauth2/repository/impl/JpaOAuth2ClientRepository.java b/openid-connect-server/src/main/java/org/mitre/oauth2/repository/impl/JpaOAuth2ClientRepository.java index 58c0bf196..7ac796d03 100644 --- a/openid-connect-server/src/main/java/org/mitre/oauth2/repository/impl/JpaOAuth2ClientRepository.java +++ b/openid-connect-server/src/main/java/org/mitre/oauth2/repository/impl/JpaOAuth2ClientRepository.java @@ -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 diff --git a/openid-connect-server/src/main/java/org/mitre/oauth2/repository/impl/JpaOAuth2TokenRepository.java b/openid-connect-server/src/main/java/org/mitre/oauth2/repository/impl/JpaOAuth2TokenRepository.java index 718a23357..627dbde27 100644 --- a/openid-connect-server/src/main/java/org/mitre/oauth2/repository/impl/JpaOAuth2TokenRepository.java +++ b/openid-connect-server/src/main/java/org/mitre/oauth2/repository/impl/JpaOAuth2TokenRepository.java @@ -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 diff --git a/openid-connect-server/src/main/java/org/mitre/oauth2/repository/impl/JpaSystemScopeRepository.java b/openid-connect-server/src/main/java/org/mitre/oauth2/repository/impl/JpaSystemScopeRepository.java index f646b5724..ca483cbed 100644 --- a/openid-connect-server/src/main/java/org/mitre/oauth2/repository/impl/JpaSystemScopeRepository.java +++ b/openid-connect-server/src/main/java/org/mitre/oauth2/repository/impl/JpaSystemScopeRepository.java @@ -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); } } diff --git a/openid-connect-server/src/main/java/org/mitre/openid/connect/repository/impl/JpaApprovedSiteRepository.java b/openid-connect-server/src/main/java/org/mitre/openid/connect/repository/impl/JpaApprovedSiteRepository.java index de30df513..fd8c34108 100644 --- a/openid-connect-server/src/main/java/org/mitre/openid/connect/repository/impl/JpaApprovedSiteRepository.java +++ b/openid-connect-server/src/main/java/org/mitre/openid/connect/repository/impl/JpaApprovedSiteRepository.java @@ -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 diff --git a/openid-connect-server/src/main/java/org/mitre/openid/connect/repository/impl/JpaBlacklistedSiteRepository.java b/openid-connect-server/src/main/java/org/mitre/openid/connect/repository/impl/JpaBlacklistedSiteRepository.java index b56a137c4..643bf9b8b 100644 --- a/openid-connect-server/src/main/java/org/mitre/openid/connect/repository/impl/JpaBlacklistedSiteRepository.java +++ b/openid-connect-server/src/main/java/org/mitre/openid/connect/repository/impl/JpaBlacklistedSiteRepository.java @@ -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); } diff --git a/openid-connect-server/src/main/java/org/mitre/openid/connect/repository/impl/JpaPairwiseIdentifierRepository.java b/openid-connect-server/src/main/java/org/mitre/openid/connect/repository/impl/JpaPairwiseIdentifierRepository.java index a92acf3bd..4289d51a7 100644 --- a/openid-connect-server/src/main/java/org/mitre/openid/connect/repository/impl/JpaPairwiseIdentifierRepository.java +++ b/openid-connect-server/src/main/java/org/mitre/openid/connect/repository/impl/JpaPairwiseIdentifierRepository.java @@ -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); } } diff --git a/openid-connect-server/src/main/java/org/mitre/openid/connect/repository/impl/JpaWhitelistedSiteRepository.java b/openid-connect-server/src/main/java/org/mitre/openid/connect/repository/impl/JpaWhitelistedSiteRepository.java index 98173588b..9f8e57c09 100644 --- a/openid-connect-server/src/main/java/org/mitre/openid/connect/repository/impl/JpaWhitelistedSiteRepository.java +++ b/openid-connect-server/src/main/java/org/mitre/openid/connect/repository/impl/JpaWhitelistedSiteRepository.java @@ -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 diff --git a/uma-server/src/main/java/org/mitre/uma/repository/impl/JpaPermissionRepository.java b/uma-server/src/main/java/org/mitre/uma/repository/impl/JpaPermissionRepository.java index 6f460d200..6d7a65d98 100644 --- a/uma-server/src/main/java/org/mitre/uma/repository/impl/JpaPermissionRepository.java +++ b/uma-server/src/main/java/org/mitre/uma/repository/impl/JpaPermissionRepository.java @@ -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) diff --git a/uma-server/src/main/java/org/mitre/uma/repository/impl/JpaResourceSetRepository.java b/uma-server/src/main/java/org/mitre/uma/repository/impl/JpaResourceSetRepository.java index e19236c39..7c41a989f 100644 --- a/uma-server/src/main/java/org/mitre/uma/repository/impl/JpaResourceSetRepository.java +++ b/uma-server/src/main/java/org/mitre/uma/repository/impl/JpaResourceSetRepository.java @@ -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