Search in sources :

Example 1 with Accessor

use of org.identityconnectors.common.security.GuardedString.Accessor in project midpoint by Evolveum.

the class DummyConnector method changePassword.

private void changePassword(final DummyAccount account, Attribute attr) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException {
    final String[] passwdArray = { null };
    if (attr.getValue() != null && !attr.getValue().isEmpty()) {
        Object passwdObject = attr.getValue().get(0);
        if (!(passwdObject instanceof GuardedString)) {
            throw new IllegalArgumentException("Password was provided as " + passwdObject.getClass().getName() + " while expecting GuardedString");
        }
        ((GuardedString) passwdObject).access(new Accessor() {

            @Override
            public void access(char[] passwdChars) {
                if (configuration.getMinPasswordLength() != null && passwdChars.length < configuration.getMinPasswordLength()) {
                    throw new InvalidAttributeValueException("Password too short");
                }
                passwdArray[0] = new String(passwdChars);
            }
        });
    } else {
    // empty password => null
    }
    account.setPassword(passwdArray[0]);
}
Also used : DummyObject(com.evolveum.icf.dummy.resource.DummyObject) GuardedString(org.identityconnectors.common.security.GuardedString) GuardedString(org.identityconnectors.common.security.GuardedString) Accessor(org.identityconnectors.common.security.GuardedString.Accessor) InvalidAttributeValueException(org.identityconnectors.framework.common.exceptions.InvalidAttributeValueException)

Aggregations

DummyObject (com.evolveum.icf.dummy.resource.DummyObject)1 GuardedString (org.identityconnectors.common.security.GuardedString)1 Accessor (org.identityconnectors.common.security.GuardedString.Accessor)1 InvalidAttributeValueException (org.identityconnectors.framework.common.exceptions.InvalidAttributeValueException)1