Skip to content

Commit

Permalink
KAA-876: Remove the verify credentials flag from the SDK profile entity
Browse files Browse the repository at this point in the history
  • Loading branch information
Bohdan Khablenko committed Mar 31, 2016
1 parent 46d90f8 commit 4876e36
Show file tree
Hide file tree
Showing 14 changed files with 16 additions and 83 deletions.
6 changes: 3 additions & 3 deletions server/common/dao/pom.xml
Expand Up @@ -48,9 +48,9 @@
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
Expand Down
Expand Up @@ -364,7 +364,6 @@ public class DaoConstants {
public static final String SDK_PROFILE_PROFILE_SCHEMA_VERSION = "profile_schems_version";
public static final String SDK_PROFILE_TABLE_NAME = "sdk_token";
public static final String SDK_PROFILE_TOKEN = "token";
public static final String SDK_PROFILE_VERIFY_ENDPOINT_CREDENTIALS = "verify_endpoint_credentials";

/**
* CTL schems constants
Expand Down
Expand Up @@ -28,7 +28,6 @@
import static org.kaaproject.kaa.server.common.dao.DaoConstants.SDK_PROFILE_PROFILE_SCHEMA_VERSION;
import static org.kaaproject.kaa.server.common.dao.DaoConstants.SDK_PROFILE_TABLE_NAME;
import static org.kaaproject.kaa.server.common.dao.DaoConstants.SDK_PROFILE_TOKEN;
import static org.kaaproject.kaa.server.common.dao.DaoConstants.SDK_PROFILE_VERIFY_ENDPOINT_CREDENTIALS;

import java.io.Serializable;
import java.util.ArrayList;
Expand Down Expand Up @@ -86,9 +85,6 @@ public class SdkProfile extends GenericModel<SdkProfileDto> implements Serializa
@Column(name = SDK_PROFILE_ENDPOINT_COUNT)
private Integer endpointCount = 0;

@Column(name = SDK_PROFILE_VERIFY_ENDPOINT_CREDENTIALS)
private Boolean verifyEndpointCredentialsFlag = false;

public SdkProfile() {
}

Expand Down Expand Up @@ -135,8 +131,6 @@ public SdkProfile(SdkProfileDto dto) {
dto.getAefMapIds().add(id);
}
}

this.verifyEndpointCredentialsFlag = dto.getVerifyEndpointCredentialsFlag();
}
}

Expand Down Expand Up @@ -236,14 +230,6 @@ public void setEndpointCount(Integer endpointCount) {
this.endpointCount = endpointCount;
}

public Boolean getVerifyEndpointCredentialsFlag() {
return this.verifyEndpointCredentialsFlag;
}

public void setVerifyEndpointCredentialsFlag(Boolean verifyEndpointCredentialsFlag) {
this.verifyEndpointCredentialsFlag = verifyEndpointCredentialsFlag;
}

@Override
protected SdkProfileDto createDto() {
return new SdkProfileDto();
Expand Down Expand Up @@ -284,8 +270,6 @@ public SdkProfileDto toDto() {
dto.setCreatedTime(this.createdTime);
dto.setEndpointCount(this.endpointCount);

dto.setVerifyEndpointCredentialsFlag(this.verifyEndpointCredentialsFlag);

return dto;
}

Expand Down Expand Up @@ -333,9 +317,6 @@ public boolean equals(Object o) {
if (createdTime != null ? !createdTime.equals(other.createdTime) : other.createdTime != null) {
return false;
}
if (verifyEndpointCredentialsFlag != null ? !verifyEndpointCredentialsFlag.equals(other.verifyEndpointCredentialsFlag) : other.verifyEndpointCredentialsFlag != null) {
return false;
}


return true;
Expand All @@ -354,7 +335,6 @@ public int hashCode() {
result = 31 * result + (defaultVerifierToken != null ? defaultVerifierToken.hashCode() : 0);
result = 31 * result + (createdUsername != null ? createdUsername.hashCode() : 0);
result = 31 * result + (createdTime != null ? createdTime.hashCode() : 0);
result = 31 * result + (verifyEndpointCredentialsFlag != null ? verifyEndpointCredentialsFlag.hashCode() : 0);

return result;
}
Expand All @@ -374,7 +354,6 @@ public String toString() {
", createdUsername=" + createdUsername +
", createdTime=" + createdTime +
", endpointCount=" + endpointCount +
", verifyEndpointCredentialsFlag=" + verifyEndpointCredentialsFlag +
'}';
}
}
Expand Up @@ -60,7 +60,7 @@ public void constructorTest() {
private SdkProfileDto generateSdkProfileDto(String appId, String appToken) {
List<String> aefMapIdsList = new ArrayList<>(Arrays.asList("firstId", "secondId", "thirdId"));
SdkProfileDto sdkProfileDto = new SdkProfileDto(appId, 2, 3, 4, 5, aefMapIdsList, "someVerifierToken", appToken,
"devuser", 100000L, "someName", false);
"devuser", 100000L, "someName");
SdkTokenGenerator.generateSdkToken(sdkProfileDto);
return sdkProfileDto;
}
Expand All @@ -72,7 +72,7 @@ private SdkProfileDto generateSdkProfileDto(String appId, String appToken) {
public void testForURLSafeToken() {
List<String> aefMapIdsList = Collections.singletonList("290");
SdkProfileDto sdkProfileDto = new SdkProfileDto("113", 1, 0, 1, 1, aefMapIdsList,
"someVerifierToken", "15643220456970528206", "devuser", 100000L, "", false);
"someVerifierToken", "15643220456970528206", "devuser", 100000L, "");
SdkTokenGenerator.generateSdkToken(sdkProfileDto);
Assert.assertFalse(sdkProfileDto.getToken().contains("/"));
}
Expand Down
Expand Up @@ -30,7 +30,6 @@ public class SdkProfileDto extends SdkTokenDto implements HasId {
private String createdUsername;
private Long createdTime;
private Integer endpointCount = 0;
private Boolean verifyEndpointCredentialsFlag = false;

public SdkProfileDto() {
super();
Expand All @@ -41,7 +40,7 @@ public SdkProfileDto(String applicationId, Integer configurationSchemaVersion,
Integer logSchemaVersion,
List<String> aefMapIds,
String defaultVerifierToken, String applicationToken,
String createdUsername, Long createdTime, String name, Boolean verifyEndpointCredentialsFlag) {
String createdUsername, Long createdTime, String name) {
super(configurationSchemaVersion,
profileSchemaVersion,
notificationSchemaVersion,
Expand All @@ -52,7 +51,6 @@ public SdkProfileDto(String applicationId, Integer configurationSchemaVersion,
this.applicationId = applicationId;
this.createdUsername = createdUsername;
this.createdTime = createdTime;
this.verifyEndpointCredentialsFlag = verifyEndpointCredentialsFlag;
}

public String getApplicationId() {
Expand Down Expand Up @@ -94,14 +92,6 @@ public Integer getEndpointCount() {
public void setEndpointCount(Integer endpointCount) {
this.endpointCount = endpointCount;
}

public Boolean getVerifyEndpointCredentialsFlag() {
return this.verifyEndpointCredentialsFlag;
}

public void setVerifyEndpointCredentialsFlag(Boolean verifyEndpointCredentialsFlag) {
this.verifyEndpointCredentialsFlag = verifyEndpointCredentialsFlag;
}

@Override
public String getId() {
Expand Down Expand Up @@ -138,7 +128,6 @@ public int hashCode() {
+ ((endpointCount == null) ? 0 : endpointCount.hashCode());
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((token == null) ? 0 : token.hashCode());
result = prime * result + ((verifyEndpointCredentialsFlag == null) ? 0 : verifyEndpointCredentialsFlag.hashCode());
return result;
}

Expand Down Expand Up @@ -196,13 +185,6 @@ public boolean equals(Object obj) {
} else if (!token.equals(other.token)) {
return false;
}
if (verifyEndpointCredentialsFlag == null) {
if (other.verifyEndpointCredentialsFlag != null) {
return false;
}
} else if (!verifyEndpointCredentialsFlag.equals(other.verifyEndpointCredentialsFlag)) {
return false;
}
return true;
}

Expand All @@ -221,8 +203,6 @@ public String toString() {
builder.append(createdTime);
builder.append(", endpointCount=");
builder.append(endpointCount);
builder.append(", verifyEndpointCredentialsFlag=");
builder.append(verifyEndpointCredentialsFlag);
builder.append("]");
return builder.toString();
}
Expand Down
Expand Up @@ -116,8 +116,6 @@ private void onInfoRetrieved(SchemaVersions schemaVersions,
List<AefMapInfoDto> aefMaps,
List<UserVerifierDto> userVerifiers) {

detailsView.getVerifyEndpointCredentialsFlag().setValue(false);

List<VersionDto> confSchemaVersions = schemaVersions.getConfigurationSchemaVersions();
detailsView.getConfigurationSchemaVersion().setValue(getMaxSchemaVersions(confSchemaVersions));
detailsView.getConfigurationSchemaVersion().setAcceptableValues(confSchemaVersions);
Expand All @@ -143,9 +141,6 @@ private void onInfoRetrieved(SchemaVersions schemaVersions,
protected void onSave() {
entity.setName(detailsView.getName().getValue());

boolean verifyEndpointCredentialsFlag = detailsView.getVerifyEndpointCredentialsFlag().getValue();
entity.setVerifyEndpointCredentialsFlag(verifyEndpointCredentialsFlag);

entity.setConfigurationSchemaVersion(detailsView.getConfigurationSchemaVersion().
getValue().getVersion());
entity.setProfileSchemaVersion(detailsView.getProfileSchemaVersion().
Expand Down
Expand Up @@ -23,15 +23,13 @@
import org.kaaproject.kaa.common.dto.user.UserVerifierDto;
import org.kaaproject.kaa.server.admin.client.mvp.view.widget.MultiValueListBox;

import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.HasValue;
import com.google.gwt.user.client.ui.ValueListBox;

public interface AddSdkProfileView extends BaseDetailsView {

HasValue<String> getName();

CheckBox getVerifyEndpointCredentialsFlag();
ValueListBox<VersionDto> getConfigurationSchemaVersion();
ValueListBox<VersionDto> getProfileSchemaVersion();
ValueListBox<VersionDto> getNotificationSchemaVersion();
Expand Down
Expand Up @@ -42,7 +42,6 @@
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.text.shared.Renderer;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.DisclosurePanel;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
Expand All @@ -59,7 +58,6 @@ public class AddSdkProfileViewImpl extends BaseDetailsViewImpl implements AddSdk

private SizedTextBox name;

private CheckBox verifyEndpointCredentialsFlag;
private VersionListBox configurationSchemaVersion;
private VersionListBox profileSchemaVersion;
private VersionListBox notificationSchemaVersion;
Expand Down Expand Up @@ -95,18 +93,6 @@ protected void initDetailsTable() {
detailsTable.setWidget(row, 0, label);
detailsTable.setWidget(row, 1, name);

row++;
label = new Label(Utils.constants.verifyEndpointCredentials());
verifyEndpointCredentialsFlag = new CheckBox();
verifyEndpointCredentialsFlag.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
fireChanged();
}
});
detailsTable.setWidget(row, 0, label);
detailsTable.setWidget(row, 1, verifyEndpointCredentialsFlag);

row++;
label = new Label(Utils.constants.configurationSchemaVersion());
label.addStyleName(REQUIRED);
Expand Down Expand Up @@ -271,11 +257,6 @@ public HasValue<String> getName() {
return name;
}

@Override
public CheckBox getVerifyEndpointCredentialsFlag() {
return verifyEndpointCredentialsFlag;
}

@Override
public ValueListBox<VersionDto> getConfigurationSchemaVersion() {
return configurationSchemaVersion;
Expand Down Expand Up @@ -317,7 +298,6 @@ public void setAefMaps(List<AefMapInfoDto> aefMaps) {
@Override
protected void resetImpl() {
name.setValue("");
verifyEndpointCredentialsFlag.setValue(false);
configurationSchemaVersion.reset();
profileSchemaVersion.reset();
notificationSchemaVersion.reset();
Expand Down
Expand Up @@ -2140,8 +2140,8 @@ public CredentialsDto provideCredentials(
public void provideRegistration(
@RequestParam String applicationId,
@RequestParam String credentialsId,
@RequestParam(required = false) Integer serverProfileVersion,
@RequestParam(required = false) String serverProfileBody)
@RequestParam Integer serverProfileVersion,
@RequestParam String serverProfileBody)
throws KaaAdminServiceException {
this.kaaAdminService.provideRegistration(applicationId, credentialsId, serverProfileVersion, serverProfileBody);
}
Expand Down
Expand Up @@ -82,6 +82,7 @@
import org.kaaproject.kaa.common.dto.admin.SdkProfileViewDto;
import org.kaaproject.kaa.common.dto.admin.TenantUserDto;
import org.kaaproject.kaa.common.dto.credentials.CredentialsDto;
import org.kaaproject.kaa.common.dto.credentials.CredentialsStatus;
import org.kaaproject.kaa.common.dto.ctl.CTLSchemaDto;
import org.kaaproject.kaa.common.dto.ctl.CTLSchemaExportMethod;
import org.kaaproject.kaa.common.dto.ctl.CTLSchemaMetaInfoDto;
Expand Down Expand Up @@ -3621,7 +3622,9 @@ public void provideRegistration(
this.checkAuthority(KaaAuthorityDto.TENANT_DEVELOPER, KaaAuthorityDto.TENANT_USER);
try {
this.checkApplicationId(applicationId);
Validate.isTrue(this.controlService.getCredentials(applicationId, credentialsId) != null, "No credentials with the given ID found!");
CredentialsDto credentials = this.controlService.getCredentials(applicationId, credentialsId);
Validate.isTrue(credentials != null, "No credentials with the given ID found!");
Validate.isTrue(credentials.getStatus() != CredentialsStatus.REVOKED, "The credentials with the given ID are revoked!");
if (serverProfileVersion != null && serverProfileBody != null) {
ServerProfileSchemaDto serverProfileSchema = this.getServerProfileSchema(applicationId, serverProfileVersion);
this.validateServerProfile(serverProfileSchema, serverProfileBody);
Expand Down
Expand Up @@ -63,7 +63,6 @@
import org.kaaproject.kaa.common.dto.logs.LogAppenderDto;
import org.kaaproject.kaa.common.dto.logs.LogSchemaDto;
import org.kaaproject.kaa.common.dto.user.UserVerifierDto;
import org.kaaproject.kaa.server.admin.shared.services.KaaAdminServiceException;
import org.kaaproject.kaa.server.control.service.exception.ControlServiceException;

/**
Expand Down Expand Up @@ -1738,7 +1737,7 @@ ApplicationEventFamilyMapDto editApplicationEventFamilyMap(ApplicationEventFamil
* @param serverProfileVersion The server-side endpoint profile version
* @param serverProfileBody The server-side endpoint profile body
*
* @throws KaaAdminServiceException - if an exception occures.
* @throws ControlServiceException - if an exception occures.
*/
void provideRegistration(String applicationId, String credentialsId, Integer serverProfileVersion, String serverProfileBody) throws ControlServiceException;
}
Expand Up @@ -288,6 +288,6 @@ private SdkProfileDto getSdkProfile(String appId,

return client.createSdkProfile(new SdkProfileDto(appId, configSchemaVersion, profileSchemaVersion,
notificationSchemaVersion, logSchemaVersion, aefMapIds, defaultVerifierToken, null,
"devuser", 100000L, "someName", false));
"devuser", 100000L, "someName"));
}
}
Expand Up @@ -133,7 +133,7 @@ public class OperationsServiceIT extends AbstractTest {
private static final byte[] ENDPOINT_KEY = getRandEndpointKey();
private static final byte[] ENDPOINT_KEY2 = getRandEndpointKey();
private static final SdkProfileDto SDK_PROFILE = new SdkProfileDto(null, CONF_SCHEMA_VERSION,
PROFILE_SCHEMA_VERSION, 1, 1, null, null, null, null, null, null, null);
PROFILE_SCHEMA_VERSION, 1, 1, null, null, null, null, null, null);
private String SDK_TOKEN;

public static final String NEW_COMPLEX_CONFIG = "operations/service/delta/complexFieldsDeltaNew.json";
Expand Down
Expand Up @@ -75,7 +75,7 @@ public void testPopulateVersionStates() {
EndpointProfileDto dtoMock = Mockito.mock(EndpointProfileDto.class);

SdkProfileDto sdkProperties = new SdkProfileDto(null, 1, 2, 3, 4, Collections.EMPTY_LIST, null, null,
null, null, null, null);
null, null, null);

ApplicationEventFamilyMapDto applicationEventFamilyMap = new ApplicationEventFamilyMapDto();
applicationEventFamilyMap.setVersion(7);
Expand Down

0 comments on commit 4876e36

Please sign in to comment.