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();
}
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<>();
}
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());
}
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);
}
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;
}
Aggregations