use of org.identityconnectors.common.security.GuardedString 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]);
}
use of org.identityconnectors.common.security.GuardedString in project syncope by apache.
the class DBPasswordPropagationActions method before.
@Transactional(readOnly = true)
@Override
public void before(final PropagationTask task, final ConnectorObject beforeObj) {
if (AnyTypeKind.USER == task.getAnyTypeKind()) {
User user = userDAO.find(task.getEntityKey());
if (user != null && user.getPassword() != null) {
Attribute missing = AttributeUtil.find(PropagationTaskExecutor.MANDATORY_MISSING_ATTR_NAME, task.getAttributes());
ConnInstance connInstance = task.getResource().getConnector();
if (missing != null && missing.getValue() != null && missing.getValue().size() == 1 && missing.getValue().get(0).equals(OperationalAttributes.PASSWORD_NAME) && cipherAlgorithmMatches(getCipherAlgorithm(connInstance), user.getCipherAlgorithm())) {
Attribute passwordAttribute = AttributeBuilder.buildPassword(new GuardedString(user.getPassword().toCharArray()));
Set<Attribute> attributes = new HashSet<>(task.getAttributes());
attributes.add(passwordAttribute);
attributes.remove(missing);
Attribute hashedPasswordAttribute = AttributeBuilder.build(AttributeUtil.createSpecialName("HASHED_PASSWORD"), Boolean.TRUE);
attributes.add(hashedPasswordAttribute);
task.setAttributes(attributes);
}
}
}
}
use of org.identityconnectors.common.security.GuardedString in project syncope by apache.
the class ConnIdBundleManagerImpl method initRemote.
private void initRemote(final URI location) {
// 1. Extract conf params for remote connection from given URI
String host = location.getHost();
int port = location.getPort();
GuardedString key = new GuardedString(location.getUserInfo().toCharArray());
boolean useSSL = location.getScheme().equals("connids");
List<TrustManager> trustManagers = new ArrayList<>();
String[] params = StringUtils.isBlank(location.getQuery()) ? null : location.getQuery().split("&");
if (params != null && params.length > 0) {
final String[] trustAllCerts = params[0].split("=");
if (trustAllCerts != null && trustAllCerts.length > 1 && "trustAllCerts".equalsIgnoreCase(trustAllCerts[0]) && "true".equalsIgnoreCase(trustAllCerts[1])) {
trustManagers.add(new X509TrustManager() {
@Override
public void checkClientTrusted(final X509Certificate[] chain, final String authType) throws CertificateException {
// no checks, trust all
}
@Override
public void checkServerTrusted(final X509Certificate[] chain, final String authType) throws CertificateException {
// no checks, trust all
}
@Override
public X509Certificate[] getAcceptedIssuers() {
return null;
}
});
}
}
LOG.debug("Configuring remote connector server:" + "\n\tHost: {}" + "\n\tPort: {}" + "\n\tKey: {}" + "\n\tUseSSL: {}" + "\n\tTrustAllCerts: {}", host, port, key, useSSL, !trustManagers.isEmpty());
RemoteFrameworkConnectionInfo info = new RemoteFrameworkConnectionInfo(host, port, key, useSSL, trustManagers, 60 * 1000);
LOG.debug("Remote connection info: {}", info);
// 2. Get connector info manager
ConnectorInfoManager manager = ConnectorInfoManagerFactory.getInstance().getRemoteManager(info);
if (manager == null) {
throw new NotFoundException("Remote ConnectorInfoManager");
}
connInfoManagers.put(location, manager);
}
use of org.identityconnectors.common.security.GuardedString in project midpoint by Evolveum.
the class DummyConnector method getFooConnectorObject.
private ConnectorObject getFooConnectorObject() {
ConnectorObjectBuilder builder = new ConnectorObjectBuilder();
builder.setUid("foo");
builder.addAttribute(Name.NAME, "foo");
builder.addAttribute(FAKE_ATTR_NAME, "fake foo");
GuardedString gs = new GuardedString("sup3rS3cr3tFak3".toCharArray());
builder.addAttribute(OperationalAttributes.PASSWORD_NAME, gs);
builder.addAttribute(OperationalAttributes.ENABLE_NAME, true);
return builder.build();
}
use of org.identityconnectors.common.security.GuardedString in project midpoint by Evolveum.
the class AbstractObjectDummyConnector method changePassword.
protected void changePassword(final DummyAccount account, GuardedString guardedString) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException {
String password = getString(guardedString);
checkPasswordPolicies(password);
account.setPassword(password);
}
Aggregations