use of lombok.ToString in project cas by apereo.
the class WsFederationCredentialsToPrincipalResolver method extractPrincipalId.
/**
* Extracts the principalId.
*
* @param credentials the credentials
* @return the principal id
*/
@Override
protected String extractPrincipalId(final Credential credentials, final Principal currentPrincipal) {
final WsFederationCredential wsFedCredentials = (WsFederationCredential) credentials;
final Map<String, List<Object>> attributes = wsFedCredentials.getAttributes();
LOGGER.debug("Credential attributes provided are: [{}]", attributes);
final String idAttribute = this.configuration.getIdentityAttribute();
if (attributes.containsKey(idAttribute)) {
LOGGER.debug("Extracting principal id from attribute [{}]", this.configuration.getIdentityAttribute());
final List<Object> idAttributeAsList = attributes.get(this.configuration.getIdentityAttribute());
if (idAttributeAsList.size() > 1) {
LOGGER.warn("Found multiple values for id attribute [{}].", idAttribute);
}
final String principalId = idAttributeAsList.get(0).toString();
LOGGER.debug("Principal Id extracted from credentials: [{}]", principalId);
return principalId;
}
LOGGER.warn("Credential attributes do not include an attribute for [{}]. " + "This will prohibit CAS to construct a meaningful authenticated principal. " + "Examine the released claims and ensure [{}] is allowed", idAttribute, idAttribute);
return null;
}
use of lombok.ToString in project oap by oaplatform.
the class Tree method trace.
public String trace(List<?> query, Predicate<T> filter) {
final HashMap<T, HashMap<Integer, TraceOperationTypeValues>> result = new HashMap<>();
final long[][] longQuery = convertQueryToLong(query);
trace(root, longQuery, result, new TraceBuffer(), true);
final String queryStr = "query = " + Stream.of(query).zipWithIndex().map(p -> dimensions.get(p._2).name + ":" + printValue(p._1)).collect(joining(",", "[", "]")) + "\n";
final String out = result.entrySet().stream().filter(e -> filter.test(e.getKey())).map(e -> e.getKey().toString() + ": \n" + e.getValue().entrySet().stream().map(dv -> {
final Dimension dimension = dimensions.get(dv.getKey());
return " " + dimension.name + "/" + dv.getKey() + ": " + dv.getValue().toString(dimension) + " " + queryToString(query, dv.getKey());
}).collect(joining("\n"))).collect(joining("\n"));
return queryStr + (out.length() > 0 ? "Expecting:\n" + out : "ALL OK");
}
use of lombok.ToString in project oap by oaplatform.
the class Client method execute.
@SneakyThrows
private Optional<Response> execute(HttpUriRequest request, Map<String, Object> headers, long timeout) {
try {
headers.forEach((name, value) -> request.setHeader(name, value == null ? "" : value.toString()));
Future<HttpResponse> future = client.execute(request, FUTURE_CALLBACK);
HttpResponse response = timeout == FOREVER ? future.get() : future.get(timeout, MILLISECONDS);
Map<String, String> responsHeaders = headers(response);
Response result;
if (response.getEntity() != null) {
HttpEntity entity = response.getEntity();
try (InputStream is = entity.getContent()) {
result = new Response(response.getStatusLine().getStatusCode(), response.getStatusLine().getReasonPhrase(), responsHeaders, Optional.ofNullable(entity.getContentType()).map(ct -> ContentType.parse(entity.getContentType().getValue())), ByteStreams.toByteArray(is));
}
} else
result = new Response(response.getStatusLine().getStatusCode(), response.getStatusLine().getReasonPhrase(), responsHeaders);
builder.onSuccess.accept(this);
return Optional.of(result);
} catch (ExecutionException e) {
final ExecutionException newEx = new ExecutionException(request.getURI().toString(), e.getCause());
builder.onError.accept(this, newEx);
throw newEx;
} catch (IOException e) {
final ExecutionException newEx = new ExecutionException(request.getURI().toString(), e);
builder.onError.accept(this, newEx);
throw newEx;
} catch (InterruptedException | TimeoutException e) {
builder.onTimeout.accept(this);
return Optional.empty();
}
}
use of lombok.ToString in project jcabi-github by jcabi.
the class MkComments method post.
@Override
public Comment post(final String text) throws IOException {
this.storage.lock();
final int number;
try {
final String timestamp = new Github.Time().toString();
number = 1 + this.storage.xml().nodes("//comment/number").size();
this.storage.apply(new Directives().xpath(this.xpath()).add("comment").add("number").set(Integer.toString(number)).up().add("url").set(String.format(// @checkstyle LineLength (1 line)
"https://api.jcabi-github.invalid/repos/%s/%s/issues/comments/%d", this.repo.user(), this.repo.repo(), number)).up().add("body").set(text).up().add("user").add("login").set(this.self).up().up().add("created_at").set(timestamp).up().add("updated_at").set(timestamp));
} finally {
this.storage.unlock();
}
Logger.info(this, "comment #%d posted to issue #%d by %s: %[text]s", number, this.issue().number(), this.self, text);
return this.get(number);
}
use of lombok.ToString in project sql-boot by sql-boot.
the class SqlResourceType method read.
@Override
public Stream<DbResource> read(final Uri uri) throws BootException {
final Map<String, Object> variables = new HashMap<>();
variables.put("uri", uri);
return sqlQuery.select(variables).map(o -> {
final List<Object> path = o.entrySet().stream().filter(v -> (v.getKey().startsWith("@") || v.getKey().startsWith("_"))).map(Entry::getValue).collect(toList());
final String name = path.get(path.size() - 1).toString();
final Map<String, Object> headers = o.entrySet().stream().collect(toMap(k -> strip(strip(k.getKey(), "@"), "_"), v -> ofNullable(v.getValue()).orElse(""), (a, b) -> a, LinkedHashMap::new));
return new DbResourceImpl(name, this, new DbUri(this.name(), path.stream().map(Object::toString).collect(toList())), headers);
});
}
Aggregations