public boolean isSatisfied(Condition[] conds, Dictionary<Object, Object> context) { for (int i = 0, length = conds.length; i < length; i++) { if (!conds[i].isSatisfied()) return false; } return true; } }
/** * Returns the string representation of this {@code ConditionInfo}. The * string is created by calling the {@code getEncoded} method on this * {@code ConditionInfo}. * * @return The string representation of this {@code ConditionInfo}. */ @Override public String toString() { return getEncoded(); }
escapeString(args[i], output); output.append('\"');
@Override public boolean matchDNChain(String pattern) { if (contributor == null) return false; return BundleSignerCondition.getCondition(contributor, new ConditionInfo(BundleSignerCondition.class.getName(), new String[] {pattern})).isSatisfied(); }
if (!CONDITION_TYPE.equals(info.getType())) throw new IllegalArgumentException("ConditionInfo must be of type \"" + CONDITION_TYPE + "\""); String[] args = info.getArgs(); if (args.length != 1 && args.length != 2) throw new IllegalArgumentException("Illegal number of args: " + args.length); Filter filter = null; try { filter = FrameworkUtil.createFilter("(location=" + escapeLocation(args[0]) + ")"); } catch (InvalidSyntaxException e) {
String imsi = conditionInfo.getArgs()[0]; int length = imsi.length(); if (length > IMSI_LENGTH) {
@Override public void printPolicies(PrintStream os) { /* * Scan permission table */ // First get the permissions table ConditionalPermissionUpdate cpu = cpa.newConditionalPermissionUpdate(); List<ConditionalPermissionInfo> piList = cpu.getConditionalPermissionInfos(); for (ConditionalPermissionInfo pInfo : piList) { os.println(pInfo.getEncoded()); } }
argsList.add(unescapeString(encoded, begin, pos)); pos++;
/** * Checks whether the condition may change during the lifetime of the UserPromptCondition object. * This depends on the permission level given in * {@link UserPromptCondition#getCondition(Bundle, ConditionInfo)}. * <ul> * <li>ONESHOT - true</li> * <li>SESSION - true, if the application model's session lifetime is * shorter than the UserPromptCondition object lifetime</li> * <li>BLANKET - false</li> * </ul> * If the system supports separately accessible permission management GUI, * then this function may also return true for SESSION and BLANKET. * * @return True, if the condition can change. */ public boolean isMutable() { lookForImplementation(); if (realUserPromptCondition!=null) { return realUserPromptCondition.isMutable(); } else { // since we don't know what the actual status is, we cannot say // "the condition cannot change anymore" return true; } }
/** * Checks if the {@link #isSatisfied()} method needs to prompt the user, thus cannot * give results instantly. * This depends on the permission level given in * {@link UserPromptCondition#getCondition(Bundle, ConditionInfo)}. * <ul> * <li>ONESHOT - isPostponed always returns true. The user is prompted for question every time.</li> * <li>SESSION - isPostponed returns true until the user decides either yes or no for the current session.</li> * <li>BLANKET - isPostponed returns true until the user decides either always or never.</li> * </ul> * Regardless of the session level, the user is always given the option to reject the prompt * permanently, as if BLANKET/never was chosen. In this case, the question is not postponed * anymore, and {@link #isSatisfied()} returns false.<br/> * If the system supports an separately accessible permission management GUI, * that may reset the condition * to its initial state. * * @return True, if user interaction is needed. */ public boolean isPostponed() { lookForImplementation(); if (realUserPromptCondition!=null) { return realUserPromptCondition.isPostponed(); } else { return true; } }
public boolean matchDNChain(String pattern) { if (contributor == null) return false; return BundleSignerCondition.getCondition(contributor, new ConditionInfo(BundleSignerCondition.class.getName(), new String[] {pattern})).isSatisfied(); }
/** * Checks an array of UserPrompt conditions. * * @param conds The array containing the UserPrompt conditions to evaluate. * @param context Storage area for evaluation. The {@link org.osgi.service.condpermadmin.ConditionalPermissionAdmin} * may evaluate a condition several times for one permission check, so this context * will be used to store results of ONESHOT questions. This way asking the same question * twice in a row can be avoided. If context is null, temporary results will not be stored. * @return True, if all conditions are satisfied. * @throws NullPointerException if conds is null. */ public boolean isSatisfied(Condition[] conds, Dictionary context) { lookForImplementation(); if (realUserPromptCondition!=null) { return realUserPromptCondition.isSatisfied(conds,context); } else { // paranoid security option return false; } } }
String imei = conditionInfo.getArgs()[0]; int length = imei.length(); if (length > IMEI_LENGTH) {
/** * Returns the string representation of this {@code ConditionInfo}. The * string is created by calling the {@code getEncoded} method on this * {@code ConditionInfo}. * * @return The string representation of this {@code ConditionInfo}. */ @Override public String toString() { return getEncoded(); }
public boolean matchDNChain(String pattern) { if (contributor == null) return false; return BundleSignerCondition.getCondition(contributor, new ConditionInfo(BundleSignerCondition.class.getName(), new String[] {pattern})).isSatisfied(); }
/** * Displays the prompt string to * the user and returns true if the user accepts. Depending on the * amount of levels the condition is assigned to, the prompt may have * multiple accept buttons and one of them can be selected by default (see * default level parameter at {@link UserPromptCondition#getCondition(Bundle, ConditionInfo)}). * It must always be possible for the user * to stop further prompting of this question, even with ONESHOT and SESSION levels. * In case of BLANKET * and SESSION levels, it is possible that the user has already answered the question, * in this case there will be no prompting, but immediate return with the previous answer. * * @return True if the user accepts the prompt (or accepts any prompt in * case there are multiple permission levels). */ public boolean isSatisfied() { lookForImplementation(); if (realUserPromptCondition!=null) { return realUserPromptCondition.isSatisfied(); } else { // paranoid security option return false; } }
String[] args = conditionInfo.getArgs(); if (args==null) throw new NullPointerException("args"); if (args.length!=4) throw new IllegalArgumentException("args.length=="+args.length+" (should be 4)");
public boolean isSatisfied(Condition[] conds, Dictionary<Object, Object> context) { for (int i = 0, length = conds.length; i < length; i++) { if (!conds[i].isSatisfied()) return false; } return true; } }
@Override public boolean isSatisfied(Condition[] conds, Dictionary<Object, Object> context) { for (int i = 0, length = conds.length; i < length; i++) { if (!conds[i].isSatisfied()) return false; } return true; } }