gluu
公開メンバ関数 | 静的公開メンバ関数 | 静的変数 | 非公開変数類 | 静的非公開変数類 | 全メンバ一覧
org.gluu.credmanager.plugins.authnmethod.conf.OTPConfig クラス
org.gluu.credmanager.plugins.authnmethod.conf.OTPConfig の継承関係図
Inheritance graph
org.gluu.credmanager.plugins.authnmethod.conf.OTPConfig 連携図
Collaboration graph

公開メンバ関数

String getIssuer ()
 
HOTPConfig getHotp ()
 
TOTPConfig getTotp ()
 
void setIssuer (String issuer)
 
void setHotp (HOTPConfig hotp)
 
void setTotp (TOTPConfig totp)
 
void populate (Map< String, String > properties) throws Exception
 
String getFormattedQROptions (int maxWidth)
 
String getFormattedQROptions ()
 
String getLabel ()
 
void setLabel (String label)
 
int getQrSize ()
 
void setQrSize (int qrSize)
 
double getQrMSize ()
 
void setQrMSize (double qrMSize)
 
String getRegistrationUri ()
 
void setRegistrationUri (String registrationUri)
 

静的公開メンバ関数

static OTPConfig get (Map< String, String > propsMap)
 

静的変数

static ObjectMapper MAPPER = new ObjectMapper()
 

非公開変数類

String issuer
 
HOTPConfig hotp
 
TOTPConfig totp
 

静的非公開変数類

static Logger LOGGER = LoggerFactory.getLogger(OTPConfig.class)
 

詳解

POJO storing values needed for HOTP/TOTP. Static methods of this class parse information belonging to the OTP custom script to be able to get an instance of this class

著者
jgomer

関数詳解

◆ get()

static OTPConfig org.gluu.credmanager.plugins.authnmethod.conf.OTPConfig.get ( Map< String, String >  propsMap)
inlinestatic

Creates an OTPConfig object to hold all properties required for OTP key generation and QR code display

引数
propsMap
戻り値
null if an error or inconsistency is found while inspecting the configuration properties of the custom script. Otherwise returns an OTPConfig object
63  {
64 
65  OTPConfig config = new OTPConfig();
66  try {
67  config.populate(propsMap);
68  config.setIssuer(propsMap.get("issuer"));
69 
70  //Find the property of the script related to json file
71  String jsonFile = propsMap.get("otp_conf_file");
72 
73  if (Utils.isNotEmpty(jsonFile)) {
74  String contents = new String(Files.readAllBytes(Paths.get(jsonFile)), Charset.forName("utf-8"));
75  //Gluu Server 3.1.3 and earlier have a typo in default /etc/certs/otp_configuration.json, the following accommodates
76  contents = contents.replaceFirst("\"htop\"", "\"hotp\"");
77 
78  String json = MAPPER.readTree(contents).get("hotp").toString();
79  config.setHotp(MAPPER.readValue(json, new TypeReference<HOTPConfig>(){ }));
80 
81  json = MAPPER.readTree(contents).get("totp").toString();
82  config.setTotp(MAPPER.readValue(json, new TypeReference<TOTPConfig>(){ }));
83  } else {
84  LOGGER.error("Property 'otp_conf_file' not found");
85  config = null;
86  }
87  } catch (Exception e) {
88  LOGGER.error(e.getMessage(), e);
89  config = null;
90  }
91  return config;
92 
93  }
static ObjectMapper MAPPER
Definition: QRConfig.java:20
static Logger LOGGER
Definition: OTPConfig.java:27

◆ getFormattedQROptions() [1/2]

String org.gluu.credmanager.plugins.authnmethod.conf.QRConfig.getFormattedQROptions ( int  maxWidth)
inlineinherited

Creates a string for a Json representation of two values: size and mSize for QR code

戻り値
Json String
55  {
56 
57  List<String> list = new ArrayList<>();
58  int size = getQrSize();
59  int ival = maxWidth > 0 ? Math.min(size, maxWidth - 30) : size;
60 
61  if (ival > 0) {
62  list.add("size:" + ival);
63  }
64 
65  double dval = getQrMSize();
66  if (dval > 0) {
67  list.add("mSize: " + dval);
68  }
69 
70  return list.toString().replaceFirst("\\[", "{").replaceFirst("\\]", "}");
71 
72  }
double getQrMSize()
Definition: QRConfig.java:94
int getQrSize()
Definition: QRConfig.java:86

◆ getFormattedQROptions() [2/2]

String org.gluu.credmanager.plugins.authnmethod.conf.QRConfig.getFormattedQROptions ( )
inlineinherited
74  {
75  return getFormattedQROptions(0);
76  }
String getFormattedQROptions()
Definition: QRConfig.java:74

◆ getHotp()

HOTPConfig org.gluu.credmanager.plugins.authnmethod.conf.OTPConfig.getHotp ( )
inline
37  {
38  return hotp;
39  }
HOTPConfig hotp
Definition: OTPConfig.java:30

◆ getIssuer()

String org.gluu.credmanager.plugins.authnmethod.conf.OTPConfig.getIssuer ( )
inline
33  {
34  return issuer;
35  }
String issuer
Definition: OTPConfig.java:29

◆ getLabel()

String org.gluu.credmanager.plugins.authnmethod.conf.QRConfig.getLabel ( )
inlineinherited
78  {
79  return label;
80  }
String label
Definition: QRConfig.java:22

◆ getQrMSize()

double org.gluu.credmanager.plugins.authnmethod.conf.QRConfig.getQrMSize ( )
inlineinherited
94  {
95  return qrMSize;
96  }
double qrMSize
Definition: QRConfig.java:26

◆ getQrSize()

int org.gluu.credmanager.plugins.authnmethod.conf.QRConfig.getQrSize ( )
inlineinherited
86  {
87  return qrSize;
88  }

◆ getRegistrationUri()

String org.gluu.credmanager.plugins.authnmethod.conf.QRConfig.getRegistrationUri ( )
inlineinherited
102  {
103  return registrationUri;
104  }
String registrationUri
Definition: QRConfig.java:23

◆ getTotp()

TOTPConfig org.gluu.credmanager.plugins.authnmethod.conf.OTPConfig.getTotp ( )
inline
41  {
42  return totp;
43  }
TOTPConfig totp
Definition: OTPConfig.java:31

◆ populate()

void org.gluu.credmanager.plugins.authnmethod.conf.QRConfig.populate ( Map< String, String >  properties) throws Exception
inlineinherited
28  {
29 
30  setLabel(properties.get("label"));
31  setRegistrationUri(properties.get("registration_uri"));
32 
33  String value = properties.get("qr_options");
34  //value may come not properly formated (without quotes, for instance...)
35  if (!value.contains("\"")) {
36  value = value.replaceFirst("mSize", "\"mSize\"").replaceFirst("size", "\"size\"");
37  }
38 
39  JsonNode tree = MAPPER.readTree(value);
40 
41  if (tree.get("size") != null) {
42  setQrSize(tree.get("size").asInt());
43  }
44 
45  if (tree.get("mSize") != null) {
46  setQrMSize(tree.get("mSize").asDouble());
47  }
48 
49  }
void setRegistrationUri(String registrationUri)
Definition: QRConfig.java:106
static ObjectMapper MAPPER
Definition: QRConfig.java:20
void setLabel(String label)
Definition: QRConfig.java:82
void setQrSize(int qrSize)
Definition: QRConfig.java:90
void setQrMSize(double qrMSize)
Definition: QRConfig.java:98

◆ setHotp()

void org.gluu.credmanager.plugins.authnmethod.conf.OTPConfig.setHotp ( HOTPConfig  hotp)
inline
49  {
50  this.hotp = hotp;
51  }
HOTPConfig hotp
Definition: OTPConfig.java:30

◆ setIssuer()

void org.gluu.credmanager.plugins.authnmethod.conf.OTPConfig.setIssuer ( String  issuer)
inline
45  {
46  this.issuer = issuer;
47  }
String issuer
Definition: OTPConfig.java:29

◆ setLabel()

void org.gluu.credmanager.plugins.authnmethod.conf.QRConfig.setLabel ( String  label)
inlineinherited
82  {
83  this.label = label;
84  }
String label
Definition: QRConfig.java:22

◆ setQrMSize()

void org.gluu.credmanager.plugins.authnmethod.conf.QRConfig.setQrMSize ( double  qrMSize)
inlineinherited
98  {
99  this.qrMSize = qrMSize;
100  }
double qrMSize
Definition: QRConfig.java:26

◆ setQrSize()

void org.gluu.credmanager.plugins.authnmethod.conf.QRConfig.setQrSize ( int  qrSize)
inlineinherited
90  {
91  this.qrSize = qrSize;
92  }

◆ setRegistrationUri()

void org.gluu.credmanager.plugins.authnmethod.conf.QRConfig.setRegistrationUri ( String  registrationUri)
inlineinherited
106  {
108  }
String registrationUri
Definition: QRConfig.java:23

◆ setTotp()

void org.gluu.credmanager.plugins.authnmethod.conf.OTPConfig.setTotp ( TOTPConfig  totp)
inline
53  {
54  this.totp = totp;
55  }
TOTPConfig totp
Definition: OTPConfig.java:31

メンバ詳解

◆ hotp

HOTPConfig org.gluu.credmanager.plugins.authnmethod.conf.OTPConfig.hotp
private

◆ issuer

String org.gluu.credmanager.plugins.authnmethod.conf.OTPConfig.issuer
private

◆ LOGGER

Logger org.gluu.credmanager.plugins.authnmethod.conf.OTPConfig.LOGGER = LoggerFactory.getLogger(OTPConfig.class)
staticprivate

◆ MAPPER

ObjectMapper org.gluu.credmanager.plugins.authnmethod.conf.QRConfig.MAPPER = new ObjectMapper()
staticpackageinherited

◆ totp

TOTPConfig org.gluu.credmanager.plugins.authnmethod.conf.OTPConfig.totp
private

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