@Override public void setup(S store) { configureDefaultSupportedAccountTypes(store); }
private SecureRandom getSecureRandom() { renewSecureRandom(); return this.secureRandom; }
@Override public void setup(CredentialStore<?> store) { super.setup(store); String algorithm = getConfigurationProperty(store, ALGORITHM, DEFAULT_ALGORITHM); String intervalSeconds = getConfigurationProperty(store, INTERVAL_SECONDS, "" + DEFAULT_INTERVAL_SECONDS); String numberDigits = getConfigurationProperty(store, NUMBER_DIGITS, "" + DEFAULT_NUMBER_DIGITS); String delayWindow = getConfigurationProperty(store, DELAY_WINDOW, "" + DEFAULT_DELAY_WINDOW); this.totp = new TimeBasedOTP(algorithm, Integer.parseInt(numberDigits), Integer.valueOf(intervalSeconds), Integer.valueOf(delayWindow)); }
@Override public void validate(final IdentityContext context, final TOTPCredentials credentials, final CredentialStore<?> store) { super.validate(context, credentials, store); if (Status.VALID.equals(credentials.getStatus()) || Status.EXPIRED.equals(credentials.getStatus())) { if (!isValid(context, credentials, store)) { credentials.setStatus(Status.INVALID); credentials.setValidatedAccount(null); } } }
@Override public void update(IdentityContext context, Account account, TOTPCredential credential, CredentialStore<?> store, Date effectiveDate, Date expiryDate) { // if a credential was not provided, updates only the secret. if (credential.getValue() != null && credential.getValue().length > 0) { super.update(context, account, credential, store, effectiveDate, expiryDate); } OTPCredentialStorage storage = new OTPCredentialStorage(); if (effectiveDate != null) { storage.setEffectiveDate(effectiveDate); } storage.setExpiryDate(expiryDate); storage.setSecretKey(credential.getSecret()); storage.setDevice(getDevice(credential.getDevice())); store.storeCredential(context, account, storage); }
@Override protected CredentialStorage getCredentialStorage(IdentityContext context, Account account, V credentials, S store) { return store.retrieveCurrentCredential(context, account, getCredentialStorageType()); }
@Override protected Account getAccount(final IdentityContext context, final X509CertificateCredentials credentials) { return getAccount(context, credentials.getUsername()); }
@Override protected Account getAccount(final IdentityContext context, final V credentials) { return getAccount(context, credentials.getUsername()); }
private SecureRandom createSecureRandom() { try { return getSecureRandomProvider().getSecureRandom(); } catch (Exception e) { throw new IdentityManagementException("Error getting SecureRandom instance from provider [" + this.secureRandomProvider + "].", e); } }
@Override public void validateCredentials(IdentityContext context, Credentials credentials) { Class<? extends CredentialHandler> credentialHandler = getCredentialHandler(credentials); this.credentialHandlers.get(credentialHandler).validate(context, credentials, this); }
@Override public void validate(final IdentityContext context, final TOTPCredentials credentials, final CredentialStore<?> store) { super.validate(context, credentials, store); if (Status.VALID.equals(credentials.getStatus()) || Status.EXPIRED.equals(credentials.getStatus())) { if (!isValid(context, credentials, store)) { credentials.setStatus(Status.INVALID); credentials.setValidatedAccount(null); } } }
@Override public void setup(CredentialStore<?> store) { super.setup(store); String algorithm = getConfigurationProperty(store, ALGORITHM, DEFAULT_ALGORITHM); String intervalSeconds = getConfigurationProperty(store, INTERVAL_SECONDS, "" + DEFAULT_INTERVAL_SECONDS); String numberDigits = getConfigurationProperty(store, NUMBER_DIGITS, "" + DEFAULT_NUMBER_DIGITS); String delayWindow = getConfigurationProperty(store, DELAY_WINDOW, "" + DEFAULT_DELAY_WINDOW); this.totp = new TimeBasedOTP(algorithm, Integer.parseInt(numberDigits), Integer.valueOf(intervalSeconds), Integer.valueOf(delayWindow)); }
@Override public void update(IdentityContext context, Account account, TOTPCredential credential, CredentialStore<?> store, Date effectiveDate, Date expiryDate) { // if a credential was not provided, updates only the secret. if (credential.getValue() != null && credential.getValue().length > 0) { super.update(context, account, credential, store, effectiveDate, expiryDate); } OTPCredentialStorage storage = new OTPCredentialStorage(); if (effectiveDate != null) { storage.setEffectiveDate(effectiveDate); } storage.setExpiryDate(expiryDate); storage.setSecretKey(credential.getSecret()); storage.setDevice(getDevice(credential.getDevice())); store.storeCredential(context, account, storage); }
@Override protected CredentialStorage getCredentialStorage(IdentityContext context, Account account, V credentials, S store) { return store.retrieveCurrentCredential(context, account, getCredentialStorageType()); }
@Override public void setup(S store) { configureDefaultSupportedAccountTypes(store); }
private SecureRandom getSecureRandom() { renewSecureRandom(); return this.secureRandom; }
@Override protected Account getAccount(final IdentityContext context, final X509CertificateCredentials credentials) { return getAccount(context, credentials.getUsername()); }
@Override protected Account getAccount(final IdentityContext context, final V credentials) { return getAccount(context, credentials.getUsername()); }
private SecureRandom createSecureRandom() { try { return getSecureRandomProvider().getSecureRandom(); } catch (Exception e) { throw new IdentityManagementException("Error getting SecureRandom instance from provider [" + this.secureRandomProvider + "].", e); } }
protected TokenCredentialStorage createCredentialStorageInstance() { try { return Reflections.newInstance(getCredentialStorageType()); } catch (Exception e) { throw new IdentityManagementException("Could not create TokenStorageCredential [" + getCredentialStorageType() + "].", e); } }