Creates a core connection

@param userName
the username
@param password
the password
@return the core connection
@throws ResourceException
if the creation fails Feature 169626.14
172889
SICoreConnection createCoreConnection(final String userName,
                                          final String password) throws ResourceException {

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.entry(this, TRACE, "createCoreConnection", new Object[] {
                                                                           userName, "*****" });
        }

        SICoreConnectionFactory coreConnectionFactory = null;

        if (!UTEHelperFactory.jmsTestEnvironmentEnabled) {

            try {

                coreConnectionFactory = SICoreConnectionFactorySelector
                                .getSICoreConnectionFactory(FactoryType.TRM_CONNECTION);

            } catch (final SIException exception) {

                FFDCFilter.processException(exception, CLASS_NAME
                                                       + ".createManagedConnection", FFDC_PROBE_5, this);
                throw new ResourceException(NLS
                                .getFormattedMessage("EXCEPTION_RECEIVED_CWSJR1064",
                                                     new Object[] { exception,
                                                                   "getSICoreConnectionFactory" }, null),
                                exception);

            }

        } else {

            coreConnectionFactory = UTEHelperFactory.getHelperInstance()
                            .setupJmsTestEnvironment();

        }

        if (coreConnectionFactory == null) {
            throw new ResourceAdapterInternalException(NLS.getFormattedMessage(
                                                                               ("SICORECONNECTION_ERROR_CWSJR1066"),
                                                                               new Object[] { "createManagedConnection" }, null));
        }

        final SICoreConnection coreConnection;

        try {

            final Map trmProperties = _managedConnectionFactory
                            .getTrmProperties();
            coreConnection = coreConnectionFactory.createConnection(userName,
                                                                    password, trmProperties);

        } catch (final SIException exception) {

            FFDCFilter
                            .processException(
                                              exception,
                                              CLASS_NAME
                                                              + ".createManagedConnection (Subject, ConnectionRequestInfo)",
                                              FFDC_PROBE_6, this);
            if (TraceComponent.isAnyTracingEnabled() && TRACE.isEventEnabled()) {
                SibTr.exception(this, TRACE, exception);
            }

            throw new ResourceException(NLS.getFormattedMessage(
                                                                "EXCEPTION_RECEIVED_CWSJR1065", new Object[] { exception,
                                                                                                              "createManagedConnection" }, null), exception);

        } catch (final SIErrorException exception) {

            FFDCFilter
                            .processException(
                                              exception,
                                              CLASS_NAME
                                                              + ".createManagedConnection (Subject, ConnectionRequestInfo)",
                                              FFDC_PROBE_7, this);
            if (TraceComponent.isAnyTracingEnabled() && TRACE.isEventEnabled()) {
                SibTr.exception(this, TRACE, exception);
            }

            throw new ResourceException(NLS.getFormattedMessage(
                                                                "EXCEPTION_RECEIVED_CWSJR1065", new Object[] { exception,
                                                                                                              "createManagedConnection" }, null), exception);

        }

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.exit(this, TRACE, "createCoreConnection", coreConnection);
        }
        return coreConnection;

    }
354521
public FTP auth(String username, String password) {
        return username(username).password(password);
    }
600497
public RestTemplateBuilder basicAuthentication(String username, String password) {
		return new RestTemplateBuilder(this.detectRequestFactory, this.rootUri,
				this.messageConverters, this.requestFactorySupplier,
				this.uriTemplateHandler, this.errorHandler,
				new BasicAuthenticationInterceptor(username, password),
				this.restTemplateCustomizers, this.requestFactoryCustomizer,
				this.interceptors);
	}
1318666
public static JiraRestClient connect(URL jiraUrl, String username, String password) throws IOException {
        return new AsynchronousJiraRestClientFactory()
                .createWithBasicHttpAuthentication(URI.create(jiraUrl.toExternalForm()), username, password);
    }
424268
public static void useResource(String host, int port, String user, String password, Authentication authType)
    throws ResourceNotFoundException, ForbiddenUserException, FailedRequestException
  {
    // create the client
    DatabaseClient client = DatabaseClientFactory.newClient(host, port, user, password, authType);

    // create the resource extension client
    HelloWorld hello = new HelloWorld(client);

    String response = hello.sayHello();
    System.out.println("Called hello worlds service, got response:["+ response + "]");

    // release the client
    client.release();
  }
1334729
public function authenticate(string $username, string $password): ConnectionInterface
    {
        $errorMessage = null;
        $errorNumber  = 0;
        \set_error_handler(static function ($nr, $message) use (&$errorMessage, &$errorNumber) {
            $errorMessage = $message;
            $errorNumber = $nr;
        });

        $resource = \imap_open(
            $this->getServerString(),
            $username,
            $password,
            $this->options,
            $this->retries,
            $this->parameters
        );

        \restore_error_handler();

        if (false === $resource || null !== $errorMessage) {
            throw new AuthenticationFailedException(\sprintf(
                'Authentication failed for user "%s"%s',
                $username,
                null !== $errorMessage ? ': ' . $errorMessage : ''
            ), $errorNumber);
        }

        $check = \imap_check($resource);

        if (false === $check) {
            throw new ResourceCheckFailureException('Resource check failure');
        }

        $mailbox       = $check->Mailbox;
        $connection    = $mailbox;
        $curlyPosition = \strpos($mailbox, '}');
        if (false !== $curlyPosition) {
            $connection = \substr($mailbox, 0, $curlyPosition + 1);
        }

        // These are necessary to get rid of PHP throwing IMAP errors
        \imap_errors();
        \imap_alerts();

        return new Connection(new ImapResource($resource), $connection);
    }
1282012
public CRestBuilder basicAuth(String username, String password) {
        this.auth = "basic";
        this.username = username;
        this.password = password;
        return this;
    }
228900
public static AuthenticationData createAuthenticationData(String userName, String password) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            SibTr.entry(tc, CLASS_NAME + "createAuthenticationData", new Object[] { userName, "Password Not Traced" });
        }
        AuthenticationData authData = new WSAuthenticationData();
        if (userName == null)
            userName = "";
        if (password == null)
            password = "";
        authData.set(AuthenticationData.USERNAME, userName);
        authData.set(AuthenticationData.PASSWORD, new ProtectedString(password.toCharArray()));
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            SibTr.exit(tc, CLASS_NAME + "createAuthenticationData", authData);
        }
        return authData;
    }
1167973
public void login(String username, String password) throws IOException {
        String requestUrl = RESOURCE + "/login";
        Credentials creds = new Credentials();

        creds.setPassword(password);
        creds.setUsername(username);

        ArgusResponse response = getClient().executeHttpRequest(ArgusHttpClient.RequestType.POST, requestUrl, creds);

        try {
		assertValidResponse(response, requestUrl);
	} catch (TokenExpiredException e) {
		//This should never happen
		throw new RuntimeException("This should never happen. login() method should never throw a TokenExpiredException", e);
	}
        
        Map<String, String> tokens = fromJson(response.getResult(), new TypeReference<Map<String, String>>() {});
        getClient().accessToken = tokens.get("accessToken");
        getClient().refreshToken = tokens.get("refreshToken");
    }
773028
public CompletionStage<Token> login(final String username,
            final String password, final AuthModule eauth) {
        Map<String, String> props = new LinkedHashMap<>();
        props.put("username", username);
        props.put("password", password);
        props.put("eauth", eauth.getValue());

        String payload = gson.toJson(props);

        CompletionStage<Token> result = asyncHttpClient
                .post(uri.resolve("login"), payload, JsonParser.TOKEN)
                .thenApply(r -> {
                    // They return a list of tokens here, take the first one
                    Token token = r.getResult().get(0);
                    return token;
                });

        return result;
    }
366169
public User get(String loginname, String password) {
        Connection conn = null;
        User user = null;
        if (loginname == null || password == null) return null;
        String cryptpassword = MD5.encodeString(password,null);
        try {
            conn = ConnectionUtils.getConnection();
            user = userDAO.get(conn,loginname,cryptpassword);
        } catch(SQLException e) {
            logger.error(e.getMessage());
        } finally {
            DbUtils.closeQuietly(conn);
        }
        return user;
    }
66066
@Override
    public SICoreConnection createConnection(String userName, String password,
                                             Map connectionProperties) throws SIResourceException,
                    SINotAuthorizedException, SIAuthenticationException {
        if (TraceComponent.isAnyTracingEnabled()
            && CoreSPIConnFactory.tc.isEntryEnabled())
            SibTr.entry(CoreSPIConnFactory.tc, "createConnection",
                        new Object[] { userName, connectionProperties });

        // Check that the Messaging Engine is started
        checkStarted();

        // Security context associated with logged-on principal.
        Subject subject = null;

        // Security Code changes for Liberty: Sharath Start
        try {
            subject = _authentication.login(userName, password);
        } catch (MessagingAuthenticationException e) {
            throw new SIAuthenticationException(e.getMessage());
        }
        SICoreConnection connection = createConnection(subject, connectionProperties);
        if (TraceComponent.isAnyTracingEnabled()
            && CoreSPIConnFactory.tc.isEntryEnabled())
            SibTr.exit(CoreSPIConnFactory.tc, "createConnection", connection);
        return connection;
        // Security Code changes for Liberty: Sharath End
    }
1314067
@Override
    public User createUser(String username, String password)
            throws AuthenticationException {
        String user = file_store.getProperty(username);
        if (user != null) {
            throw new AuthenticationException("User '" + username
                    + "' already exists.");
        }
        // Encrypt the new password
        String ePwd = encryptPassword(password);
        file_store.put(username, ePwd);
        try {
            saveUsers();
        } catch (IOException e) {
            throw new AuthenticationException("Error changing password: ", e);
        }

        return getUser(username);
    }
225885
public T authentication(String username, String password) {
        return authentication(username, password, false);
    }
1296404
public static @NotNull Database forUrlAndCredentials(@NotNull String url, @Nullable String username, @Nullable String password) {
        return new Database(new DriverManagerConnectionProvider(url, username, password));
    }
607425
def create_user(self, username, password):
        
        user_id = "org.couchdb.user:" + username
        res = self["_users"].resource.put(
            user_id, body=json.dumps({
                "_id": user_id,
                "name": username,
                "roles": [],
                "type": "user",
                "password": password,
                "farms": []
            })
        )
        if res[0] == 409:
            raise RuntimeError(
                'The username "{}" is already taken'.format(username)
            )
        elif res[0] != 201:
            raise RuntimeError(
                "Failed to create user ({}): {}".format(
                    res.status_code, res.content
                )
            )
1003878
@Override
    public SICoreConnection createConnection(ClientConnection cc,
                                             String credentialType, String userid, String password)
                    throws SIResourceException, SINotAuthorizedException,
                    SIAuthenticationException {

        if (TraceComponent.isAnyTracingEnabled()
            && CoreSPIConnFactory.tc.isEntryEnabled()) {
            SibTr.entry(CoreSPIConnFactory.tc, "createConnection",
                        new Object[] { cc, credentialType, userid, password });
        }

        // Check that the Messaging Engine is started
        checkStarted();

        if ("".equals(userid))
            userid = null;

        SICoreConnection connection = null;
        SSLSession sslSession = cc.getMetaData().getSSLSession();

        if (credentialType.equals(TrmConstantsImpl.CREDENTIAL_USERID_PASSWORD)) {
            Certificate[] peerCerts = null;
            // Get hold of SSL credentials if userID null
            if (userid == null) {
                if (sslSession != null) {
                    try {
                        // Attempt to get hold of peer certificates
                        if (TraceComponent.isAnyTracingEnabled()
                            && tc.isDebugEnabled())
                            SibTr.debug(tc,
                                        "Authentication: attempting to retrieve SSL Peer certificates");
                        peerCerts = sslSession.getPeerCertificates();
                    } catch (SSLPeerUnverifiedException sslPUE) {
                        // No FFDC Code Needed
                        // No action needed - this will be handled by the
                        // anonymous login section below
                        if (TraceComponent.isAnyTracingEnabled()
                            && tc.isDebugEnabled())
                            SibTr.debug(tc,
                                        "Authentication: Error obtaining SSL certificates >"
                                                        + sslPUE + "<");
                    }
                }
            }
            // Call login depending on credentials provided
            if (userid != null) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                    SibTr.debug(tc,
                                "Authentication: Login using user ID and password");
                connection = createConnection(userid, password, null);
            } else if ((peerCerts != null) && (peerCerts.length > 0)) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                    SibTr.debug(tc,
                                "Authentication: Login using SSL Peer certificates");
                connection = createConnection(peerCerts);
            } else {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                    SibTr.debug(
                                tc,
                                "Authentication: Anonymous Login using user ID and password; note that these may be null");
                connection = createConnection(userid, password, null);
            }
        }

        //mark connection  type comms/commsssl. Explicitly porting connection to ConnectionImpl as all connection in MP are off type ConnectionImpl
        if (null != sslSession)
            ((ConnectionImpl) connection).setConnectionType(SIMPConstants.MP_VIACOMMSSSL_CONNECTION);
        else
            ((ConnectionImpl) connection).setConnectionType(SIMPConstants.MP_VIACOMMS_CONNECTION);

        if (TraceComponent.isAnyTracingEnabled()
            && CoreSPIConnFactory.tc.isEntryEnabled())
            SibTr.exit(CoreSPIConnFactory.tc, "createConnection", connection);
        return connection;
    }