@Test public void testReturnUidOnly() { String user = "TESTUSER"; GuardedString password = new GuardedString("TEST".toCharArray()); Attribute authentication = AttributeBuilder.build(OracleConstants.ORACLE_AUTHENTICATION_ATTR_NAME, OracleConstants.ORACLE_AUTH_LOCAL); Attribute name = new Name(user); Attribute passwordAttribute = AttributeBuilder.buildPassword(password); Attribute privileges = AttributeBuilder.build(OracleConstants.ORACLE_PRIVS_ATTR_NAME, "CREATE SESSION"); try { facade.delete(ObjectClass.ACCOUNT, new Uid(user), null); } catch (UnknownUidException e) { } Uid uid = facade.create(ObjectClass.ACCOUNT, CollectionUtil.newSet(authentication, name, passwordAttribute, privileges), null); Uid aUid = facade.authenticate(ObjectClass.ACCOUNT, user, password, null); AssertJUnit.assertEquals( "Uid returned from authenticate must be same as returned from create ", uid, aUid); GuardedString badPassword = new GuardedString("badPassword".toCharArray()); try { facade.authenticate(ObjectClass.ACCOUNT, user, badPassword, null); Assert.fail("Must fail for bad password"); } catch (ConnectorException e) { } OperationOptions options = new OperationOptionsBuilder().setOption("returnUidOnly", Boolean.TRUE).build(); Uid aUid2 = facade.authenticate(ObjectClass.ACCOUNT, user, badPassword, options); AssertJUnit.assertEquals( "Uid returned from authenticate must be same as returned from create ", uid, aUid2); String invalidUser = "TESTUSER2"; try { facade.delete(ObjectClass.ACCOUNT, new Uid(invalidUser), null); } catch (UnknownUidException e) { } try { facade.authenticate(ObjectClass.ACCOUNT, invalidUser, password, options); Assert.fail("Authenticate with returnUidOnly must fail for not existing user"); } catch (InvalidCredentialException e) { } facade.delete(ObjectClass.ACCOUNT, uid, null); }
public Uid authenticate(ObjectClass objectClass, String username, GuardedString password, OperationOptions options) { OracleConnectorHelper.checkObjectClass(objectClass, cfg.getConnectorMessages()); new LocalizedAssert(cfg.getConnectorMessages()).assertNotBlank(username, "username"); new LocalizedAssert(cfg.getConnectorMessages()).assertNotNull(password, "password"); if (options != null && Boolean.TRUE.equals(options.getOptions().get("returnUidOnly"))) { return findUserByName(username); } LOG.info("Authenticate user: [{0}]", username); if (cfg.isUseDriverForAuthentication()) { doDriverAuthenticate(username, password); } else { doCfgAuthenticate(username, password); } LOG.info("User authenticated : [{0}]", username); return new Uid(username); }
OracleOperationAuthenticate extends AbstractOracleOperation implements AuthenticateOp { public Uid authenticate(ObjectClass objectClass, String username, GuardedString password, OperationOptions options) { OracleConnectorHelper.checkObjectClass(objectClass, cfg.getConnectorMessages()); new LocalizedAssert(cfg.getConnectorMessages()).assertNotBlank(username, "username"); new LocalizedAssert(cfg.getConnectorMessages()).assertNotNull(password, "password"); if (options != null && Boolean.TRUE.equals(options.getOptions().get("returnUidOnly"))) { return findUserByName(username); } LOG.info("Authenticate user: [{0}]", username); if (cfg.isUseDriverForAuthentication()) { doDriverAuthenticate(username, password); } else { doCfgAuthenticate(username, password); } LOG.info("User authenticated : [{0}]", username); return new Uid(username); } }
OracleOperationAuthenticate extends AbstractOracleOperation implements AuthenticateOp { public Uid authenticate(ObjectClass objectClass, String username, GuardedString password, OperationOptions options) { OracleConnectorHelper.checkObjectClass(objectClass, cfg.getConnectorMessages()); new LocalizedAssert(cfg.getConnectorMessages()).assertNotBlank(username, "username"); new LocalizedAssert(cfg.getConnectorMessages()).assertNotNull(password, "password"); if (options != null && Boolean.TRUE.equals(options.getOptions().get("returnUidOnly"))) { return findUserByName(username); } LOG.info("Authenticate user: [{0}]", username); if (cfg.isUseDriverForAuthentication()) { doDriverAuthenticate(username, password); } else { doCfgAuthenticate(username, password); } LOG.info("User authenticated : [{0}]", username); return new Uid(username); } OracleOperationAuthenticate(OracleConfiguration cfg, Connection adminConn); }
OracleOperationAuthenticate extends AbstractOracleOperation implements AuthenticateOp { public Uid authenticate(ObjectClass objectClass, String username, GuardedString password, OperationOptions options) { OracleConnectorHelper.checkObjectClass(objectClass, cfg.getConnectorMessages()); new LocalizedAssert(cfg.getConnectorMessages()).assertNotBlank(username, "username"); new LocalizedAssert(cfg.getConnectorMessages()).assertNotNull(password, "password"); if (options != null && Boolean.TRUE.equals(options.getOptions().get("returnUidOnly"))) { return findUserByName(username); } LOG.info("Authenticate user: [{0}]", username); if (cfg.isUseDriverForAuthentication()) { doDriverAuthenticate(username, password); } else { doCfgAuthenticate(username, password); } LOG.info("User authenticated : [{0}]", username); return new Uid(username); } OracleOperationAuthenticate(OracleConfiguration cfg, Connection adminConn); Uid authenticate(ObjectClass objectClass, String username, GuardedString password,
            OperationOptions options); }
OracleOperationAuthenticate extends AbstractOracleOperation implements AuthenticateOp { public Uid authenticate(ObjectClass objectClass, String username, GuardedString password, OperationOptions options) { OracleConnectorHelper.checkObjectClass(objectClass, cfg.getConnectorMessages()); new LocalizedAssert(cfg.getConnectorMessages()).assertNotBlank(username, "username"); new LocalizedAssert(cfg.getConnectorMessages()).assertNotNull(password, "password"); if (options != null && Boolean.TRUE.equals(options.getOptions().get("returnUidOnly"))) { return findUserByName(username); } LOG.info("Authenticate user: [{0}]", username); if (cfg.isUseDriverForAuthentication()) { doDriverAuthenticate(username, password); } else { doCfgAuthenticate(username, password); } LOG.info("User authenticated : [{0}]", username); return new Uid(username); } OracleOperationAuthenticate(OracleConfiguration cfg, Connection adminConn); Uid authenticate(ObjectClass objectClass, String username, GuardedString password,
            OperationOptions options);  }