public final class ClientInfo
extends java.lang.Object
#Firefox for Windows Mozilla/{mozillaVersion} (Windows; U; {agentOs}; {osData}; rv:{releaseVersion}) Gecko/{geckoReleaseDate} {agentName}/{agentVersion}This template matches the "user-agent" string of the Firefox client for windows:
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20060918 Firefox/2.0At this time, six predefined variables are used:
Name | Description |
---|---|
agentName | Name of the user agent (i.e.: Firefox) |
agentVersion | Version of the user agent |
agentOs | Operating system of the user agent |
agentComment | Comment string, that is to say a sequence of characters enclosed "(", or ")" |
commentAttribute | A sequence of characters enclosed by ";", "(", or ")" |
facultativeData | A sequence of characters that can be empty |
Product
instance with the main
data (name, version, comment). This instance is accessible via the
getMainAgentProduct()
method. All other variables used in
the template aims at catching a sequence of characters and are accessible via
the getAgentAttributes()
method.Constructor and Description |
---|
ClientInfo()
Constructor.
|
ClientInfo(java.util.List<? extends Variant> variants)
Constructor from a list of variants.
|
ClientInfo(MediaType mediaType)
Constructor from a media type.
|
Modifier and Type | Method and Description |
---|---|
java.util.List<Preference<CharacterSet>> |
getAcceptedCharacterSets()
Returns the modifiable list of character set preferences.
|
java.util.List<Preference<Encoding>> |
getAcceptedEncodings()
Returns the modifiable list of encoding preferences.
|
java.util.List<Preference<Language>> |
getAcceptedLanguages()
Returns the modifiable list of language preferences.
|
java.util.List<Preference<MediaType>> |
getAcceptedMediaTypes()
Returns the modifiable list of media type preferences.
|
java.lang.String |
getAddress()
Returns the immediate client's IP address.
|
java.util.List<java.lang.String> |
getAddresses()
Deprecated.
Use the
getForwardedAddresses() method instead. |
java.lang.String |
getAgent()
Returns the agent name (ex: "Restlet-Framework/2.0").
|
java.util.Map<java.lang.String,java.lang.String> |
getAgentAttributes()
Returns a list of attributes taken from the name of the user agent.
|
java.lang.String |
getAgentName()
Returns the name of the user agent.
|
java.util.List<Product> |
getAgentProducts()
Returns the list of product tokens from the user agent name.
|
java.lang.String |
getAgentVersion()
Returns the version of the user agent.
|
java.util.List<Expectation> |
getExpectations()
Returns the client expectations.
|
java.util.List<java.lang.String> |
getForwardedAddresses()
Returns the list of forwarded IP addresses.
|
java.lang.String |
getFrom()
Returns the email address of the human user controlling the user agent.
|
Product |
getMainAgentProduct()
Returns a Product object based on the name of the user agent.
|
int |
getPort()
Returns the port number which sent the call.
|
CharacterSet |
getPreferredCharacterSet(java.util.List<CharacterSet> supported)
Returns the preferred character set among a list of supported ones, based
on the client preferences.
|
Encoding |
getPreferredEncoding(java.util.List<Encoding> supported)
Returns the preferred encoding among a list of supported ones, based on
the client preferences.
|
Language |
getPreferredLanguage(java.util.List<Language> supported)
Returns the preferred language among a list of supported ones, based on
the client preferences.
|
MediaType |
getPreferredMediaType(java.util.List<MediaType> supported)
Returns the preferred media type among a list of supported ones, based on
the client preferences.
|
Variant |
getPreferredVariant(java.util.List<? extends Variant> variants,
MetadataService metadataService)
Returns the best variant for a given resource according the the client
preferences: accepted languages, accepted character sets, accepted media
types and accepted encodings.
|
Variant |
getPreferredVariant(Resource resource,
MetadataService metadataService)
Deprecated.
|
java.util.List<java.security.Principal> |
getPrincipals()
Returns the additional client principals.
|
java.util.List<Role> |
getRoles()
Returns the authenticated user roles.
|
java.lang.String |
getUpstreamAddress()
Returns the IP address of the upstream client component.
|
User |
getUser()
Returns the authenticated user.
|
boolean |
isAuthenticated()
Indicates if the identifier or principal has been authenticated.
|
void |
setAcceptedCharacterSets(java.util.List<Preference<CharacterSet>> acceptedCharacterSets)
Sets the character set preferences.
|
void |
setAcceptedEncodings(java.util.List<Preference<Encoding>> acceptedEncodings)
Sets the encoding preferences.
|
void |
setAcceptedLanguages(java.util.List<Preference<Language>> acceptedLanguages)
Sets the language preferences.
|
void |
setAcceptedMediaTypes(java.util.List<Preference<MediaType>> acceptedMediaTypes)
Sets the media type preferences.
|
void |
setAddress(java.lang.String address)
Sets the client's IP address.
|
void |
setAddresses(java.util.List<java.lang.String> addresses)
Deprecated.
See the
setForwardedAddresses(List) method instead. |
void |
setAgent(java.lang.String agent)
Sets the agent name (ex: "Restlet-Framework/2.0").
|
void |
setAgentAttributes(java.util.Map<java.lang.String,java.lang.String> agentAttributes)
Sets a list of attributes taken from the name of the user agent.
|
void |
setAgentProducts(java.util.List<Product> agentProducts)
Sets the list of product tokens from the user agent name.
|
void |
setAuthenticated(boolean authenticated)
Indicates if the identifier or principal has been authenticated.
|
void |
setExpectations(java.util.List<Expectation> expectations)
Sets the client expectations.
|
void |
setForwardedAddresses(java.util.List<java.lang.String> forwardedAddresses)
Sets the list of forwarded IP addresses.
|
void |
setFrom(java.lang.String from)
Sets the email address of the human user controlling the user agent.
|
void |
setPort(int port)
Sets the port number which sent the call.
|
void |
setPrincipals(java.util.List<java.security.Principal> principals)
Sets the additional client principals.
|
void |
setRoles(java.util.List<Role> roles)
Sets the authenticated user roles.
|
void |
setUser(User user)
Sets the authenticated user.
|
public ClientInfo()
public ClientInfo(java.util.List<? extends Variant> variants)
variants
- The variants corresponding to the accepted media types.public ClientInfo(MediaType mediaType)
mediaType
- The preferred media type.public java.util.List<Preference<CharacterSet>> getAcceptedCharacterSets()
public java.util.List<Preference<Encoding>> getAcceptedEncodings()
public java.util.List<Preference<Language>> getAcceptedLanguages()
public java.util.List<Preference<MediaType>> getAcceptedMediaTypes()
public java.lang.String getAddress()
getUpstreamAddress()
,
getForwardedAddresses()
@Deprecated public java.util.List<java.lang.String> getAddresses()
getForwardedAddresses()
method instead.public java.lang.String getAgent()
public java.util.Map<java.lang.String,java.lang.String> getAgentAttributes()
getAgent()
public java.lang.String getAgentName()
getAgent()
public java.util.List<Product> getAgentProducts()
getAgent()
public java.lang.String getAgentVersion()
getAgent()
public java.util.List<Expectation> getExpectations()
public java.util.List<java.lang.String> getForwardedAddresses()
getUpstreamAddress()
,
Wikipedia
page for the "X-Forwarded-For" HTTP headerpublic java.lang.String getFrom()
public Product getMainAgentProduct()
public int getPort()
public CharacterSet getPreferredCharacterSet(java.util.List<CharacterSet> supported)
supported
- The supported character sets.public Encoding getPreferredEncoding(java.util.List<Encoding> supported)
supported
- The supported encodings.public Language getPreferredLanguage(java.util.List<Language> supported)
supported
- The supported languages.public MediaType getPreferredMediaType(java.util.List<MediaType> supported)
supported
- The supported media types.public Variant getPreferredVariant(java.util.List<? extends Variant> variants, MetadataService metadataService)
variants
- The list of variants to compare.metadataService
- The metadata service.@Deprecated public Variant getPreferredVariant(Resource resource, MetadataService metadataService)
getPreferredVariant(List, org.restlet.service.MetadataService)
instead.resource
- The resource for which the best representation needs to be
set.metadataService
- The metadata service.public java.util.List<java.security.Principal> getPrincipals()
getUser()
and getRoles()
methods already return user and role principals.public java.util.List<Role> getRoles()
public java.lang.String getUpstreamAddress()
getForwardedAddresses()
method returns a non
empty list, the IP address will be the first element. Otherwise, the
value of getAddress()
will be returned.getAddress()
,
getForwardedAddresses()
public User getUser()
public boolean isAuthenticated()
Guard
or manually.public void setAcceptedCharacterSets(java.util.List<Preference<CharacterSet>> acceptedCharacterSets)
acceptedCharacterSets
- The character set preferences.public void setAcceptedEncodings(java.util.List<Preference<Encoding>> acceptedEncodings)
acceptedEncodings
- The encoding preferences.public void setAcceptedLanguages(java.util.List<Preference<Language>> acceptedLanguages)
acceptedLanguages
- The language preferences.public void setAcceptedMediaTypes(java.util.List<Preference<MediaType>> acceptedMediaTypes)
acceptedMediaTypes
- The media type preferences.public void setAddress(java.lang.String address)
address
- The client's IP address.@Deprecated public void setAddresses(java.util.List<java.lang.String> addresses)
setForwardedAddresses(List)
method instead.addresses
- The list of client IP addresses.public void setAgent(java.lang.String agent)
agent
- The agent name.public void setAgentAttributes(java.util.Map<java.lang.String,java.lang.String> agentAttributes)
agentAttributes
- A list of attributes taken from the name of the user agent.public void setAgentProducts(java.util.List<Product> agentProducts)
agentProducts
- The list of product tokens from the user agent name.public void setAuthenticated(boolean authenticated)
Guard
or manually.authenticated
- True if the identifier or principal has been authenticated.public void setExpectations(java.util.List<Expectation> expectations)
expectations
- The client expectations.public void setForwardedAddresses(java.util.List<java.lang.String> forwardedAddresses)
forwardedAddresses
- The list of forwarded IP addresses.getForwardedAddresses()
public void setFrom(java.lang.String from)
from
- The email address of the human user controlling the user
agent.public void setPort(int port)
port
- The port number which sent the call.public void setPrincipals(java.util.List<java.security.Principal> principals)
principals
- The additional client principals.getPrincipals()
public void setRoles(java.util.List<Role> roles)
roles
- The authenticated user roles.public void setUser(User user)
user
- The authenticated user.Copyright © 2005-2012. All Rights Reserved.