Skip to content

Commit

Permalink
KAA-876: Device management (#584)
Browse files Browse the repository at this point in the history
* KAA-876: Trustful credentials service implementation

* KAA-876: Fix the Admin UI

* KAA-876: Add the ability to change the credentials service used for an application

* KAA-876: Add aliases for credentials services

* KAA-876: Fix the application service to allow credentials service updates
  • Loading branch information
bkhablenko authored and ashvayka committed Apr 11, 2016
1 parent 3075ec5 commit 3f3fe1c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 12 deletions.
Expand Up @@ -57,6 +57,8 @@ public interface CredentialsService {
* @param credentialsId The credentials ID
*
* @return The credentials with the given ID
*
* @throws CredentialsServiceException - if an unexpected exception occures.
*/
Optional<CredentialsDto> lookupCredentials(String applicationId, String credentialsId) throws CredentialsServiceException;

Expand Down
Expand Up @@ -25,6 +25,7 @@
import static org.kaaproject.kaa.server.common.dao.service.Validator.isValidSqlObject;

import java.util.List;
import java.util.Objects;

import org.apache.commons.lang.RandomStringUtils;
import org.kaaproject.kaa.common.Constants;
Expand Down Expand Up @@ -162,7 +163,7 @@ public ApplicationDto saveApp(ApplicationDto applicationDto) {
throw new IncorrectParameterException("Can't save/update application with null name");
}
Application checkApplication = applicationDao.findByNameAndTenantId(applicationDto.getName(), applicationDto.getTenantId());
if (checkApplication != null) {
if (checkApplication != null && !Objects.equals(checkApplication.getStringId(), applicationDto.getId())) {
throw new IncorrectParameterException("Can't save application with same name within one tenant");
}
if (isNotBlank(applicationDto.getId())) {
Expand Down
2 changes: 2 additions & 0 deletions server/common/dao/src/main/resources/common-dao-context.xml
Expand Up @@ -95,7 +95,9 @@
<bean id="internalCredentialsService" class="org.kaaproject.kaa.server.common.dao.service.InternalCredentialsService">
<property name="credentialsDao" ref="credentialsDao"/>
</bean>
<alias name="internalCredentialsService" alias="Internal Credentials Service"/>

<bean id="trustfulCredentialsService" class="org.kaaproject.kaa.server.common.dao.service.TrustfulCredentialsService"/>
<alias name="trustfulCredentialsService" alias="Trustful Credentials Service"/>

</beans>
Expand Up @@ -95,11 +95,7 @@ public void onSuccess(List<String> result) {
ApplicationActivity.this.detailsView.getCredentialsServiceName().setAcceptableValues(result);
}
});
String serviceName = this.entity.getCredentialsServiceName();
if (!"".equals(serviceName) && serviceName != null) {
serviceNames.setValue(serviceName);
serviceNames.setEnabled(false);
}
serviceNames.setValue(this.entity.getCredentialsServiceName());
}
}

Expand Down
Expand Up @@ -16,10 +16,9 @@

package org.kaaproject.kaa.server.node.service.credentials;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import javax.annotation.Resource;

Expand Down Expand Up @@ -56,8 +55,8 @@ public final class DefaultCredentialsServiceLocator implements CredentialsServic
public CredentialsService getCredentialsService(String applicationId) {
String serviceName = this.applicationService.findAppById(applicationId).getCredentialsServiceName();
if (StringUtils.isBlank(serviceName)) {
LOG.debug("No credentials service configured for application [{}], using [{}]", applicationId, serviceName);
serviceName = DEFAULT_CREDENTIALS_SERVICE_NAME;
LOG.debug("No credentials service configured for application [{}], using [{}]", applicationId, serviceName);
}
CredentialsServiceLocator locator = credentialsServiceLocatorMap.get(serviceName);
if (locator == null) {
Expand All @@ -69,8 +68,6 @@ public CredentialsService getCredentialsService(String applicationId) {

@Override
public List<String> getCredentialsServiceNames() {
List<String> result = new ArrayList<>(credentialsServiceLocatorMap.keySet());
Collections.sort(result);
return result;
return this.credentialsServiceLocatorMap.keySet().stream().sorted().collect(Collectors.toList());
}
}

0 comments on commit 3f3fe1c

Please sign in to comment.