keycloak
クラス | 公開メンバ関数 | 静的公開変数類 | 限定公開変数類 | 静的限定公開変数類 | 静的関数 | 静的非公開変数類 | 全メンバ一覧
org.keycloak.models.OTPPolicy クラス
org.keycloak.models.OTPPolicy の継承関係図
Inheritance graph
org.keycloak.models.OTPPolicy 連携図
Collaboration graph

クラス

class  FreeOTP
 
class  GoogleAuthenticator
 
interface  OtpApp
 

公開メンバ関数

 OTPPolicy ()
 
 OTPPolicy (String type, String algorithm, int initialCounter, int digits, int lookAheadWindow, int period)
 
String getAlgorithmKey ()
 
String getType ()
 
void setType (String type)
 
String getAlgorithm ()
 
void setAlgorithm (String algorithm)
 
int getInitialCounter ()
 
void setInitialCounter (int initialCounter)
 
int getDigits ()
 
void setDigits (int digits)
 
int getLookAheadWindow ()
 
void setLookAheadWindow (int lookAheadWindow)
 
int getPeriod ()
 
void setPeriod (int period)
 
String getKeyURI (RealmModel realm, UserModel user, String secret)
 
List< String > getSupportedApplications ()
 

静的公開変数類

static OTPPolicy DEFAULT_POLICY = new OTPPolicy(UserCredentialModel.TOTP, HmacOTP.HMAC_SHA1, 0, 6, 1, 30)
 

限定公開変数類

String type
 
String algorithm
 
int initialCounter
 
int digits
 
int lookAheadWindow
 
int period
 

静的限定公開変数類

static final Logger logger = Logger.getLogger(OTPPolicy.class)
 

静的関数

 [static initializer]
 

静的非公開変数類

static final Map< String, String > algToKeyUriAlg = new HashMap<>()
 
static final OtpApp [] allApplications = new OtpApp[] { new FreeOTP(), new GoogleAuthenticator() }
 

詳解

著者
Bill Burke
バージョン
Revision
1

構築子と解体子

◆ OTPPolicy() [1/2]

org.keycloak.models.OTPPolicy.OTPPolicy ( )
inline
57  {
58  }

◆ OTPPolicy() [2/2]

org.keycloak.models.OTPPolicy.OTPPolicy ( String  type,
String  algorithm,
int  initialCounter,
int  digits,
int  lookAheadWindow,
int  period 
)
inline
60  {
61  this.type = type;
62  this.algorithm = algorithm;
64  this.digits = digits;
66  this.period = period;
67  }
int initialCounter
Definition: OTPPolicy.java:42
int digits
Definition: OTPPolicy.java:43
int period
Definition: OTPPolicy.java:45
int lookAheadWindow
Definition: OTPPolicy.java:44
String algorithm
Definition: OTPPolicy.java:41
String type
Definition: OTPPolicy.java:40

関数詳解

◆ [static initializer]()

org.keycloak.models.OTPPolicy.[static initializer] ( )
inlinestaticpackage

◆ getAlgorithm()

String org.keycloak.models.OTPPolicy.getAlgorithm ( )
inline
83  {
84  return algorithm;
85  }
String algorithm
Definition: OTPPolicy.java:41

◆ getAlgorithmKey()

String org.keycloak.models.OTPPolicy.getAlgorithmKey ( )
inline
71  {
72  return algToKeyUriAlg.containsKey(algorithm) ? algToKeyUriAlg.get(algorithm) : algorithm;
73  }
String algorithm
Definition: OTPPolicy.java:41
static final Map< String, String > algToKeyUriAlg
Definition: OTPPolicy.java:47

◆ getDigits()

int org.keycloak.models.OTPPolicy.getDigits ( )
inline
99  {
100  return digits;
101  }
int digits
Definition: OTPPolicy.java:43

◆ getInitialCounter()

int org.keycloak.models.OTPPolicy.getInitialCounter ( )
inline
91  {
92  return initialCounter;
93  }
int initialCounter
Definition: OTPPolicy.java:42

◆ getKeyURI()

String org.keycloak.models.OTPPolicy.getKeyURI ( RealmModel  realm,
UserModel  user,
String  secret 
)
inline

Constructs the otpauth:// URI based on the Key-Uri-Format.

引数
realm
user
secret
戻り値
the otpauth:// URI
130  {
131 
132  try {
133 
134  String displayName = realm.getDisplayName() != null && !realm.getDisplayName().isEmpty() ? realm.getDisplayName() : realm.getName();
135 
136  String accountName = URLEncoder.encode(user.getUsername(), "UTF-8");
137  String issuerName = URLEncoder.encode(displayName, "UTF-8") .replaceAll("\\+", "%20");
138 
139  /*
140  * The issuerName component in the label is usually shown in a authenticator app, such as
141  * Google Authenticator or FreeOTP, as a hint for the user to which system an username
142  * belongs to.
143  */
144  String label = issuerName + ":" + accountName;
145 
146  String parameters = "secret=" + Base32.encode(secret.getBytes()) //
147  + "&digits=" + digits //
148  + "&algorithm=" + algToKeyUriAlg.get(algorithm) //
149  + "&issuer=" + issuerName;
150 
151  if (type.equals(UserCredentialModel.HOTP)) {
152  parameters += "&counter=" + initialCounter;
153  } else if (type.equals(UserCredentialModel.TOTP)) {
154  parameters += "&period=" + period;
155  }
156 
157  return "otpauth://" + type + "/" + label+ "?" + parameters;
158  } catch (UnsupportedEncodingException e) {
159  throw new RuntimeException(e);
160  }
161  }
int initialCounter
Definition: OTPPolicy.java:42
int digits
Definition: OTPPolicy.java:43
int period
Definition: OTPPolicy.java:45
String algorithm
Definition: OTPPolicy.java:41
static final Map< String, String > algToKeyUriAlg
Definition: OTPPolicy.java:47
String type
Definition: OTPPolicy.java:40

◆ getLookAheadWindow()

int org.keycloak.models.OTPPolicy.getLookAheadWindow ( )
inline
107  {
108  return lookAheadWindow;
109  }
int lookAheadWindow
Definition: OTPPolicy.java:44

◆ getPeriod()

int org.keycloak.models.OTPPolicy.getPeriod ( )
inline
115  {
116  return period;
117  }
int period
Definition: OTPPolicy.java:45

◆ getSupportedApplications()

List<String> org.keycloak.models.OTPPolicy.getSupportedApplications ( )
inline
163  {
164  List<String> applications = new LinkedList<>();
165  for (OtpApp a : allApplications) {
166  if (a.supports(this)) {
167  applications.add(a.getName());
168  }
169  }
170  return applications;
171  }
static final OtpApp [] allApplications
Definition: OTPPolicy.java:49

◆ getType()

String org.keycloak.models.OTPPolicy.getType ( )
inline
75  {
76  return type;
77  }
String type
Definition: OTPPolicy.java:40

◆ setAlgorithm()

void org.keycloak.models.OTPPolicy.setAlgorithm ( String  algorithm)
inline
87  {
88  this.algorithm = algorithm;
89  }
String algorithm
Definition: OTPPolicy.java:41

◆ setDigits()

void org.keycloak.models.OTPPolicy.setDigits ( int  digits)
inline
103  {
104  this.digits = digits;
105  }
int digits
Definition: OTPPolicy.java:43

◆ setInitialCounter()

void org.keycloak.models.OTPPolicy.setInitialCounter ( int  initialCounter)
inline
95  {
97  }
int initialCounter
Definition: OTPPolicy.java:42

◆ setLookAheadWindow()

void org.keycloak.models.OTPPolicy.setLookAheadWindow ( int  lookAheadWindow)
inline
111  {
113  }
int lookAheadWindow
Definition: OTPPolicy.java:44

◆ setPeriod()

void org.keycloak.models.OTPPolicy.setPeriod ( int  period)
inline
119  {
120  this.period = period;
121  }
int period
Definition: OTPPolicy.java:45

◆ setType()

void org.keycloak.models.OTPPolicy.setType ( String  type)
inline
79  {
80  this.type = type;
81  }
String type
Definition: OTPPolicy.java:40

メンバ詳解

◆ algorithm

String org.keycloak.models.OTPPolicy.algorithm
protected

◆ algToKeyUriAlg

final Map<String, String> org.keycloak.models.OTPPolicy.algToKeyUriAlg = new HashMap<>()
staticprivate

◆ allApplications

final OtpApp [] org.keycloak.models.OTPPolicy.allApplications = new OtpApp[] { new FreeOTP(), new GoogleAuthenticator() }
staticprivate

◆ DEFAULT_POLICY

OTPPolicy org.keycloak.models.OTPPolicy.DEFAULT_POLICY = new OTPPolicy(UserCredentialModel.TOTP, HmacOTP.HMAC_SHA1, 0, 6, 1, 30)
static

◆ digits

int org.keycloak.models.OTPPolicy.digits
protected

◆ initialCounter

int org.keycloak.models.OTPPolicy.initialCounter
protected

◆ logger

final Logger org.keycloak.models.OTPPolicy.logger = Logger.getLogger(OTPPolicy.class)
staticprotected

◆ lookAheadWindow

int org.keycloak.models.OTPPolicy.lookAheadWindow
protected

◆ period

int org.keycloak.models.OTPPolicy.period
protected

◆ type

String org.keycloak.models.OTPPolicy.type
protected

このクラス詳解は次のファイルから抽出されました: