本文整理了Java中org.restlet.util.Series
类的一些代码示例,展示了Series
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Series
类的具体详情如下:
包路径:org.restlet.util.Series
类名称:Series
[英]Modifiable list of entries with many helper methods. Note that this class uses the Parameter class as the template type. This allows you to use an instance of this class as any other java.util.List, in particular all the helper methods in java.util.Collections.
[中]具有许多辅助方法的可修改条目列表。注意,这个类使用参数类作为模板类型。这允许您像使用任何其他java一样使用这个类的实例。util。列表,尤其是java中的所有帮助程序方法。util。收藏。
代码示例来源:origin: internetarchive/heritrix3
/**
* Create an HTTPS restlet Server instance matching the given parameters.
*
* @param port
* @param address
* @param keystorePath
* @param keystorePassword
* @param keyPassword
*/
protected void setupServer(int port, String address, String keystorePath, String keystorePassword, String keyPassword) {
Server server = new Server(Protocol.HTTPS,address,port,null);
component.getServers().add(server);
server.getContext().getParameters().add("keystorePath", keystorePath);
server.getContext().getParameters().add("keystorePassword", keystorePassword);
server.getContext().getParameters().add("keyPassword", keyPassword);
}
代码示例来源:origin: internetarchive/heritrix3
public static List<Flash> getFlashes(Request request) {
List<Flash> flashes = new LinkedList<Flash>();
Series<Cookie> cookies = request.getCookies();
String flashdrops = cookies.getFirstValue("flashdrop");
if (StringUtils.isBlank(flashdrops)) {
return flashes;
}
for (String dropbox : flashdrops.split(",")) {
if(dropbox!=null) {
Flash flash = dropboxes.remove(Long.parseLong(dropbox));
if(flash!=null) {
flashes.add(flash);
}
}
}
return flashes;
}
代码示例来源:origin: org.restlet.jse/org.restlet.example
@Override
protected int beforeHandle(Request request, Response response) {
Cookie cookie = request.getCookies().getFirst("Credentials");
if (cookie != null) {
// Extract the challenge response from the cookie
String[] credentials = cookie.getValue().split("=");
if (credentials.length == 2) {
String identifier = credentials[0];
String secret = credentials[1];
request.setChallengeResponse(new ChallengeResponse(
ChallengeScheme.HTTP_COOKIE, identifier, secret));
}
} else if (Method.POST.equals(request.getMethod())
&& request.getResourceRef().getQueryAsForm().getFirst("login") != null) {
// Intercepting a login form
Form credentials = new Form(request.getEntity());
String identifier = credentials.getFirstValue("identifier");
String secret = credentials.getFirstValue("secret");
request.setChallengeResponse(new ChallengeResponse(
ChallengeScheme.HTTP_COOKIE, identifier, secret));
// Continue call processing to return the target representation if
// authentication is successful or a new login page
request.setMethod(Method.GET);
}
return super.beforeHandle(request, response);
}
代码示例来源:origin: org.restlet.osgi/org.restlet
boolean result = equals(ALL) || equals(included);
if (getMainType().equals(includedMediaType.getMainType())) {
if (getSubType().equals(includedMediaType.getSubType())) {
for (int i = 0; result && i < getParameters().size(); i++) {
Parameter param = getParameters().get(i);
Parameter includedParam = includedMediaType
.getParameters().getFirst(param.getName());
result = (includedParam != null && param.getValue()
.equals(includedParam.getValue()));
代码示例来源:origin: com.github.ansell.oas/oas-webservice-impl
for(String parameter : getContext().getAttributes().keySet())
getContext().getAttributes().get(parameter));
for(Parameter parameter : getContext().getParameters())
this.log.trace("context parameter: <{}> <{}>", parameter.getName(), parameter.getValue());
this.getContext().getParameters().getFirstValue("oasproperties", true, "oas");
this.log.info("Setting up property util using: {}", propertyBundleName);
this.propertyUtil = new PropertyUtil(propertyBundleName);
代码示例来源:origin: cdelmas/microservices-comparison
@Get("json")
public List<CarRepresentation> all() {
List<io.github.cdelmas.spike.common.domain.Car> cars = carRepository.all();
getResponse().getHeaders().add("total-count", String.valueOf(cars.size()));
return cars.stream().map(c -> {
CarRepresentation carRepresentation = new CarRepresentation(c);
carRepresentation.addLink(Link.self(new Reference(getReference()).addSegment(String.valueOf(c.getId())).toString()));
return carRepresentation;
}).collect(toList());
}
代码示例来源:origin: org.restlet.osgi/org.restlet
if ("realm".equals(param.getName())) {
challenge.setRealm(param.getValue());
} else {
challenge.getParameters().add(param);
Context.getCurrentLogger()
.log(Level.WARNING,
"Unable to parse the challenge request header parameter",
Context.getCurrentLogger()
.log(Level.WARNING,
"Unable to parse the challenge request header parameter",
代码示例来源:origin: DeviceConnect/DeviceConnect-Android
Context context = new Context(sLogger);
AuthorizationServerResource.init(context);
Request request = new Request();
request.setOriginalRef(new Reference(DUMMY_ORIGINAL_REF));
Response response = new Response(request);
request.setResourceRef(new Reference(DUMMY_REFERENCE));
Series<Cookie> cookies = new Series<>(Cookie.class);
cookies.add(AuthorizationBaseServerResource.ClientCookieID, sessionId);
request.setCookies(cookies);
代码示例来源:origin: org.restlet.jse/org.restlet.example
@Override
protected void afterHandle(Request request, Response response) {
super.afterHandle(request, response);
Cookie cookie = request.getCookies().getFirst("Credentials");
if (request.getClientInfo().isAuthenticated() && (cookie == null)) {
String identifier = request.getChallengeResponse().getIdentifier();
String secret = new String(request.getChallengeResponse()
.getSecret());
CookieSetting cookieSetting = new CookieSetting("Credentials",
identifier + "=" + secret);
cookieSetting.setAccessRestricted(true);
cookieSetting.setPath("/");
cookieSetting.setComment("Unsecured cookie based authentication");
cookieSetting.setMaxAge(30);
response.getCookieSettings().add(cookieSetting);
}
}
代码示例来源:origin: com.noelios.restlet/com.noelios.restlet.ext.servlet
/**
* Returns the list of request headers.
*
* @return The list of request headers.
*/
@Override
@SuppressWarnings("unchecked")
public Series<Parameter> getRequestHeaders() {
if (this.requestHeaders == null) {
this.requestHeaders = new Form();
// Copy the headers from the request object
String headerName;
String headerValue;
for (final Enumeration<String> names = getRequest()
.getHeaderNames(); names.hasMoreElements();) {
headerName = names.nextElement();
for (final Enumeration<String> values = getRequest()
.getHeaders(headerName); values.hasMoreElements();) {
headerValue = values.nextElement();
this.requestHeaders.add(new Parameter(headerName,
headerValue));
}
}
}
return this.requestHeaders;
}
代码示例来源:origin: DeviceConnect/DeviceConnect-Android
Series<Cookie> cookies = new Series<>(Cookie.class);
cookies.add(AuthorizationBaseServerResource.ClientCookieID, sessionId);
Request request = new Request();
Reference requestReference = new Reference(DUMMY_ORIGINAL_REF);
requestReference.addQueryParameter(LoginPageServerResource.USER_ID, userId);
requestReference.addQueryParameter(LoginPageServerResource.PASSWORD, password);
requestReference.addQueryParameter(LoginPageServerResource.CONTINUE,
RedirectRepresentation.RedirectProc.requestAuthorization.toString());
LoginPageServerResource.getQuery().put(LoginPageServerResource.CONTINUE, continues);
request.setCookies(cookies);
request.setOriginalRef(requestReference);
request.setResourceRef(requestReference);
Response response = new Response(request);
代码示例来源:origin: org.restlet.osgi/org.restlet
/**
* Extract the media parameters. Only leave as the quality parameter if
* found. Modifies the parameters list.
*
* @param parameters
* All the preference parameters.
* @return The media parameters.
*/
protected Series<Parameter> extractMediaParams(Series<Parameter> parameters) {
Series<Parameter> result = null;
boolean qualityFound = false;
Parameter param = null;
if (parameters != null) {
result = new Series<Parameter>(Parameter.class);
for (final Iterator<Parameter> iter = parameters.iterator(); !qualityFound
&& iter.hasNext();) {
param = iter.next();
if (param.getName().equals("q")) {
qualityFound = true;
} else {
iter.remove();
result.add(param);
}
}
}
return result;
}
代码示例来源:origin: jtalks-org/jcommune
private void addHeaderAttribute(ClientResource clientResource, String attrName, String attrValue) {
ConcurrentMap<String, Object> attrs = clientResource.getRequest().getAttributes();
Series<Header> headers = (Series<Header>) attrs.get(HeaderConstants.ATTRIBUTE_HEADERS);
if (headers == null) {
headers = new Series<>(Header.class);
Series<Header> prev = (Series<Header>) attrs.putIfAbsent(HeaderConstants.ATTRIBUTE_HEADERS, headers);
if (prev != null) {
headers = prev;
}
}
headers.add(attrName, attrValue);
}
代码示例来源:origin: com.github.ansell.restlet-utils/restlet-utils
/**
* Test method for {@link org.restlet.security.Realm#setParameters(org.restlet.util.Series)}.
*/
@Test
public final void testSetParameters()
{
Assert.assertEquals(0, this.testRealm.getParameters().size());
final List<Parameter> list = new ArrayList<Parameter>(1);
list.add(new Parameter("testName", "123"));
this.testRealm.setParameters(new Series<Parameter>(Parameter.class, list));
Assert.assertEquals(1, this.testRealm.getParameters().size());
final Parameter parameter = this.testRealm.getParameters().get(0);
Assert.assertEquals("testName", parameter.getName());
Assert.assertEquals("123", parameter.getValue());
}
代码示例来源:origin: org.restlet/org.restlet
/**
* Returns a list of all the values associated to the parameter name.
*
* @param name
* The parameter name.
* @param ignoreCase
* Indicates if the name comparison is case sensitive.
* @return The list of values.
*/
public Series<E> subList(String name, boolean ignoreCase) {
final Series<E> result = createSeries(null);
for (final E param : this) {
if (equals(param.getName(), name, ignoreCase)) {
result.add(param);
}
}
return result;
}
代码示例来源:origin: org.restlet.jse/org.restlet.ext.html
/**
* Creates the media type of a multipart form which must include the used
* boundary.
*
* @param boundary
* The multipart boundary.
* @return The multipart media type.
*/
private static MediaType createMultipartMediaType(String boundary) {
Series<Parameter> params = new Series<Parameter>(Parameter.class);
params.add("boundary", boundary);
MediaType result = new MediaType(
MediaType.MULTIPART_FORM_DATA.getName(), params);
return result;
}
代码示例来源:origin: org.restlet/org.restlet
boolean found = false;
for (final Iterator<E> iter = iterator(); iter.hasNext();) {
param = iter.next();
if (equals(param.getName(), name, ignoreCase)) {
if (found) {
param.setValue(value);
result = param;
add(name, value);
代码示例来源:origin: org.restlet.jee/org.restlet.ext.wadl
result = new Series<Parameter>(Parameter.class);
result.add(parameterInfo.getName(), parameterInfo.getFixed());
} else if (ParameterStyle.HEADER.equals(parameterInfo.getStyle())) {
result = getHeaders().subList(parameterInfo.getName());
} else if (ParameterStyle.TEMPLATE.equals(parameterInfo.getStyle())) {
Object parameter = getRequest().getAttributes().get(
parameterInfo.getName());
result = new Series<Parameter>(Parameter.class);
result.add(parameterInfo.getName(),
Reference.decode((String) parameter));
result = new Series<Parameter>(Parameter.class);
result.add(parameterInfo.getName(), parameterInfo.getDefaultValue());
代码示例来源:origin: org.nuxeo/nuxeo-http-client
protected void setupAuth(Request request) {
if (authType == AUTH_TYPE_BASIC) {
ChallengeScheme scheme = ChallengeScheme.HTTP_BASIC;
ChallengeResponse authentication = new ChallengeResponse(scheme, userName, password);
request.setChallengeResponse(authentication);
} else if (authType == AUTH_TYPE_SECRET) {
Series<Parameter> additionnalHeaders = new Form();
Map<String, String> securityHeaders = PortalSSOAuthenticationProvider.getHeaders(secretToken, userName);
for (String hn : securityHeaders.keySet()) {
additionnalHeaders.add(hn, securityHeaders.get(hn));
}
request.getAttributes().put("org.restlet.http.headers", additionnalHeaders);
}
}
代码示例来源:origin: org.restlet.osgi/org.restlet.ext.oauth
/**
* Sets up a new authorization session.
*
* @param redirectUri
* The redirection URI.
*/
protected AuthSession setupAuthSession(RedirectionURI redirectUri) {
getLogger().fine("Base ref = " + getReference().getParentRef());
AuthSession session = AuthSession.newAuthSession();
session.setRedirectionURI(redirectUri);
CookieSetting cs = new CookieSetting(ClientCookieID, session.getId());
// TODO create a secure mode setting, update all cookies
// cs.setAccessRestricted(true);
// cs.setSecure(true);
getCookieSettings().add(cs);
getLogger().fine("Setting cookie in SetupSession - " + session.getId());
getContext().getAttributes().put(session.getId(), session);
return session;
}
内容来源于网络,如有侵权,请联系作者删除!