Search in sources :

Example 56 with HashMap

use of java.util.HashMap in project cas by apereo.

the class DelegatedClientAuthenticationAction method hasDelegationRequestFailed.

/**
     * Determine if request has errors.
     *
     * @param request the request
     * @param status  the status
     * @return the optional model and view, if request is an error.
     */
public static Optional<ModelAndView> hasDelegationRequestFailed(final HttpServletRequest request, final int status) {
    final Map<String, String[]> params = request.getParameterMap();
    if (params.containsKey("error") || params.containsKey("error_code") || params.containsKey("error_description") || params.containsKey("error_message")) {
        final Map<String, Object> model = new HashMap<>();
        if (params.containsKey("error_code")) {
            model.put("code", StringEscapeUtils.escapeHtml4(request.getParameter("error_code")));
        } else {
            model.put("code", status);
        }
        model.put("error", StringEscapeUtils.escapeHtml4(request.getParameter("error")));
        model.put("reason", StringEscapeUtils.escapeHtml4(request.getParameter("error_reason")));
        if (params.containsKey("error_description")) {
            model.put("description", StringEscapeUtils.escapeHtml4(request.getParameter("error_description")));
        } else if (params.containsKey("error_message")) {
            model.put("description", StringEscapeUtils.escapeHtml4(request.getParameter("error_message")));
        }
        model.put(CasProtocolConstants.PARAMETER_SERVICE, request.getAttribute(CasProtocolConstants.PARAMETER_SERVICE));
        model.put("client", StringEscapeUtils.escapeHtml4(request.getParameter("client_name")));
        LOGGER.debug("Delegation request has failed. Details are [{}]", model);
        return Optional.of(new ModelAndView("casPac4jStopWebflow", model));
    }
    return Optional.empty();
}
Also used : HashMap(java.util.HashMap) ModelAndView(org.springframework.web.servlet.ModelAndView)

Example 57 with HashMap

use of java.util.HashMap in project cas by apereo.

the class InCommonRSAttributeReleasePolicy method getAttributesForSamlRegisteredService.

@Override
protected Map<String, Object> getAttributesForSamlRegisteredService(final Map<String, Object> attributes, final SamlRegisteredService service, final ApplicationContext applicationContext, final SamlRegisteredServiceCachingMetadataResolver resolver, final SamlRegisteredServiceServiceProviderMetadataFacade facade, final EntityDescriptor entityDescriptor) {
    final EntityAttributesPredicate.Candidate attr = new EntityAttributesPredicate.Candidate("http://macedir.org/entity-category");
    attr.setValues(Collections.singletonList("http://refeds.org/category/research-and-scholarship"));
    LOGGER.debug("Loading entity attribute predicate filter for candidate [{}] with values [{}]", attr.getName(), attr.getValues());
    final EntityAttributesPredicate predicate = new EntityAttributesPredicate(Collections.singletonList(attr), true);
    if (predicate.apply(entityDescriptor)) {
        return authorizeReleaseOfAllowedAttributes(attributes);
    }
    return new HashMap<>();
}
Also used : HashMap(java.util.HashMap) EntityAttributesPredicate(org.opensaml.saml.common.profile.logic.EntityAttributesPredicate)

Example 58 with HashMap

use of java.util.HashMap in project bazel by bazelbuild.

the class AspectCollection method create.

/**
   *  Creates an {@link AspectCollection} from an ordered list of aspects and
   *  a set of visible aspects.
   *
   *  The order of aspects is reverse to the order in which they originated, with
   *  the earliest originating occurring last in the list.
   */
public static AspectCollection create(Iterable<Aspect> aspectPath, Set<AspectDescriptor> visibleAspects) throws AspectCycleOnPathException {
    LinkedHashMap<AspectDescriptor, Aspect> aspectMap = deduplicateAspects(aspectPath);
    LinkedHashMap<AspectDescriptor, ArrayList<AspectDescriptor>> deps = new LinkedHashMap<>();
    // deps[aspect] contains all aspects that 'aspect' needs, in reverse order.
    for (Entry<AspectDescriptor, Aspect> aspect : ImmutableList.copyOf(aspectMap.entrySet()).reverse()) {
        boolean needed = visibleAspects.contains(aspect.getKey());
        for (AspectDescriptor depAspectDescriptor : deps.keySet()) {
            if (depAspectDescriptor.equals(aspect.getKey())) {
                continue;
            }
            Aspect depAspect = aspectMap.get(depAspectDescriptor);
            if (depAspect.getDefinition().getRequiredProvidersForAspects().isSatisfiedBy(aspect.getValue().getDefinition().getAdvertisedProviders())) {
                deps.get(depAspectDescriptor).add(aspect.getKey());
                needed = true;
            }
        }
        if (needed && !deps.containsKey(aspect.getKey())) {
            deps.put(aspect.getKey(), new ArrayList<AspectDescriptor>());
        }
    }
    // Record only the needed aspects from all aspects, in correct order.
    ImmutableList<AspectDescriptor> neededAspects = ImmutableList.copyOf(deps.keySet()).reverse();
    // Calculate visible aspect paths.
    HashMap<AspectDescriptor, AspectDeps> aspectPaths = new HashMap<>();
    ImmutableSet.Builder<AspectDeps> visibleAspectPaths = ImmutableSet.builder();
    for (AspectDescriptor visibleAspect : visibleAspects) {
        visibleAspectPaths.add(buildAspectDeps(visibleAspect, aspectPaths, deps));
    }
    return new AspectCollection(ImmutableSet.copyOf(neededAspects), visibleAspectPaths.build());
}
Also used : LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Aspect(com.google.devtools.build.lib.packages.Aspect) LinkedHashMap(java.util.LinkedHashMap) ImmutableSet(com.google.common.collect.ImmutableSet) AspectDescriptor(com.google.devtools.build.lib.packages.AspectDescriptor)

Example 59 with HashMap

use of java.util.HashMap in project bazel by bazelbuild.

the class BuildView method setArtifactRoots.

/**
   * Sets the possible artifact roots in the artifact factory. This allows the factory to resolve
   * paths with unknown roots to artifacts.
   */
// for BuildViewTestCase
@VisibleForTesting
public void setArtifactRoots(ImmutableMap<PackageIdentifier, Path> packageRoots) {
    Map<Path, Root> rootMap = new HashMap<>();
    Map<PackageIdentifier, Root> realPackageRoots = new HashMap<>();
    for (Map.Entry<PackageIdentifier, Path> entry : packageRoots.entrySet()) {
        Root root = rootMap.get(entry.getValue());
        if (root == null) {
            root = Root.asSourceRoot(entry.getValue(), entry.getKey().getRepository().isMain());
            rootMap.put(entry.getValue(), root);
        }
        realPackageRoots.put(entry.getKey(), root);
    }
    // Source Artifact roots:
    getArtifactFactory().setPackageRoots(realPackageRoots);
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) Root(com.google.devtools.build.lib.actions.Root) PackageIdentifier(com.google.devtools.build.lib.cmdline.PackageIdentifier) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 60 with HashMap

use of java.util.HashMap in project bazel by bazelbuild.

the class ActionCacheChecker method getCachedInputs.

@Nullable
public Iterable<Artifact> getCachedInputs(Action action, PackageRootResolver resolver) throws PackageRootResolutionException, InterruptedException {
    ActionCache.Entry entry = getCacheEntry(action);
    if (entry == null || entry.isCorrupted()) {
        return ImmutableList.of();
    }
    List<PathFragment> outputs = new ArrayList<>();
    for (Artifact output : action.getOutputs()) {
        outputs.add(output.getExecPath());
    }
    List<PathFragment> inputExecPaths = new ArrayList<>();
    for (String path : entry.getPaths()) {
        PathFragment execPath = new PathFragment(path);
        // most efficient.
        if (!outputs.contains(execPath)) {
            inputExecPaths.add(execPath);
        }
    }
    // Note that this method may trigger a violation of the desirable invariant that getInputs()
    // is a superset of getMandatoryInputs(). See bug about an "action not in canonical form"
    // error message and the integration test test_crosstool_change_and_failure().
    Map<PathFragment, Artifact> allowedDerivedInputsMap = new HashMap<>();
    for (Artifact derivedInput : action.getAllowedDerivedInputs()) {
        if (!derivedInput.isSourceArtifact()) {
            allowedDerivedInputsMap.put(derivedInput.getExecPath(), derivedInput);
        }
    }
    List<Artifact> inputArtifacts = new ArrayList<>();
    List<PathFragment> unresolvedPaths = new ArrayList<>();
    for (PathFragment execPath : inputExecPaths) {
        Artifact artifact = allowedDerivedInputsMap.get(execPath);
        if (artifact != null) {
            inputArtifacts.add(artifact);
        } else {
            // Remember this execPath, we will try to resolve it as a source artifact.
            unresolvedPaths.add(execPath);
        }
    }
    Map<PathFragment, Artifact> resolvedArtifacts = artifactResolver.resolveSourceArtifacts(unresolvedPaths, resolver);
    if (resolvedArtifacts == null) {
        // We are missing some dependencies. We need to rerun this update later.
        return null;
    }
    for (PathFragment execPath : unresolvedPaths) {
        Artifact artifact = resolvedArtifacts.get(execPath);
        // was used before) and will force action execution.
        if (artifact != null) {
            inputArtifacts.add(artifact);
        }
    }
    return inputArtifacts;
}
Also used : ActionCache(com.google.devtools.build.lib.actions.cache.ActionCache) HashMap(java.util.HashMap) Entry(com.google.devtools.build.lib.actions.cache.ActionCache.Entry) ArrayList(java.util.ArrayList) PathFragment(com.google.devtools.build.lib.vfs.PathFragment) Nullable(javax.annotation.Nullable)

Aggregations

HashMap (java.util.HashMap)29051 ArrayList (java.util.ArrayList)7306 Map (java.util.Map)6569 Test (org.junit.Test)6315 List (java.util.List)3204 IOException (java.io.IOException)2753 HashSet (java.util.HashSet)2366 Set (java.util.Set)1616 File (java.io.File)1440 LinkedHashMap (java.util.LinkedHashMap)1417 Iterator (java.util.Iterator)1273 Test (org.testng.annotations.Test)1048 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)865 ApiResponse (io.kubernetes.client.ApiResponse)707 Pair (io.kubernetes.client.Pair)707 ProgressResponseBody (io.kubernetes.client.ProgressResponseBody)707 Date (java.util.Date)590 LinkedList (java.util.LinkedList)574 Properties (java.util.Properties)507 URI (java.net.URI)474