Commit fe423ef931a1b6a9dbaf92f6d45533779cbfa069

Authored by Chris Eykamp
2 parents f94aee19 ddb69646

Merge branch 'is_public'

@@ -56,11 +56,7 @@ public class CustomerController extends BaseController { @@ -56,11 +56,7 @@ public class CustomerController extends BaseController {
56 ObjectMapper objectMapper = new ObjectMapper(); 56 ObjectMapper objectMapper = new ObjectMapper();
57 ObjectNode infoObject = objectMapper.createObjectNode(); 57 ObjectNode infoObject = objectMapper.createObjectNode();
58 infoObject.put("title", customer.getTitle()); 58 infoObject.put("title", customer.getTitle());
59 - boolean isPublic = false;  
60 - if (customer.getAdditionalInfo() != null && customer.getAdditionalInfo().has("isPublic")) {  
61 - isPublic = customer.getAdditionalInfo().get("isPublic").asBoolean();  
62 - }  
63 - infoObject.put("isPublic", isPublic); 59 + infoObject.put("isPublic", customer.isPublic());
64 return infoObject; 60 return infoObject;
65 } catch (Exception e) { 61 } catch (Exception e) {
66 throw handleException(e); 62 throw handleException(e);
@@ -103,13 +103,11 @@ public class RefreshTokenAuthenticationProvider implements AuthenticationProvide @@ -103,13 +103,11 @@ public class RefreshTokenAuthenticationProvider implements AuthenticationProvide
103 if (publicCustomer == null) { 103 if (publicCustomer == null) {
104 throw new UsernameNotFoundException("Public entity not found by refresh token"); 104 throw new UsernameNotFoundException("Public entity not found by refresh token");
105 } 105 }
106 - boolean isPublic = false;  
107 - if (publicCustomer.getAdditionalInfo() != null && publicCustomer.getAdditionalInfo().has("isPublic")) {  
108 - isPublic = publicCustomer.getAdditionalInfo().get("isPublic").asBoolean();  
109 - }  
110 - if (!isPublic) { 106 +
  107 + if (!publicCustomer.isPublic()) {
111 throw new BadCredentialsException("Refresh token is not valid"); 108 throw new BadCredentialsException("Refresh token is not valid");
112 } 109 }
  110 +
113 User user = new User(new UserId(UUIDBased.EMPTY)); 111 User user = new User(new UserId(UUIDBased.EMPTY));
114 user.setTenantId(publicCustomer.getTenantId()); 112 user.setTenantId(publicCustomer.getTenantId());
115 user.setCustomerId(publicCustomer.getId()); 113 user.setCustomerId(publicCustomer.getId());
@@ -108,11 +108,7 @@ public class RestAuthenticationProvider implements AuthenticationProvider { @@ -108,11 +108,7 @@ public class RestAuthenticationProvider implements AuthenticationProvider {
108 if (publicCustomer == null) { 108 if (publicCustomer == null) {
109 throw new UsernameNotFoundException("Public entity not found: " + publicId); 109 throw new UsernameNotFoundException("Public entity not found: " + publicId);
110 } 110 }
111 - boolean isPublic = false;  
112 - if (publicCustomer.getAdditionalInfo() != null && publicCustomer.getAdditionalInfo().has("isPublic")) {  
113 - isPublic = publicCustomer.getAdditionalInfo().get("isPublic").asBoolean();  
114 - }  
115 - if (!isPublic) { 111 + if (!publicCustomer.isPublic()) {
116 throw new BadCredentialsException("Authentication Failed. Public Id is not valid."); 112 throw new BadCredentialsException("Authentication Failed. Public Id is not valid.");
117 } 113 }
118 User user = new User(new UserId(UUIDBased.EMPTY)); 114 User user = new User(new UserId(UUIDBased.EMPTY));
@@ -60,6 +60,14 @@ public class Customer extends ContactBased<CustomerId> implements HasName { @@ -60,6 +60,14 @@ public class Customer extends ContactBased<CustomerId> implements HasName {
60 public void setTitle(String title) { 60 public void setTitle(String title) {
61 this.title = title; 61 this.title = title;
62 } 62 }
  63 +
  64 + public boolean isPublic() {
  65 + if (getAdditionalInfo() != null && getAdditionalInfo().has("isPublic")) {
  66 + return getAdditionalInfo().get("isPublic").asBoolean();
  67 + }
  68 +
  69 + return false;
  70 + }
63 71
64 @Override 72 @Override
65 @JsonProperty(access = Access.READ_ONLY) 73 @JsonProperty(access = Access.READ_ONLY)