Prevent some potential NPEs if null set is set on various fields for an OAuth Client
package org.apache.cxf.rs.security.oauth2.common;
import java.io.Serializable;
+import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
@@ -223,7 +224,7 @@ public class Client implements Serializable {
* @param redirectUris the redirect uris
*/
public void setRedirectUris(List<String> redirectUris) {
- this.redirectUris = redirectUris;
+ this.redirectUris = redirectUris != null ? redirectUris : Collections.emptyList();
}
/**
@@ -243,7 +244,7 @@ public class Client implements Serializable {
* @param allowedGrantTypes the list of grant types
*/
public void setAllowedGrantTypes(List<String> allowedGrantTypes) {
- this.allowedGrantTypes = allowedGrantTypes;
+ this.allowedGrantTypes = allowedGrantTypes != null ? allowedGrantTypes : Collections.emptyList();
}
/**
@@ -328,7 +329,7 @@ public class Client implements Serializable {
* @param registeredScopes the scopes
*/
public void setRegisteredScopes(List<String> registeredScopes) {
- this.registeredScopes = registeredScopes;
+ this.registeredScopes = registeredScopes != null ? registeredScopes : Collections.emptyList();
}
@ElementCollection(fetch = FetchType.EAGER)
@@ -342,7 +343,7 @@ public class Client implements Serializable {
* @param registeredAudiences audiences
*/
public void setRegisteredAudiences(List<String> registeredAudiences) {
- this.registeredAudiences = registeredAudiences;
+ this.registeredAudiences = registeredAudiences != null ? registeredAudiences : Collections.emptyList();
}
@ElementCollection(fetch = FetchType.EAGER)
@@ -358,7 +359,8 @@ public class Client implements Serializable {
* Basic or other password-aware authentication on top of 2-way TLS.
*/
public void setApplicationCertificates(List<String> applicationCertificates) {
- this.applicationCertificates = applicationCertificates;
+ this.applicationCertificates = applicationCertificates != null
+ ? applicationCertificates : Collections.emptyList();
}
public String getClientIpAddress() {
