Search in sources :

Example 76 with InvalidParameterException

use of java.security.InvalidParameterException in project platform_frameworks_base by android.

the class ContentService method notifyChange.

/**
     * Notify observers of a particular user's view of the provider.
     * @param userHandle the user whose view of the provider is to be notified.  May be
     *     the calling user without requiring any permission, otherwise the caller needs to
     *     hold the INTERACT_ACROSS_USERS_FULL permission or hold a write uri grant to the uri.
     *     Pseudousers USER_ALL and USER_CURRENT are properly interpreted; no other pseudousers are
     *     allowed.
     */
@Override
public void notifyChange(Uri uri, IContentObserver observer, boolean observerWantsSelfNotifications, int flags, int userHandle) {
    if (DEBUG)
        Slog.d(TAG, "Notifying update of " + uri + " for user " + userHandle + " from observer " + observer + ", flags " + Integer.toHexString(flags));
    if (uri == null) {
        throw new NullPointerException("Uri must not be null");
    }
    final int uid = Binder.getCallingUid();
    final int pid = Binder.getCallingPid();
    final int callingUserHandle = UserHandle.getCallingUserId();
    // Notify for any user other than the caller requires uri grant or cross user permission
    if (callingUserHandle != userHandle) {
        if (checkUriPermission(uri, pid, uid, Intent.FLAG_GRANT_WRITE_URI_PERMISSION, userHandle) != PackageManager.PERMISSION_GRANTED) {
            enforceCrossUserPermission(userHandle, "no permission to notify other users");
        }
    }
    // We passed the permission check; resolve pseudouser targets as appropriate
    if (userHandle < 0) {
        if (userHandle == UserHandle.USER_CURRENT) {
            userHandle = ActivityManager.getCurrentUser();
        } else if (userHandle != UserHandle.USER_ALL) {
            throw new InvalidParameterException("Bad user handle for notifyChange: " + userHandle);
        }
    }
    // This makes it so that future permission checks will be in the context of this
    // process rather than the caller's process. We will restore this before returning.
    long identityToken = clearCallingIdentity();
    try {
        ArrayList<ObserverCall> calls = new ArrayList<ObserverCall>();
        synchronized (mRootNode) {
            mRootNode.collectObserversLocked(uri, 0, observer, observerWantsSelfNotifications, flags, userHandle, calls);
        }
        final int numCalls = calls.size();
        for (int i = 0; i < numCalls; i++) {
            ObserverCall oc = calls.get(i);
            try {
                oc.mObserver.onChange(oc.mSelfChange, uri, userHandle);
                if (DEBUG)
                    Slog.d(TAG, "Notified " + oc.mObserver + " of " + "update at " + uri);
            } catch (RemoteException ex) {
                synchronized (mRootNode) {
                    Log.w(TAG, "Found dead observer, removing");
                    IBinder binder = oc.mObserver.asBinder();
                    final ArrayList<ObserverNode.ObserverEntry> list = oc.mNode.mObservers;
                    int numList = list.size();
                    for (int j = 0; j < numList; j++) {
                        ObserverNode.ObserverEntry oe = list.get(j);
                        if (oe.observer.asBinder() == binder) {
                            list.remove(j);
                            j--;
                            numList--;
                        }
                    }
                }
            }
        }
        if ((flags & ContentResolver.NOTIFY_SYNC_TO_NETWORK) != 0) {
            SyncManager syncManager = getSyncManager();
            if (syncManager != null) {
                syncManager.scheduleLocalSync(null, /* all accounts */
                callingUserHandle, uid, uri.getAuthority());
            }
        }
        synchronized (mCache) {
            final String providerPackageName = getProviderPackageName(uri);
            invalidateCacheLocked(userHandle, providerPackageName, uri);
        }
    } finally {
        restoreCallingIdentity(identityToken);
    }
}
Also used : ArrayList(java.util.ArrayList) InvalidParameterException(java.security.InvalidParameterException) IBinder(android.os.IBinder) RemoteException(android.os.RemoteException)

Example 77 with InvalidParameterException

use of java.security.InvalidParameterException in project platform_frameworks_base by android.

the class ContentService method registerContentObserver.

/**
     * Register a content observer tied to a specific user's view of the provider.
     * @param userHandle the user whose view of the provider is to be observed.  May be
     *     the calling user without requiring any permission, otherwise the caller needs to
     *     hold the INTERACT_ACROSS_USERS_FULL permission or hold a read uri grant to the uri.
     *     Pseudousers USER_ALL and USER_CURRENT are properly handled; all other pseudousers
     *     are forbidden.
     */
@Override
public void registerContentObserver(Uri uri, boolean notifyForDescendants, IContentObserver observer, int userHandle) {
    if (observer == null || uri == null) {
        throw new IllegalArgumentException("You must pass a valid uri and observer");
    }
    final int uid = Binder.getCallingUid();
    final int pid = Binder.getCallingPid();
    final int callingUserHandle = UserHandle.getCallingUserId();
    // cross user permission
    if (callingUserHandle != userHandle) {
        if (checkUriPermission(uri, pid, uid, Intent.FLAG_GRANT_READ_URI_PERMISSION, userHandle) != PackageManager.PERMISSION_GRANTED) {
            enforceCrossUserPermission(userHandle, "no permission to observe other users' provider view");
        }
    }
    if (userHandle < 0) {
        if (userHandle == UserHandle.USER_CURRENT) {
            userHandle = ActivityManager.getCurrentUser();
        } else if (userHandle != UserHandle.USER_ALL) {
            throw new InvalidParameterException("Bad user handle for registerContentObserver: " + userHandle);
        }
    }
    synchronized (mRootNode) {
        mRootNode.addObserverLocked(uri, observer, notifyForDescendants, mRootNode, uid, pid, userHandle);
        if (false)
            Log.v(TAG, "Registered observer " + observer + " at " + uri + " with notifyForDescendants " + notifyForDescendants);
    }
}
Also used : InvalidParameterException(java.security.InvalidParameterException)

Example 78 with InvalidParameterException

use of java.security.InvalidParameterException in project camel by apache.

the class RestletComponent method addServerIfNecessary.

protected void addServerIfNecessary(RestletEndpoint endpoint) throws Exception {
    String key = buildKey(endpoint);
    Server server;
    synchronized (servers) {
        server = servers.get(key);
        if (server == null) {
            server = createServer(endpoint);
            component.getServers().add(server);
            // Add any Restlet server parameters that were included
            Series<Parameter> params = server.getContext().getParameters();
            if ("https".equals(endpoint.getProtocol())) {
                SSLContextParameters scp = endpoint.getSslContextParameters();
                if (endpoint.getSslContextParameters() == null) {
                    throw new InvalidParameterException("Need to specify the SSLContextParameters option here!");
                }
                setupServerWithSSLContext(params, scp);
            }
            if (getControllerDaemon() != null) {
                params.add("controllerDaemon", getControllerDaemon().toString());
            }
            if (getControllerSleepTimeMs() != null) {
                params.add("controllerSleepTimeMs", getControllerSleepTimeMs().toString());
            }
            if (getInboundBufferSize() != null) {
                params.add("inboundBufferSize", getInboundBufferSize().toString());
            }
            if (getMinThreads() != null) {
                params.add("minThreads", getMinThreads().toString());
            }
            if (getMaxThreads() != null) {
                params.add("maxThreads", getMaxThreads().toString());
            }
            if (getLowThreads() != null) {
                params.add("lowThreads", getLowThreads().toString());
            }
            if (getMaxQueued() != null) {
                params.add("maxQueued", getMaxQueued().toString());
            }
            if (getMaxConnectionsPerHost() != null) {
                params.add("maxConnectionsPerHost", getMaxConnectionsPerHost().toString());
            }
            if (getMaxTotalConnections() != null) {
                params.add("maxTotalConnections", getMaxTotalConnections().toString());
            }
            if (getOutboundBufferSize() != null) {
                params.add("outboundBufferSize", getOutboundBufferSize().toString());
            }
            if (getPersistingConnections() != null) {
                params.add("persistingConnections", getPersistingConnections().toString());
            }
            if (getPipeliningConnections() != null) {
                params.add("pipeliningConnections", getPipeliningConnections().toString());
            }
            if (getThreadMaxIdleTimeMs() != null) {
                params.add("threadMaxIdleTimeMs", getThreadMaxIdleTimeMs().toString());
            }
            if (getUseForwardedForHeader() != null) {
                params.add("useForwardedForHeader", getUseForwardedForHeader().toString());
            }
            if (getReuseAddress() != null) {
                params.add("reuseAddress", getReuseAddress().toString());
            }
            LOG.debug("Setting parameters: {} to server: {}", params, server);
            server.getContext().setParameters(params);
            servers.put(key, server);
            LOG.debug("Added server: {}", key);
            server.start();
        }
    }
}
Also used : InvalidParameterException(java.security.InvalidParameterException) Server(org.restlet.Server) Parameter(org.restlet.data.Parameter) SSLContextParameters(org.apache.camel.util.jsse.SSLContextParameters)

Example 79 with InvalidParameterException

use of java.security.InvalidParameterException in project HoloEverywhere by Prototik.

the class SimpleMonthView method setMonthParams.

/**
     * Sets all the parameters for displaying this week. The only required
     * parameter is the week number. Other parameters have a default value and
     * will only update if a new value is included, except for focus month,
     * which will always default to no focus month if no value is passed in. See
     * {@link #VIEW_PARAMS_HEIGHT} for more info on parameters.
     *
     * @param params A map of the new parameters, see
     *               {@link #VIEW_PARAMS_HEIGHT}
     */
public void setMonthParams(HashMap<String, Integer> params) {
    if (!params.containsKey(VIEW_PARAMS_MONTH) && !params.containsKey(VIEW_PARAMS_YEAR)) {
        throw new InvalidParameterException("You must specify the month and year for this view");
    }
    setTag(params);
    // We keep the current value for any params not present
    if (params.containsKey(VIEW_PARAMS_HEIGHT)) {
        mRowHeight = params.get(VIEW_PARAMS_HEIGHT);
        if (mRowHeight < MIN_HEIGHT) {
            mRowHeight = MIN_HEIGHT;
        }
    }
    if (params.containsKey(VIEW_PARAMS_SELECTED_DAY)) {
        mSelectedDay = params.get(VIEW_PARAMS_SELECTED_DAY);
    }
    // Allocate space for caching the day numbers and focus values
    mMonth = params.get(VIEW_PARAMS_MONTH);
    mYear = params.get(VIEW_PARAMS_YEAR);
    // Figure out what day today is
    final Time today = new Time(Time.getCurrentTimezone());
    today.setToNow();
    mHasToday = false;
    mToday = -1;
    mCalendar.set(Calendar.MONTH, mMonth);
    mCalendar.set(Calendar.YEAR, mYear);
    mCalendar.set(Calendar.DAY_OF_MONTH, 1);
    mDayOfWeekStart = mCalendar.get(Calendar.DAY_OF_WEEK);
    if (params.containsKey(VIEW_PARAMS_WEEK_START)) {
        mWeekStart = params.get(VIEW_PARAMS_WEEK_START);
    } else {
        mWeekStart = mCalendar.getFirstDayOfWeek();
    }
    mNumCells = DateTimePickerUtils.getDaysInMonth(mMonth, mYear);
    for (int i = 0; i < mNumCells; i++) {
        final int day = i + 1;
        if (sameDay(day, today)) {
            mHasToday = true;
            mToday = day;
        }
    }
    mNumRows = calculateNumRows();
    // Invalidate cached accessibility information.
    mNodeProvider.invalidateParent();
}
Also used : InvalidParameterException(java.security.InvalidParameterException) Time(android.text.format.Time) Paint(android.graphics.Paint)

Example 80 with InvalidParameterException

use of java.security.InvalidParameterException in project XPrivacy by M66B.

the class ActivitySettings method optionSave.

@SuppressLint("DefaultLocale")
private void optionSave() {
    if (uid == userId) {
        // Global settings
        PrivacyManager.setSetting(uid, PrivacyManager.cSettingUsage, Boolean.toString(cbUsage.isChecked()));
        PrivacyManager.setSetting(uid, PrivacyManager.cSettingParameters, Boolean.toString(cbParameters.isChecked()));
        PrivacyManager.setSetting(uid, PrivacyManager.cSettingValues, Boolean.toString(cbValues.isChecked()));
        if (userId == 0)
            PrivacyManager.setSetting(uid, PrivacyManager.cSettingLog, Boolean.toString(cbLog.isChecked()));
        PrivacyManager.setSetting(uid, PrivacyManager.cSettingSystem, Boolean.toString(cbSystem.isChecked()));
        PrivacyManager.setSetting(uid, PrivacyManager.cSettingExperimental, Boolean.toString(cbExperimental.isChecked()));
        PrivacyManager.setSetting(uid, PrivacyManager.cSettingHttps, Boolean.toString(cbHttps.isChecked()));
        PrivacyManager.setSetting(uid, PrivacyManager.cSettingAOSPMode, Boolean.toString(cbAOSP.isChecked()));
        PrivacyManager.setSetting(uid, PrivacyManager.cSettingConfidence, etConfidence.getText().toString());
    }
    // Quirks
    List<String> listQuirks = Arrays.asList(etQuirks.getText().toString().toLowerCase().replace(" ", "").split(","));
    PrivacyManager.setSetting(uid, PrivacyManager.cSettingFreeze, Boolean.toString(listQuirks.contains("freeze")));
    PrivacyManager.setSetting(uid, PrivacyManager.cSettingResolve, Boolean.toString(listQuirks.contains("resolve")));
    PrivacyManager.setSetting(uid, PrivacyManager.cSettingNoResolve, Boolean.toString(listQuirks.contains("noresolve")));
    PrivacyManager.setSetting(uid, PrivacyManager.cSettingPermMan, Boolean.toString(listQuirks.contains("permman")));
    PrivacyManager.setSetting(uid, PrivacyManager.cSettingIntentWall, Boolean.toString(listQuirks.contains("iwall")));
    PrivacyManager.setSetting(uid, PrivacyManager.cSettingSafeMode, Boolean.toString(listQuirks.contains("safemode")));
    PrivacyManager.setSetting(uid, PrivacyManager.cSettingTestVersions, Boolean.toString(listQuirks.contains("test")));
    PrivacyManager.setSetting(uid, PrivacyManager.cSettingUpdates, Boolean.toString(listQuirks.contains("updates")));
    PrivacyManager.setSetting(uid, PrivacyManager.cSettingOnDemandSystem, Boolean.toString(listQuirks.contains("odsystem")));
    PrivacyManager.setSetting(uid, PrivacyManager.cSettingWhitelistNoModify, Boolean.toString(listQuirks.contains("wnomod")));
    PrivacyManager.setSetting(uid, PrivacyManager.cSettingNoUsageData, Boolean.toString(listQuirks.contains("nousage")));
    // Notifications
    PrivacyManager.setSetting(uid, PrivacyManager.cSettingNotify, Boolean.toString(cbNotify.isChecked()));
    // On demand restricting
    if (uid == userId || (isApp || odSystem))
        PrivacyManager.setSetting(uid, PrivacyManager.cSettingOnDemand, Boolean.toString(cbOnDemand.isChecked()));
    if (uid != userId)
        PrivacyManager.setSetting(uid, PrivacyManager.cSettingBlacklist, Boolean.toString(cbBlacklist.isChecked()));
    // Random at boot
    PrivacyManager.setSetting(uid, PrivacyManager.cSettingRandom, cbRandom.isChecked() ? Boolean.toString(true) : null);
    // Serial#
    PrivacyManager.setSetting(uid, PrivacyManager.cSettingSerial, getValue(cbSerial, etSerial));
    // Set latitude
    if (cbLat.isChecked())
        PrivacyManager.setSetting(uid, PrivacyManager.cSettingLatitude, PrivacyManager.cValueRandom);
    else
        try {
            float lat = Float.parseFloat(etLat.getText().toString().replace(',', '.'));
            if (lat < -90 || lat > 90)
                throw new InvalidParameterException();
            PrivacyManager.setSetting(uid, PrivacyManager.cSettingLatitude, Float.toString(lat));
        } catch (Throwable ignored) {
            PrivacyManager.setSetting(uid, PrivacyManager.cSettingLatitude, null);
        }
    // Set longitude
    if (cbLon.isChecked())
        PrivacyManager.setSetting(uid, PrivacyManager.cSettingLongitude, PrivacyManager.cValueRandom);
    else
        try {
            float lon = Float.parseFloat(etLon.getText().toString().replace(',', '.'));
            if (lon < -180 || lon > 180)
                throw new InvalidParameterException();
            PrivacyManager.setSetting(uid, PrivacyManager.cSettingLongitude, Float.toString(lon));
        } catch (Throwable ignored) {
            PrivacyManager.setSetting(uid, PrivacyManager.cSettingLongitude, null);
        }
    // Set altitude
    if (cbAlt.isChecked())
        PrivacyManager.setSetting(uid, PrivacyManager.cSettingAltitude, PrivacyManager.cValueRandom);
    else
        try {
            float alt = Float.parseFloat(etAlt.getText().toString().replace(',', '.'));
            if (alt < -10000 || alt > 10000)
                throw new InvalidParameterException();
            PrivacyManager.setSetting(uid, PrivacyManager.cSettingAltitude, Float.toString(alt));
        } catch (Throwable ignored) {
            PrivacyManager.setSetting(uid, PrivacyManager.cSettingAltitude, null);
        }
    // Check Gsf ID
    try {
        String value = etGsfId.getText().toString();
        if (!"".equals(value))
            Long.parseLong(value.toLowerCase(), 16);
    } catch (NumberFormatException ignored) {
        etGsfId.setText("");
    }
    // Other settings
    PrivacyManager.setSetting(uid, PrivacyManager.cSettingMac, getValue(cbMac, etMac));
    PrivacyManager.setSetting(uid, PrivacyManager.cSettingIP, getValue(null, etIP));
    PrivacyManager.setSetting(uid, PrivacyManager.cSettingImei, getValue(cbImei, etImei));
    PrivacyManager.setSetting(uid, PrivacyManager.cSettingPhone, getValue(cbPhone, etPhone));
    PrivacyManager.setSetting(uid, PrivacyManager.cSettingId, getValue(cbId, etId));
    PrivacyManager.setSetting(uid, PrivacyManager.cSettingGsfId, getValue(cbGsfId, etGsfId));
    PrivacyManager.setSetting(uid, PrivacyManager.cSettingAdId, getValue(cbAdId, etAdId));
    PrivacyManager.setSetting(uid, PrivacyManager.cSettingMcc, getValue(null, etMcc));
    PrivacyManager.setSetting(uid, PrivacyManager.cSettingMnc, getValue(null, etMnc));
    PrivacyManager.setSetting(uid, PrivacyManager.cSettingCountry, getValue(cbCountry, etCountry));
    PrivacyManager.setSetting(uid, PrivacyManager.cSettingOperator, getValue(null, etOperator));
    PrivacyManager.setSetting(uid, PrivacyManager.cSettingIccId, getValue(null, etIccId));
    PrivacyManager.setSetting(uid, PrivacyManager.cSettingCid, getValue(null, etCid));
    PrivacyManager.setSetting(uid, PrivacyManager.cSettingLac, getValue(null, etLac));
    PrivacyManager.setSetting(uid, PrivacyManager.cSettingSubscriber, getValue(cbSubscriber, etSubscriber));
    PrivacyManager.setSetting(uid, PrivacyManager.cSettingSSID, getValue(cbSSID, etSSID));
    PrivacyManager.setSetting(uid, PrivacyManager.cSettingUa, getValue(null, etUa));
    finish();
    // Refresh view
    if (uid == userId) {
        Intent intent = new Intent(ActivitySettings.this, ActivityMain.class);
        startActivity(intent);
    } else {
        Intent intent = new Intent(ActivitySettings.this, ActivityApp.class);
        intent.putExtra(ActivityApp.cUid, uid);
        intent.putExtra(ActivityApp.cAction, ActivityApp.cActionRefresh);
        startActivity(intent);
    }
}
Also used : InvalidParameterException(java.security.InvalidParameterException) Intent(android.content.Intent) SuppressLint(android.annotation.SuppressLint)

Aggregations

InvalidParameterException (java.security.InvalidParameterException)135 SecureRandom (java.security.SecureRandom)15 ActionEvent (com.cloud.event.ActionEvent)11 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)11 IOException (java.io.IOException)10 ArrayList (java.util.ArrayList)10 Map (java.util.Map)10 LoadBalancerVO (com.cloud.network.dao.LoadBalancerVO)9 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)8 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)8 Paint (android.graphics.Paint)7 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)7 DB (com.cloud.utils.db.DB)7 File (java.io.File)7 Properties (java.util.Properties)7 NimbusClient (backtype.storm.utils.NimbusClient)6 FirewallRule (com.cloud.network.rules.FirewallRule)6 InvalidKeyException (java.security.InvalidKeyException)6 Time (android.text.format.Time)4 FileNotFoundException (java.io.FileNotFoundException)4