-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
442 additions
and
50 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
103 changes: 103 additions & 0 deletions
103
...ithub/dedis/popstellar/model/network/method/message/data/popcha/PoPCHAAuthentication.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,103 @@ | ||
package com.github.dedis.popstellar.model.network.method.message.data.popcha; | ||
|
||
import androidx.annotation.Nullable; | ||
import com.github.dedis.popstellar.model.Immutable; | ||
import com.github.dedis.popstellar.model.network.method.message.data.*; | ||
import com.google.gson.annotations.SerializedName; | ||
|
||
/** Data sent to authenticate to a PoPCHA server */ | ||
@Immutable | ||
public class PoPCHAAuthentication extends Data { | ||
|
||
@SerializedName("client_id") | ||
private final String clientId; | ||
|
||
private final String nonce; | ||
private final String identifier; | ||
|
||
@SerializedName("identifier_proof") | ||
private final String identifierProof; | ||
|
||
@Nullable private final String state; | ||
|
||
@Nullable | ||
@SerializedName("response_mode") | ||
private final String responseMode; | ||
|
||
@SerializedName("popcha_address") | ||
private final String popchaAddress; | ||
|
||
public PoPCHAAuthentication( | ||
String clientId, | ||
String nonce, | ||
String identifier, | ||
String identifierProof, | ||
@Nullable String state, | ||
@Nullable String responseMode, | ||
String popchaAddress) { | ||
this.clientId = clientId; | ||
this.nonce = nonce; | ||
this.identifier = identifier; | ||
this.identifierProof = identifierProof; | ||
this.state = state; | ||
this.responseMode = responseMode; | ||
this.popchaAddress = popchaAddress; | ||
} | ||
|
||
@Override | ||
public String getObject() { | ||
return Objects.POPCHA.getObject(); | ||
} | ||
|
||
@Override | ||
public String getAction() { | ||
return Action.AUTH.getAction(); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
PoPCHAAuthentication that = (PoPCHAAuthentication) o; | ||
return clientId.equals(that.clientId) | ||
&& nonce.equals(that.nonce) | ||
&& identifier.equals(that.identifier) | ||
&& identifierProof.equals(that.identifierProof) | ||
&& java.util.Objects.equals(state, that.state) | ||
&& java.util.Objects.equals(responseMode, that.responseMode) | ||
&& popchaAddress.equals(that.popchaAddress); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return java.util.Objects.hash( | ||
clientId, nonce, identifier, identifierProof, state, responseMode, popchaAddress); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "PoPCHAAuthentication{" | ||
+ "clientId='" | ||
+ clientId | ||
+ '\'' | ||
+ ", nonce='" | ||
+ nonce | ||
+ '\'' | ||
+ ", identifier='" | ||
+ identifier | ||
+ '\'' | ||
+ ", identifierProof='" | ||
+ identifierProof | ||
+ '\'' | ||
+ ", state='" | ||
+ state | ||
+ '\'' | ||
+ ", responseMode='" | ||
+ responseMode | ||
+ '\'' | ||
+ ", popchaAddress='" | ||
+ popchaAddress | ||
+ '\'' | ||
+ '}'; | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
fe2-android/app/src/main/java/com/github/dedis/popstellar/model/qrcode/PoPCHAQRCode.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,75 @@ | ||
package com.github.dedis.popstellar.model.qrcode; | ||
|
||
import android.net.Uri; | ||
import com.github.dedis.popstellar.model.Immutable; | ||
import com.github.dedis.popstellar.utility.MessageValidator; | ||
|
||
@Immutable | ||
public class PoPCHAQRCode { | ||
|
||
public static final String CLIENT_ID = "client_id"; | ||
public static final String NONCE = "nonce"; | ||
public static final String REDIRECT_URI = "redirect_uri"; | ||
public static final String STATE = "state"; | ||
public static final String RESPONSE_TYPE = "response_type"; | ||
public static final String RESPONSE_MODE = "response_mode"; | ||
public static final String LOGIN_HINT = "login_hint"; | ||
|
||
private final String clientId; | ||
private final String nonce; | ||
private final String state; | ||
private final String responseMode; | ||
private final String host; | ||
|
||
public PoPCHAQRCode(String data, String laoId) throws IllegalArgumentException { | ||
MessageValidator.verify().isValidPoPCHAUrl(data, laoId); | ||
|
||
Uri uri = Uri.parse(data); | ||
clientId = uri.getQueryParameter(CLIENT_ID); | ||
nonce = uri.getQueryParameter(NONCE); | ||
state = uri.getQueryParameter(STATE); | ||
responseMode = uri.getQueryParameter(RESPONSE_MODE); | ||
host = uri.getHost(); | ||
} | ||
|
||
public String getClientId() { | ||
return clientId; | ||
} | ||
|
||
public String getNonce() { | ||
return nonce; | ||
} | ||
|
||
public String getState() { | ||
return state; | ||
} | ||
|
||
public String getResponseMode() { | ||
return responseMode; | ||
} | ||
|
||
public String getHost() { | ||
return host; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "PoPCHAQRCode{" | ||
+ "clientId='" | ||
+ clientId | ||
+ '\'' | ||
+ ", nonce='" | ||
+ nonce | ||
+ '\'' | ||
+ ", state='" | ||
+ state | ||
+ '\'' | ||
+ ", responseMode='" | ||
+ responseMode | ||
+ '\'' | ||
+ ", host='" | ||
+ host | ||
+ '\'' | ||
+ '}'; | ||
} | ||
} |
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.