Retrieves the users password by iterating over the user's security contexts and returning the
first available cached password.

@param baseContext The security context to start looking for a password from.
@return the users password
480817
private String getPassword(ISecurityContext baseContext) {
        String password = null;
        IOpaqueCredentials oc = baseContext.getOpaqueCredentials();

        if (oc instanceof NotSoOpaqueCredentials) {
            NotSoOpaqueCredentials nsoc = (NotSoOpaqueCredentials) oc;
            password = nsoc.getCredentials();
        }

        // If still no password, loop through subcontexts to find cached credentials
        Enumeration en = baseContext.getSubContexts();
        while (password == null && en.hasMoreElements()) {
            ISecurityContext subContext = (ISecurityContext) en.nextElement();
            password = this.getPassword(subContext);
        }

        return password;
    }
27798
def get_password(self):
        
        password = self.get_as_nullable_string("password")
        password = password if password != None else self.get_as_nullable_string("pass")
        return password
1201389
public static String getBasicAuth(String user, final String pass) {

    return "Basic " + java.util.Base64.getEncoder().encodeToString((user + ":" + pass).getBytes());
  }
783381
@GET
    public String showBasicUserSecret(@Context SecurityContext context) {
        User user = (User) context.getUserPrincipal();
        return String.format("Hey there, %s. You seem to be a basic user. %d", user.getName(), user.getId());
    }
1084600
private SecurityContext getSecurityContext() {
        return new SecurityContext() {
            @Override
            public AuthorisationDecision getReadPriviledge() {
                return securityContextDelegate.getReadPriviledge();
            }

            @Override
            public AuthorisationDecision getWritePriviledge() {
                return securityContextDelegate.getWritePriviledge();
            }

            @Override
            public AuthorisationDecision getAttributeWritePriviledge(String s) {
                return securityContextDelegate.getAttributeWritePriviledge(attributeName);
            }

            @Override
            public AuthorisationDecision getAttributeReadPriviledge(String s) {
                return securityContextDelegate.getAttributeReadPriviledge(attributeName);
            }

            @Override
            public AuthorisationDecision getAttributeWritePriviledge(String resourceAddress, String attributeName) {
                return securityContextDelegate.getAttributeWritePriviledge(attributeName);
            }

            @Override
            public AuthorisationDecision getAttributeReadPriviledge(String resourceAddress, String attributeName) {
                return securityContextDelegate.getAttributeReadPriviledge(attributeName);
            }

            @Override
            public AuthorisationDecision getReadPrivilege(String resourceAddress) {
                return securityContextDelegate.getAttributeReadPriviledge(attributeName);
            }

            @Override
            public AuthorisationDecision getWritePrivilege(String resourceAddress) {
                return securityContextDelegate.getAttributeWritePriviledge(attributeName);
            }

            @Override
            public AuthorisationDecision getOperationPriviledge(String resourceAddress, String operationName) {
                return securityContextDelegate.getOperationPriviledge(resourceAddress, operationName);
            }

            @Override
            public boolean hasChildContext(Object s, String resolvedKey) {
                return false;
            }

            @Override
            public void activateChildContext(Object resourceAddress, String resolvedKey) {

            }

            @Override
            public void seal() {
                securityContextDelegate.seal();
            }
        };
    }
1092695
@Override
	public SecurityContext getContext(String userName, String password) throws FFMQSecurityException 
	{
		if (userName == null)
			throw new FFMQSecurityException("User name not specified","INVALID_SECURITY_DESCRIPTOR");
		
		// Check user and password
		User user = descriptor.getUser(userName);
        if (user == null || !user.getPassword().equals(password))
            throw new FFMQSecurityException("Invalid user/password","INVALID_SECURITY_DESCRIPTOR");
        
        return user;
	}
493802
public static String getCurrentUser() {
        ServiceContext ctx = ServiceContextStore.get();
        String currentUser;
        if (ctx == null) {
            currentUser = ServiceContextFactory.SYSTEM_USER;
        } else {
            currentUser = ctx.getUserId();
        }

        if (currentUser == null) {
            currentUser = ServiceContextFactory.UNKNOWN_USER;
        }
        return currentUser;
    }
863850
public void setContextParameters(
            Map<String, String> principals,
            Map<String, String> credentials,
            String ctxName,
            ISecurityContext securityContext) {

        if (log.isDebugEnabled()) {
            final StringBuilder msg = new StringBuilder();
            msg.append("Preparing to authenticate;  setting parameters for context name '")
                    .append(ctxName)
                    .append("', context class '")
                    .append(securityContext.getClass().getName())
                    .append("'");
            // Display principalTokens...
            msg.append("\n\t Available Principal Tokens");
            for (final Object o : principals.entrySet()) {
                final Map.Entry<?, ?> y = (Map.Entry<?, ?>) o;
                msg.append("\n\t\t").append(y.getKey()).append("=").append(y.getValue());
            }
            // Keep credentialTokens secret, but indicate whether they were provided...
            msg.append("\n\t Available Credential Tokens");
            for (final Object o : credentials.entrySet()) {
                final Map.Entry<?, ?> y = (Map.Entry<?, ?>) o;
                final String val = (String) y.getValue();
                String valWasSpecified = null;
                if (val != null) {
                    valWasSpecified = val.trim().length() == 0 ? "empty" : "provided";
                }
                msg.append("\n\t\t").append(y.getKey()).append(" was ").append(valWasSpecified);
            }
            log.debug(msg.toString());
        }

        String username = principals.get(ctxName);
        String credential = credentials.get(ctxName);
        // If username or credential are null, this indicates that the token was not
        // set in security.properties. We will then use the value for root.
        username = username != null ? username : (String) principals.get(BASE_CONTEXT_NAME);
        credential = credential != null ? credential : (String) credentials.get(BASE_CONTEXT_NAME);
        if (log.isDebugEnabled()) {
            log.debug("Authentication::setContextParameters() username: " + username);
        }
        // Retrieve and populate an instance of the principal object
        final IPrincipal principalInstance = securityContext.getPrincipalInstance();
        if (username != null && !username.equals("")) {
            principalInstance.setUID(username);
        }
        // Retrieve and populate an instance of the credentials object
        final IOpaqueCredentials credentialsInstance =
                securityContext.getOpaqueCredentialsInstance();
        if (credentialsInstance != null) {
            credentialsInstance.setCredentials(credential);
        }
    }
1236023
public T basic(String user, String password){
        connection.setRequestProperty("Authorization", "Basic " + toBase64((user + ":" + password).getBytes()));
        return (T) this;
    }
553756
public String getAuthString() {
        String credentials = this.username + ":" + this.password;
        try {

            String encoded = new Base64().encodeAsString(credentials.getBytes("ascii"));
            return "Basic " + encoded;

        } catch (final UnsupportedEncodingException e) {

            throw new InvalidRequestException("It must be possible to encode credentials as ascii", credentials, e);

        }
    }
1315238
protected AuthenticationContext getAuthenticationContext(ProfileRequestContext<?, ?> context)
      throws ExternalAutenticationErrorCodeException {
    AuthenticationContext authnContext = authenticationContextLookupStrategy.apply(context);
    if (authnContext == null) {
      log.error("No AuthenticationContext available [{}]", this.getLogString(context));
      throw new ExternalAutenticationErrorCodeException(AuthnEventIds.INVALID_AUTHN_CTX, "Missing AuthenticationContext");
    }
    return authnContext;
  }
21811
def get_password(self, service, username):
        
        service = escape_for_ini(service)
        username = escape_for_ini(username)

        # fetch the password
        try:
            password_base64 = self.config.get(service, username).encode()
            # decode with base64
            password_encrypted = base64.decodestring(password_base64)
            # decrypted the password
            password = self.decrypt(password_encrypted).decode('utf-8')
        except (configparser.NoOptionError, configparser.NoSectionError):
            password = None
        return password
373221
def get_auth_basic(self):
        """"""
        username = ''
        password = ''
        auth_header = self.get_header('authorization')
        if auth_header:
            m = re.search(r"^Basic\s+(\S+)$", auth_header, re.I)
            if m:
                auth_str = Base64.decode(m.group(1))
                username, password = auth_str.split(':', 1)

        return username, password
10278
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
    public static UserManager getUserManager(Context context) {
        return (UserManager) context.getSystemService(Context.USER_SERVICE);
    }
284380
private String getUserPassword(Object[] args) throws AuthException {
		if (args == null)
			throw new AuthException("auth error: args is null");
		if ((userPasswordPair == null) || userPasswordPair.equals("")) {
			try {
				StringBuilder sb = new StringBuilder();
				if ((args[0] != null) && (args[1] != null)) {
					sb.append(args[0]);
					sb.append(":");
					sb.append(args[1]);
					userPasswordPair = sb.toString();
				}
			} catch (Exception e) {
				throw new AuthException("auth error: args is null");
			}
		}
		Debug.logVerbose("[JdonFramework] url param is" + userPasswordPair, module);
		return userPasswordPair;
	}
122864
def get_password(self, service, username):
        
        try:
            # fetch the password
            key = self._key_for_service(service)
            hkey = winreg.OpenKey(winreg.HKEY_CURRENT_USER, key)
            password_saved = winreg.QueryValueEx(hkey, username)[0]
            password_base64 = password_saved.encode('ascii')
            # decode with base64
            password_encrypted = base64.decodestring(password_base64)
            # decrypted the password
            password = _win_crypto.decrypt(password_encrypted).decode('utf-8')
        except EnvironmentError:
            password = None
        return password
753362
protected final boolean authenticate(Context context, String username, String password, boolean rememberMe) {
        UsernamePasswordToken authenticationToken = new UsernamePasswordToken(username, password, rememberMe);
        try {
            SecurityUtils.getSubject().login(authenticationToken);
            log.info("'{}' authenticated", username);
            return true;
        } catch (AuthenticationException e) {
            log.info("'{}' failed to authenticate", username);
            return false;
        }
    }