-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from privacyidea/v0.3
v0.3
- Loading branch information
Showing
11 changed files
with
753 additions
and
539 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
95 changes: 95 additions & 0 deletions
95
src/main/java/org/privacyidea/authenticator/Configuration.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,95 @@ | ||
package org.privacyidea.authenticator; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import static org.privacyidea.authenticator.Const.*; | ||
|
||
class Configuration { | ||
|
||
private String _serverURL; | ||
private String _realm; | ||
private boolean _doSSLVerify; | ||
private boolean _doTriggerChallenge; | ||
private String _serviceAccountName; | ||
private String _serviceAccountPass; | ||
private List<String> _excludedGroups = new ArrayList<>(); | ||
private boolean _doEnrollToken; | ||
private String _enrollingTokenType; | ||
private List<Integer> _pushtokenPollingInterval = new ArrayList<>(); | ||
|
||
Configuration(Map<String, String> configMap) { | ||
_serverURL = configMap.get(CONFIG_SERVER); | ||
_realm = configMap.get(CONFIG_REALM) == null ? "" : configMap.get(CONFIG_REALM); | ||
_doSSLVerify = configMap.get(CONFIG_VERIFYSSL) != null && configMap.get(CONFIG_VERIFYSSL).equals(TRUE); | ||
_doTriggerChallenge = configMap.get(CONFIG_DOTRIGGERCHALLENGE) != null && configMap.get(CONFIG_DOTRIGGERCHALLENGE).equals(TRUE); | ||
_serviceAccountName = configMap.get(CONFIG_SERVICEACCOUNT) == null ? "" : configMap.get(CONFIG_SERVICEACCOUNT); | ||
_serviceAccountPass = (configMap.get(CONFIG_SERVICEPASS) == null) ? "" : configMap.get(CONFIG_SERVICEPASS); | ||
_doEnrollToken = configMap.get(CONFIG_ENROLLTOKEN) != null && configMap.get(CONFIG_ENROLLTOKEN).equals(TRUE); | ||
_enrollingTokenType = configMap.get(CONFIG_ENROLLTOKENTYPE) == null ? "" : configMap.get(CONFIG_ENROLLTOKENTYPE); | ||
|
||
String excludedGroupsStr = configMap.get(CONFIG_EXCLUDEGROUPS); | ||
if (excludedGroupsStr != null) { | ||
_excludedGroups.addAll(Arrays.asList(excludedGroupsStr.split(","))); | ||
} | ||
|
||
// Set default, overwrite if configured | ||
_pushtokenPollingInterval.addAll(DEFAULT_POLLING_ARRAY); | ||
String s = configMap.get(CONFIG_PUSHTOKENINTERVAL); | ||
if (s != null) { | ||
List<String> strPollingIntervals = Arrays.asList(s.split(",")); | ||
if (!strPollingIntervals.isEmpty()) { | ||
_pushtokenPollingInterval.clear(); | ||
for (String str : strPollingIntervals) { | ||
try { | ||
_pushtokenPollingInterval.add(Integer.parseInt(str)); | ||
} catch (NumberFormatException e) { | ||
_pushtokenPollingInterval.add(DEFAULT_POLLING_INTERVAL); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
String getServerURL() { | ||
return _serverURL; | ||
} | ||
|
||
String getRealm() { | ||
return _realm; | ||
} | ||
|
||
boolean doSSLVerify() { | ||
return _doSSLVerify; | ||
} | ||
|
||
boolean doTriggerChallenge() { | ||
return _doTriggerChallenge; | ||
} | ||
|
||
String getServiceAccountName() { | ||
return _serviceAccountName; | ||
} | ||
|
||
String getServiceAccountPass() { | ||
return _serviceAccountPass; | ||
} | ||
|
||
List<String> getExcludedGroups() { | ||
return _excludedGroups; | ||
} | ||
|
||
boolean doEnrollToken() { | ||
return _doEnrollToken; | ||
} | ||
|
||
String getEnrollingTokenType() { | ||
return _enrollingTokenType; | ||
} | ||
|
||
List<Integer> getPushtokenPollingInterval() { | ||
return _pushtokenPollingInterval; | ||
} | ||
} |
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,81 @@ | ||
package org.privacyidea.authenticator; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
final class Const { | ||
private Const() { | ||
} | ||
|
||
static final String PROVIDER_ID = "privacyidea-authenticator"; | ||
|
||
static final String GET = "GET"; | ||
static final String POST = "POST"; | ||
static final String TRUE = "true"; | ||
|
||
static final String ENDPOINT_AUTH = "/auth"; | ||
static final String ENDPOINT_TOKEN_INIT = "/token/init"; | ||
static final String ENDPOINT_TRIGGERCHALLENGE = "/validate/triggerchallenge"; | ||
static final String ENDPOINT_TOKEN_CHALLENGES = "/token/challenges"; | ||
static final String ENDPOINT_VALIDATE_CHECK = "/validate/check"; | ||
static final String ENDPOINT_TOKEN = "/token"; | ||
|
||
static final String DEFAULT_PUSH_MESSAGE = "Please confirm the authentication on your mobile device"; | ||
static final String DEFAULT_OTP_MESSAGE = "Please enter the OTP"; | ||
|
||
static final int DEFAULT_POLLING_INTERVAL = 2; // Will be used if single value from config cannot be parsed | ||
static final List<Integer> DEFAULT_POLLING_ARRAY = Arrays.asList(5, 1, 1, 1, 2, 3); // Will be used if no intervals are specified | ||
|
||
static final String FORM_PUSHTOKEN_INTERVAL = "pushTokenInterval"; | ||
static final String FORM_TOKEN_ENROLLMENT_QR = "tokenEnrollmentQR"; | ||
static final String FORM_TOKENTYPE = "tokenType"; | ||
static final String FORM_PUSHTOKEN = "pushToken"; | ||
static final String FORM_OTPTOKEN = "otpToken"; | ||
static final String FORM_PUSH_MESSAGE = "pushMessage"; | ||
static final String FORM_OTP_MESSAGE = "otpMessage"; | ||
static final String FORM_FILE_NAME = "privacyIDEA.ftl"; | ||
static final String FORM_TOKENTYPE_CHANGED = "tokenTypeChanged"; | ||
static final String FORM_PI_OTP = "pi_otp"; | ||
|
||
static final String PARAM_KEY_USERNAME = "username"; | ||
static final String PARAM_KEY_USER = "user"; | ||
static final String PARAM_KEY_PASSWORD = "password"; | ||
static final String PARAM_KEY_PASS = "pass"; | ||
static final String PARAM_KEY_TYPE = "type"; | ||
static final String PARAM_KEY_GENKEY = "genkey"; | ||
static final String PARAM_KEY_TRANSACTION_ID = "transaction_id"; | ||
static final String PARAM_KEY_REALM = "realm"; | ||
|
||
static final String TOKEN_TYPE_PUSH = "push"; | ||
static final String TOKEN_TYPE_OTP = "otp"; // Classic OTPs like HOTP/TOTP | ||
|
||
static final String AUTH_NOTE_TRANSACTION_ID = "pi.transaction_id"; | ||
static final String AUTH_NOTE_AUTH_COUNTER = "authCounter"; | ||
|
||
static final String JSON_KEY_DETAIL = "detail"; | ||
static final String JSON_KEY_RESULT = "result"; | ||
static final String JSON_KEY_VALUE = "value"; | ||
static final String JSON_KEY_MESSAGE = "message"; | ||
static final String JSON_KEY_MULTI_CHALLENGE = "multi_challenge"; | ||
static final String JSON_KEY_TYPE = "type"; | ||
static final String JSON_KEY_TOKEN = "token"; | ||
static final String JSON_KEY_GOOGLEURL = "googleurl"; | ||
static final String JSON_KEY_IMG = "img"; | ||
static final String JSON_KEY_CHALLENGES = "challenges"; | ||
static final String JSON_KEY_OTP_VALID = "otp_valid"; | ||
static final String JSON_KEY_TRANSACTION_ID = "transaction_id"; | ||
static final String JSON_KEY_MESSAGES = "messages"; | ||
static final String JSON_KEY_TRANSACTION_IDS = "transaction_ids"; | ||
static final String JSON_KEY_TOKENS = "tokens"; | ||
|
||
static final String CONFIG_PUSHTOKENINTERVAL = "pipushtokeninterval"; | ||
static final String CONFIG_EXCLUDEGROUPS = "piexcludegroups"; | ||
static final String CONFIG_ENROLLTOKENTYPE = "pienrolltokentype"; | ||
static final String CONFIG_ENROLLTOKEN = "pienrolltoken"; | ||
static final String CONFIG_SERVICEPASS = "piservicepass"; | ||
static final String CONFIG_SERVICEACCOUNT = "piserviceaccount"; | ||
static final String CONFIG_DOTRIGGERCHALLENGE = "pidotriggerchallenge"; | ||
static final String CONFIG_VERIFYSSL = "piverifyssl"; | ||
static final String CONFIG_REALM = "pirealm"; | ||
static final String CONFIG_SERVER = "piserver"; | ||
} |
Oops, something went wrong.