Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KAA-244: Trustful verifier implementation
- Loading branch information
Showing
15 changed files
with
472 additions
and
22 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
server/common/utils/src/main/java/org/kaaproject/kaa/server/common/utils/CRC32Util.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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright 2014 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.utils; | ||
|
||
import java.nio.charset.Charset; | ||
import java.util.zip.CRC32; | ||
|
||
/** | ||
* | ||
* An util class that provides convenient methods to get crc32 checksum from {@link String} | ||
* | ||
* @author Andrew Shvayka | ||
* | ||
*/ | ||
public class CRC32Util { | ||
|
||
private static final Charset UTF8 = Charset.forName("UTF-8"); | ||
|
||
/** | ||
* Calculates the crc32 hash based on the name parameter. | ||
* | ||
* @param name | ||
* the name parameter | ||
* @return crc32 hash | ||
*/ | ||
public static int crc32(String name) { | ||
CRC32 crc32 = new CRC32(); | ||
crc32.update(name.getBytes(UTF8)); | ||
return (int) crc32.getValue(); | ||
} | ||
} |
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
11 changes: 11 additions & 0 deletions
11
...shared/src/main/java/org/kaaproject/kaa/server/common/verifier/UserVerifierErrorCode.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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.kaaproject.kaa.server.common.verifier; | ||
|
||
public enum UserVerifierErrorCode { | ||
NO_VERIFIER_CONFIGURED, | ||
TOKEN_INVALID, | ||
TOKEN_EXPIRED, | ||
INTERNAL_ERROR, | ||
CONNECTION_ERROR, | ||
REMOTE_ERROR, | ||
OTHER | ||
} |
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
58 changes: 58 additions & 0 deletions
58
...erations/service/akka/messages/core/user/verification/UserVerificationRequestMessage.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 | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,63 @@ | ||
/* | ||
* Copyright 2014 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.operations.service.akka.messages.core.user.verification; | ||
|
||
import akka.actor.ActorRef; | ||
|
||
public class UserVerificationRequestMessage { | ||
|
||
private final ActorRef originator; | ||
private final int verifierId; | ||
private final String userId; | ||
private final String accessToken; | ||
|
||
public UserVerificationRequestMessage(ActorRef originator, int verifierId, String userId, String accessToken) { | ||
super(); | ||
this.originator = originator; | ||
this.verifierId = verifierId; | ||
this.userId = userId; | ||
this.accessToken = accessToken; | ||
} | ||
|
||
public int getVerifierId() { | ||
return verifierId; | ||
} | ||
|
||
public String getUserId() { | ||
return userId; | ||
} | ||
|
||
public String getAccessToken() { | ||
return accessToken; | ||
} | ||
|
||
public ActorRef getOriginator() { | ||
return originator; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
StringBuilder builder = new StringBuilder(); | ||
builder.append("UserVerificationRequestMessage [verifierId="); | ||
builder.append(verifierId); | ||
builder.append(", userId="); | ||
builder.append(userId); | ||
builder.append(", accessToken="); | ||
builder.append(accessToken); | ||
builder.append("]"); | ||
return builder.toString(); | ||
} | ||
} |
Oops, something went wrong.