android.net.Credentials Java Examples

The following examples show how to use android.net.Credentials. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SecureSocketHandler.java    From Dream-Catcher with MIT License 6 votes vote down vote up
private static void enforcePermission(Context context, LocalSocket peer)
    throws IOException, PeerAuthorizationException {
  Credentials credentials = peer.getPeerCredentials();

  int uid = credentials.getUid();
  int pid = credentials.getPid();

  if (LogUtil.isLoggable(Log.VERBOSE)) {
    LogUtil.v("Got request from uid=%d, pid=%d", uid, pid);
  }

  String requiredPermission = Manifest.permission.DUMP;
  int checkResult = context.checkPermission(requiredPermission, pid, uid);
  if (checkResult != PackageManager.PERMISSION_GRANTED) {
    throw new PeerAuthorizationException(
        "Peer pid=" + pid + ", uid=" + uid + " does not have " + requiredPermission);
  }
}
 
Example #2
Source File: SecureSocketHandler.java    From weex with Apache License 2.0 6 votes vote down vote up
private static void enforcePermission(Context context, LocalSocket peer)
    throws IOException, PeerAuthorizationException {
  Credentials credentials = peer.getPeerCredentials();

  int uid = credentials.getUid();
  int pid = credentials.getPid();

  if (LogUtil.isLoggable(Log.VERBOSE)) {
    LogUtil.v("Got request from uid=%d, pid=%d", uid, pid);
  }

  String requiredPermission = Manifest.permission.DUMP;
  int checkResult = context.checkPermission(requiredPermission, pid, uid);
  if (checkResult != PackageManager.PERMISSION_GRANTED) {
    throw new PeerAuthorizationException(
        "Peer pid=" + pid + ", uid=" + uid + " does not have " + requiredPermission);
  }
}
 
Example #3
Source File: SecureSocketHandler.java    From stetho with MIT License 6 votes vote down vote up
private static void enforcePermission(Context context, LocalSocket peer)
    throws IOException, PeerAuthorizationException {
  Credentials credentials = peer.getPeerCredentials();

  int uid = credentials.getUid();
  int pid = credentials.getPid();

  if (LogUtil.isLoggable(Log.VERBOSE)) {
    LogUtil.v("Got request from uid=%d, pid=%d", uid, pid);
  }

  String requiredPermission = Manifest.permission.DUMP;
  int checkResult = context.checkPermission(requiredPermission, pid, uid);
  if (checkResult != PackageManager.PERMISSION_GRANTED) {
    throw new PeerAuthorizationException(
        "Peer pid=" + pid + ", uid=" + uid + " does not have " + requiredPermission);
  }
}
 
Example #4
Source File: ZygoteConnection.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * uid 1000 (Process.SYSTEM_UID) may specify any uid > 1000 in normal
 * operation. It may also specify any gid and setgroups() list it chooses.
 * In factory test mode, it may specify any UID.
 *
 * @param args non-null; zygote spawner arguments
 * @param peer non-null; peer credentials
 * @throws ZygoteSecurityException
 */
private static void applyUidSecurityPolicy(Arguments args, Credentials peer)
        throws ZygoteSecurityException {

    if (peer.getUid() == Process.SYSTEM_UID) {
        /* In normal operation, SYSTEM_UID can only specify a restricted
         * set of UIDs. In factory test mode, SYSTEM_UID may specify any uid.
         */
        boolean uidRestricted = FactoryTest.getMode() == FactoryTest.FACTORY_TEST_OFF;

        if (uidRestricted && args.uidSpecified && (args.uid < Process.SYSTEM_UID)) {
            throw new ZygoteSecurityException(
                    "System UID may not launch process with UID < "
                    + Process.SYSTEM_UID);
        }
    }

    // If not otherwise specified, uid and gid are inherited from peer
    if (!args.uidSpecified) {
        args.uid = peer.getUid();
        args.uidSpecified = true;
    }
    if (!args.gidSpecified) {
        args.gid = peer.getGid();
        args.gidSpecified = true;
    }
}
 
Example #5
Source File: WalletManager.java    From guarda-android-wallets with GNU General Public License v3.0 4 votes vote down vote up
public Credentials getCredentials() {
    return null;
}
 
Example #6
Source File: WalletManager.java    From guarda-android-wallets with GNU General Public License v3.0 4 votes vote down vote up
public Credentials getCredentials() {
    return null;
}
 
Example #7
Source File: WalletManager.java    From guarda-android-wallets with GNU General Public License v3.0 4 votes vote down vote up
public Credentials getCredentials() {
    return null;
}
 
Example #8
Source File: WalletManager.java    From guarda-android-wallets with GNU General Public License v3.0 4 votes vote down vote up
public Credentials getCredentials() {
    return null;
}
 
Example #9
Source File: WalletManager.java    From guarda-android-wallets with GNU General Public License v3.0 4 votes vote down vote up
public Credentials getCredentials() {
    return null;
}
 
Example #10
Source File: WalletManager.java    From guarda-android-wallets with GNU General Public License v3.0 4 votes vote down vote up
public Credentials getCredentials() {
    return null;
}
 
Example #11
Source File: WalletManager.java    From guarda-android-wallets with GNU General Public License v3.0 4 votes vote down vote up
public Credentials getCredentials() {
    return null;
}
 
Example #12
Source File: WalletManager.java    From guarda-android-wallets with GNU General Public License v3.0 4 votes vote down vote up
public Credentials getCredentials() {
    return null;
}
 
Example #13
Source File: WalletManager.java    From guarda-android-wallets with GNU General Public License v3.0 4 votes vote down vote up
public Credentials getCredentials() {
    return null;
}
 
Example #14
Source File: WalletManager.java    From guarda-android-wallets with GNU General Public License v3.0 4 votes vote down vote up
public Credentials getCredentials() {
    return null;
}
 
Example #15
Source File: WalletManager.java    From guarda-android-wallets with GNU General Public License v3.0 4 votes vote down vote up
public Credentials getCredentials() {
    return null;
}
 
Example #16
Source File: ZygoteConnection.java    From android_9.0.0_r45 with Apache License 2.0 3 votes vote down vote up
/**
 * Applies zygote security policy.
 * Based on the credentials of the process issuing a zygote command:
 * <ol>
 * <li> uid 0 (root) may specify --invoke-with to launch Zygote with a
 * wrapper command.
 * <li> Any other uid may not specify any invoke-with argument.
 * </ul>
 *
 * @param args non-null; zygote spawner arguments
 * @param peer non-null; peer credentials
 * @throws ZygoteSecurityException
 */
private static void applyInvokeWithSecurityPolicy(Arguments args, Credentials peer)
        throws ZygoteSecurityException {
    int peerUid = peer.getUid();

    if (args.invokeWith != null && peerUid != 0 &&
        (args.runtimeFlags & Zygote.DEBUG_ENABLE_JDWP) == 0) {
        throw new ZygoteSecurityException("Peer is permitted to specify an"
                + "explicit invoke-with wrapper command only for debuggable"
                + "applications.");
    }
}