Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KAA-25: Implement server profile update via REST API and Endpoint pro…
…file UI.
- Loading branch information
Showing
63 changed files
with
971 additions
and
1,033 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...mon/dao/src/main/java/org/kaaproject/kaa/server/common/dao/service/SdkTokenGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,44 @@ | |||
/* | |||
* Copyright 2014-2015 CyberVision, Inc. | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
* You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
* See the License for the specific language governing permissions and | |||
* limitations under the License. | |||
*/ | |||
|
|||
package org.kaaproject.kaa.server.common.dao.service; | |||
|
|||
import java.security.MessageDigest; | |||
import java.security.NoSuchAlgorithmException; | |||
|
|||
import org.apache.commons.codec.binary.Base64; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.kaaproject.kaa.common.dto.DtoByteMarshaller; | |||
import org.kaaproject.kaa.common.dto.admin.SdkProfileDto; | |||
|
|||
public class SdkTokenGenerator { | |||
|
|||
private static final String SDK_TOKEN_HASH_ALGORITHM = "SHA1"; | |||
|
|||
public static void generateSdkToken(SdkProfileDto sdkProfileDto) { | |||
if (StringUtils.isEmpty(sdkProfileDto.getToken())) { | |||
try { | |||
MessageDigest messageDigest = MessageDigest.getInstance(SDK_TOKEN_HASH_ALGORITHM); | |||
messageDigest.update(DtoByteMarshaller.toBytes(sdkProfileDto.toSdkTokenDto())); | |||
String token = Base64.encodeBase64String(messageDigest.digest()); | |||
sdkProfileDto.setToken(token); | |||
} catch (NoSuchAlgorithmException e) { | |||
throw new RuntimeException(e); | |||
} | |||
} | |||
} | |||
|
|||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.