{@inheritDoc} Create a WSCredential for the realm, user, and password in the subject.
If a basic auth map is not found, take no action.
334447
@Override
    public void setCredential(Subject subject) throws CredentialException {
        Hashtable<String, ?> customProperties = getBasicAuthHashtableFromSubject(subject);
        try {
            // Hashtable with basic auth information, all properties must be there.
            if (customProperties != null && !customProperties.isEmpty() && customProperties.size() == 3) {
                String realm = getRealm(customProperties);
                String securityName = getSecurityName(customProperties);
                SerializableProtectedString password = getPassword(customProperties);
                setBasicAuthCredential(subject, realm, securityName, password);
            }
        } finally {
            removeBasicAuthHashtable(subject, customProperties);
        }
    }
552412
private void initializeSecurityManager(SubjectAwareDescriptor subjectAware)
  {
    String cfg = subjectAware.getConfiguration();

    if (cfg.length() > 0)
    {
      Factory<SecurityManager> factory = new IniSecurityManagerFactory(cfg);
      SecurityManager securityManager = factory.getInstance();

      SecurityUtils.setSecurityManager(securityManager);
    }

    String username = subjectAware.getUsername();

    if ((username != null) && (username.length() > 0))
    {
      UsernamePasswordToken token = new UsernamePasswordToken(username,
                                      subjectAware.getPassword());

      SecurityUtils.getSubject().login(token);
    }
  }
272673
function(realm, key, ssl) {

    // Initialize with a specified realm, key, and a boolean indicating wther
    // SSL should be enabled or disabled.
    var scheme = 'https';
    if (typeof ssl !== 'undefined' && !ssl) {
        scheme = 'http';
    }
    var uri = scheme + '://api.fanout.io/realm/' + realm;
    var pubControl = new pubcontrol.PubControlClient(uri);
    pubControl.setAuthJwt({'iss': realm}, new Buffer(key, 'base64'));
    this.pubControl = pubControl;
}
282045
@Override
    public Subject authenticate(String username, @Sensitive String password) throws AuthenticationException {
        AuthenticationData authenticationData = createAuthenticationData(username, password);
        return authenticationService.authenticate(jaasEntryName, authenticationData, null);
    }
251755
@FFDCIgnore(NoSuchAlgorithmException.class)
    public static String createLookupKey(String realm, String userid, @Sensitive String password) {
        String lookupKey = null;
        if (realm != null && userid != null && password != null) {
            try {
                String hashedPassword = getHashedPassword(password);
                lookupKey = realm + KEY_SEPARATOR + userid + KEY_SEPARATOR + hashedPassword;
            } catch (NoSuchAlgorithmException e) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "There was a problem creating the lookup key.", e);
                }
            }
        }
        return lookupKey;
    }
192468
private void configureAuthentication(String username, String password, String realm) {

        // If the username is set, set up authentication:
        if (StringUtils.isNotBlank(username)) {

            this.username = username;
            this.password = password;
            this.realm = StringUtils.defaultIfBlank(realm, "restolino");

            authenticationEnabled = true;
        }
    }
1244198
def _auth(url, user, passwd, realm):
    '''
    
    '''

    basic = _HTTPBasicAuthHandler()
    basic.add_password(realm=realm, uri=url, user=user, passwd=passwd)
    digest = _HTTPDigestAuthHandler()
    digest.add_password(realm=realm, uri=url, user=user, passwd=passwd)
    return _build_opener(basic, digest)
1310018
public static String createAuthenticateHeader(final String realm, final String authMethod, final String nonce) {
        val stringBuilder = new StringBuilder("Digest realm=\"")
            .append(realm).append("\",");
        if (StringUtils.isNotBlank(authMethod)) {
            stringBuilder.append("qop=").append(authMethod).append(',');
        }
        return stringBuilder.append("nonce=\"").append(nonce)
            .append("\",opaque=\"").append(createOpaque(realm, nonce))
            .append('"')
            .toString();
    }
153993
static Subject createSubject(final SubjectFactory subjectFactory, final String domain)
   {
      if (System.getSecurityManager() == null)
         return subjectFactory.createSubject(domain);

      return AccessController.doPrivileged(new PrivilegedAction<Subject>() 
      {
         public Subject run()
         {
            return subjectFactory.createSubject(domain);
         }
      });
   }
1212074
public boolean isUnauthenticated(Subject subject) {
        if (subject == null) {
            return true;
        }

        WSCredential wsCred = getWSCredential(subject);
        if (wsCred == null) {
            return true;
        } else {
            return wsCred.isUnauthenticated();
        }
    }
889123
private void setCredential(Subject subject, WSPrincipal principal) throws CredentialException {
        String securityName = principal.getName();
        Hashtable<String, ?> customProperties = getUniqueIdHashtableFromSubject(subject);
        if (customProperties == null || customProperties.isEmpty()) {
            UserRegistryService urService = userRegistryServiceRef.getService();
            if (urService != null) {
                String urType = urService.getUserRegistryType();
                if ("WIM".equalsIgnoreCase(urType) || "LDAP".equalsIgnoreCase(urType)) {
                    try {
                        securityName = urService.getUserRegistry().getUserDisplayName(securityName);
                    } catch (Exception e) {
                        //do nothing
                    }
                }
            }
        }
        if (securityName == null || securityName.length() == 0) {
            securityName = principal.getName();
        }
        String accessId = principal.getAccessId();

        String customRealm = null;
        String realm = null;
        String uniqueName = null;

        if (customProperties != null) {
            customRealm = (String) customProperties.get(AttributeNameConstants.WSCREDENTIAL_REALM);
        }

        if (customRealm != null) {
            realm = customRealm;
            String[] parts = accessId.split(realm + "/");
            if (parts != null && parts.length == 2)
                uniqueName = parts[1];
        } else {
            realm = AccessIdUtil.getRealm(accessId);
            uniqueName = AccessIdUtil.getUniqueId(accessId);
        }
        if (AccessIdUtil.isServerAccessId(accessId)) {
            // Create a server WSCredential
            setCredential(null, subject, realm, securityName, uniqueName, null, accessId, null, null);
        } else {
            CredentialsService cs = credentialsServiceRef.getService();
            String unauthenticatedUserid = cs.getUnauthenticatedUserid();

            if (securityName != null && unauthenticatedUserid != null &&
                securityName.equals(unauthenticatedUserid)) {
                // Create an unauthenticated WSCredential
                setCredential(unauthenticatedUserid, subject, realm, securityName, uniqueName, null, null, null, null);
            } else if (AccessIdUtil.isUserAccessId(accessId)) {
                // Create a user WSCredential
                createUserWSCredential(subject, securityName, accessId, realm, uniqueName, unauthenticatedUserid);
            }
        }
    }
1058907
private HashMap<String, Object> createJMXEnvironment(final String user, final String password, final SSLSocketFactory sslSF) {
        HashMap<String, Object> environment = new HashMap<String, Object>();
        environment.put("jmx.remote.protocol.provider.pkgs", "com.ibm.ws.jmx.connector.client");
        environment.put(JMXConnector.CREDENTIALS, new String[] { user, password });
        environment.put(ClientProvider.READ_TIMEOUT, 2 * 60 * 1000);
        environment.put(ConnectorSettings.DISABLE_HOSTNAME_VERIFICATION, Boolean.TRUE);
        environment.put(ConnectorSettings.CUSTOM_SSLSOCKETFACTORY, sslSF);
        environment.put("isCollectiveUtil", Boolean.TRUE);
        return environment;
    }
1075676
private SSLContext buildSSLContext(SecurityRealm realm) {
        if (realm.getAuthentication() == null || realm.getAuthentication().getTruststore() == null) {
            throw new IllegalArgumentException("No truststore configuration in security realm \"" + realm.getName() + "\".");
        }
        if (realm.getIdentities() == null || realm.getIdentities().getSsl() == null
                || realm.getIdentities().getSsl().getKeystore() == null) {
            throw new IllegalArgumentException("No keystore configuration in security realm \"" + realm.getName() + "\".");
        }

        SecurityRealm.Keystore keystore = realm.getIdentities().getSsl().getKeystore();
        SecurityRealm.Truststore truststore = realm.getAuthentication().getTruststore();

        String keystorePassword = keystore.getPassword();
        String keyPassword = keystore.getKeyPassword();

        // we'll reuse PID configuration for OCSP/CRL stuff
        return buildSSLContext(keystore.getPath(), keystore.getProvider(),
                keystorePassword, keyPassword,
                keystore.getAlias(),
                truststore.getPath(), truststore.getProvider(),
                truststore.getPassword(),
                configuration.isValidateCerts(), configuration.getCrlPath(),
                null, // "SHA1PRNG", "NativePRNGNonBlocking", ...
                configuration.isValidatePeerCerts(), configuration.isEnableCRLDP(), configuration.isEnableOCSP(),
                configuration.getOcspResponderURL(),
                configuration.getSslKeystoreProvider(),
                configuration.getSslTrustStoreProvider(),
                configuration.getSslProvider());
    }
1067373
public Response create(String username, String password, String organization, String email, String phone, String countryCode, String firstName, String lastName) {
        Response op = new Response();
        if (userDAO.hasUser(username) == false) {
            if (userDAO.hasUserWithEmail(email) == false) {
                if (organizationDAO.hasOrganization(organization) == true) {
                    PersistedUser user = new PersistedUser(username, null, Arrays.asList("ROLE_USER"), organization, email, phone, countryCode);
                    user.firstName = firstName;
                    user.lastName = lastName;
                    user.has2FAEnabled = Boolean.parseBoolean(authyEnabled);
                    createPasswordHash(user, password);
                    com.authy.api.User authyUser = client.getUsers().createUser(user.email, user.phone, user.countryCode);
                    user.authProviderId = authyUser.getId();
                    userDAO.create(user);
                    op.setPayload(true);
                    sendAccountVerificationMessage(user, null);
                    notifyOperator(user);
                } else {
                    op.addError(new Error(11));
                }
            } else {
                op.addError(new Error(Error.USER_BY_EMAIL_FOUND));
            }
        } else {
            op.addError(new Error(7));
        }
        return op;
    }
94399
public static Subject generateSecuritySubject(String jassLoginConfig, String username, String password) throws LoginException {
  	  
        LoginContext loginCtx = null;
      
        try {
      
            // "Client" references the JAAS configuration in the jaas.conf file.
            loginCtx = new LoginContext(jassLoginConfig, new Krb5TokenUtils.LoginCallbackHandler(username, password));
            loginCtx.login();
 
            log.debug(" : Krb5Token Kerberos login succeeded against user: %s", username);
      
            return loginCtx.getSubject();
        }
        catch(LoginException e) {
            log.debug(" : Krb5Token Kerberos login failed against user: %s", username);
            throw e;
        }
    }
1049703
@Sensitive
    private Hashtable<String, ?> getBasicAuthHashtableFromSubject(@Sensitive final Subject subject) {
        final String[] properties = { KEY_BASIC_AUTH_REALM, KEY_BASIC_AUTH_USER, KEY_BASIC_AUTH_PASSWORD };
        SubjectHelper subjectHelper = new SubjectHelper();
        return subjectHelper.getSensitiveHashtableFromSubject(subject, properties);
    }
770127
public static function CreateResponseA1 ($realm, $user_name, $password, $key) {
		return Hash::HmacString(implode(static::RESPONSE_SEPARATOR,[$user_name, $realm, $password]), $key, static::GetAlgorithm());
	}