| | |
| | |
|
| | | /**
|
| | | * User certificate config section parser.
|
| | | * |
| | | *
|
| | | * @author James Moger
|
| | | */
|
| | | public class UserCertificateConfig {
|
| | | public static final SectionParser<UserCertificateConfig> KEY = new SectionParser<UserCertificateConfig>() {
|
| | | public UserCertificateConfig parse(final Config cfg) { |
| | | @Override
|
| | | public UserCertificateConfig parse(final Config cfg) {
|
| | | return new UserCertificateConfig(cfg);
|
| | | }
|
| | | };
|
| | | |
| | |
|
| | | public final List<UserCertificateModel> list;
|
| | |
|
| | | private UserCertificateConfig(final Config c) {
|
| | | SimpleDateFormat df = new SimpleDateFormat(Constants.ISO8601);
|
| | | list = new ArrayList<UserCertificateModel>(); |
| | | list = new ArrayList<UserCertificateModel>();
|
| | | for (String username : c.getSubsections("user")) {
|
| | | UserCertificateModel uc = new UserCertificateModel(new UserModel(username));
|
| | | try {
|
| | | uc.expires = df.parse(c.getString("user", username, "expires"));
|
| | | } catch (ParseException e) {
|
| | | LoggerFactory.getLogger(UserCertificateConfig.class).error("Failed to parse date!", e);
|
| | | } catch (NullPointerException e) { |
| | | } catch (NullPointerException e) {
|
| | | }
|
| | | uc.notes = c.getString("user", username, "notes");
|
| | | uc.revoked = new ArrayList<String>(Arrays.asList(c.getStringList("user", username, "revoked"))); |
| | | uc.revoked = new ArrayList<String>(Arrays.asList(c.getStringList("user", username, "revoked")));
|
| | | list.add(uc);
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | public UserCertificateModel getUserCertificateModel(String username) {
|
| | | for (UserCertificateModel ucm : list) {
|
| | | if (ucm.user.username.equalsIgnoreCase(username)) {
|