public void setDefaultFailureUrl(String defaultFailureUrl) {
		Assert.isTrue(UrlUtils.isValidRedirectUrl(defaultFailureUrl),
				() -> "'" + defaultFailureUrl + "' is not a valid redirect URL");
		this.defaultFailureUrl = defaultFailureUrl;
	}

public
void
setDefaultFailureUrl
(
String
defaultFailureUrl
)
{
Assert
.
isTrue
(
UrlUtils
.
isValidRedirectUrl
(
defaultFailureUrl
)
,
(
)
->
"'"
+
defaultFailureUrl
+
"' is not a valid redirect URL"
)
;
this
.
defaultFailureUrl
=
defaultFailureUrl
;
}

The URL which will be used as the failure destination.

@param defaultFailureUrl the failure URL, for example "/loginFailed.jsp".

The URL which will be used as the failure destination .


public void setResolveHiddenInputs(
			Function<HttpServletRequest, Map<String, String>> resolveHiddenInputs) {
		Assert.notNull(resolveHiddenInputs, "resolveHiddenInputs cannot be null");
		this.resolveHiddenInputs = resolveHiddenInputs;
	}

public
void
setResolveHiddenInputs
(
Function
<
HttpServletRequest
,
Map
<
String
,
String
>
>
resolveHiddenInputs
)
{
Assert
.
notNull
(
resolveHiddenInputs
,
"resolveHiddenInputs cannot be null"
)
;
this
.
resolveHiddenInputs
=
resolveHiddenInputs
;
}

Sets a Function used to resolve a Map of the hidden inputs where the key is the
name of the input and the value is the value of the input. Typically this is used
to resolve the CSRF token.
@param resolveHiddenInputs the function to resolve the inputs

Sets a Function used to resolve a Map of the hidden inputs where the key is the name of the input and the value is the value of the input . Typically this is used to resolve the CSRF token .


private static String buildRequestUrl(String servletPath, String requestURI,
			String contextPath, String pathInfo, String queryString) {

		StringBuilder url = new StringBuilder();

		if (servletPath != null) {
			url.append(servletPath);
			if (pathInfo != null) {
				url.append(pathInfo);
			}
		}
		else {
			url.append(requestURI.substring(contextPath.length()));
		}

		if (queryString != null) {
			url.append("?").append(queryString);
		}

		return url.toString();
	}

private static String buildRequestUrl ( String servletPath , String requestURI , String contextPath , String pathInfo , String queryString ) { StringBuilder url = new StringBuilder ( ) ; if ( servletPath != null ) { url . append ( servletPath ) ; if ( pathInfo != null ) { url . append ( pathInfo ) ; } } else { url . append ( requestURI . substring ( contextPath . length ( ) ) ) ; } if ( queryString != null ) { url . append ( "?" ) . append ( queryString ) ; } return url . toString ( ) ; }

Obtains the web application-specific fragment of the URL.

Obtains the web application - specific fragment of the URL .


public static boolean isAbsoluteUrl(String url) {
		if (url == null) {
			return false;
		}
		final Pattern ABSOLUTE_URL = Pattern.compile("\\A[a-z0-9.+-]+://.*",
				Pattern.CASE_INSENSITIVE);

		return ABSOLUTE_URL.matcher(url).matches();
	}

public static boolean isAbsoluteUrl ( String url ) { if ( url == null ) { return false ; } final Pattern ABSOLUTE_URL = Pattern . compile ( "\\A[a-z0-9.+-]+://.*" , Pattern . CASE_INSENSITIVE ) ; return ABSOLUTE_URL . matcher ( url ) . matches ( ) ; }

Decides if a URL is absolute based on whether it contains a valid scheme name, as
defined in RFC 1738.

Decides if a URL is absolute based on whether it contains a valid scheme name as defined in RFC 1738 .


public List<OpenIDAttribute> createAttributeList(String identifier) {
		for (Map.Entry<Pattern, List<OpenIDAttribute>> entry : idToAttributes.entrySet()) {
			if (entry.getKey().matcher(identifier).matches()) {
				return entry.getValue();
			}
		}

		return Collections.emptyList();
	}

public List < OpenIDAttribute > createAttributeList ( String identifier ) { for ( Map . Entry < Pattern , List < OpenIDAttribute > > entry : idToAttributes . entrySet ( ) ) { if ( entry . getKey ( ) . matcher ( identifier ) . matches ( ) ) { return entry . getValue ( ) ; } } return Collections . emptyList ( ) ; }

Iterates through the patterns stored in the map and returns the list of attributes
defined for the first match. If no match is found, returns an empty list.

Iterates through the patterns stored in the map and returns the list of attributes defined for the first match . If no match is found returns an empty list .


Serializable identifierFrom(Serializable identifier, ResultSet resultSet) throws SQLException {
		if (isString(identifier) && hasValidClassIdType(resultSet)
			&& canConvertFromStringTo(classIdTypeFrom(resultSet))) {

			identifier = convertFromStringTo((String) identifier, classIdTypeFrom(resultSet));
		} else {
			// Assume it should be a Long type
			identifier = convertToLong(identifier);
		}

		return identifier;
	}

Serializable
identifierFrom
(
Serializable
identifier
,
ResultSet
resultSet
)
throws
SQLException
{
if
(
isString
(
identifier
)
&&
hasValidClassIdType
(
resultSet
)
&&
canConvertFromStringTo
(
classIdTypeFrom
(
resultSet
)
)
)
{
identifier
=
convertFromStringTo
(
(
String
)
identifier
,
classIdTypeFrom
(
resultSet
)
)
;
}
else
{
// Assume it should be a Long type
identifier
=
convertToLong
(
identifier
)
;
}
return
identifier
;
}

Converts the raw type from the database into the right Java type. For most applications the 'raw type' will be Long, for some applications
it could be String.
@param identifier The identifier from the database
@param resultSet  Result set of the query
@return The identifier in the appropriate target Java type. Typically Long or UUID.
@throws SQLException

Converts the raw type from the database into the right Java type . For most applications the raw type will be Long for some applications it could be String .


protected void createEntries(final MutableAcl acl) {
		if (acl.getEntries().isEmpty()) {
			return;
		}
		jdbcOperations.batchUpdate(insertEntry, new BatchPreparedStatementSetter() {
			public int getBatchSize() {
				return acl.getEntries().size();
			}

			public void setValues(PreparedStatement stmt, int i) throws SQLException {
				AccessControlEntry entry_ = acl.getEntries().get(i);
				Assert.isTrue(entry_ instanceof AccessControlEntryImpl,
						"Unknown ACE class");
				AccessControlEntryImpl entry = (AccessControlEntryImpl) entry_;

				stmt.setLong(1, ((Long) acl.getId()).longValue());
				stmt.setInt(2, i);
				stmt.setLong(3, createOrRetrieveSidPrimaryKey(entry.getSid(), true)
						.longValue());
				stmt.setInt(4, entry.getPermission().getMask());
				stmt.setBoolean(5, entry.isGranting());
				stmt.setBoolean(6, entry.isAuditSuccess());
				stmt.setBoolean(7, entry.isAuditFailure());
			}
		});
	}

protected
void
createEntries
(
final
MutableAcl
acl
)
{
if
(
acl
.
getEntries
(
)
.
isEmpty
(
)
)
{
return
;
}
jdbcOperations
.
batchUpdate
(
insertEntry
,
new
BatchPreparedStatementSetter
(
)
{
public
int
getBatchSize
(
)
{
return
acl
.
getEntries
(
)
.
size
(
)
;
}
public
void
setValues
(
PreparedStatement
stmt
,
int
i
)
throws
SQLException
{
AccessControlEntry
entry_
=
acl
.
getEntries
(
)
.
get
(
i
)
;
Assert
.
isTrue
(
entry_
instanceof
AccessControlEntryImpl
,
"Unknown ACE class"
)
;
AccessControlEntryImpl
entry
=
(
AccessControlEntryImpl
)
entry_
;
stmt
.
setLong
(
1
,
(
(
Long
)
acl
.
getId
(
)
)
.
longValue
(
)
)
;
stmt
.
setInt
(
2
,
i
)
;
stmt
.
setLong
(
3
,
createOrRetrieveSidPrimaryKey
(
entry
.
getSid
(
)
,
true
)
.
longValue
(
)
)
;
stmt
.
setInt
(
4
,
entry
.
getPermission
(
)
.
getMask
(
)
)
;
stmt
.
setBoolean
(
5
,
entry
.
isGranting
(
)
)
;
stmt
.
setBoolean
(
6
,
entry
.
isAuditSuccess
(
)
)
;
stmt
.
setBoolean
(
7
,
entry
.
isAuditFailure
(
)
)
;
}
}
)
;
}

Creates a new row in acl_entry for every ACE defined in the passed MutableAcl
object.

@param acl containing the ACEs to insert

Creates a new row in acl_entry for every ACE defined in the passed MutableAcl object .


protected void createObjectIdentity(ObjectIdentity object, Sid owner) {
		Long sidId = createOrRetrieveSidPrimaryKey(owner, true);
		Long classId = createOrRetrieveClassPrimaryKey(object.getType(), true, object.getIdentifier().getClass());
		jdbcOperations.update(insertObjectIdentity, classId, object.getIdentifier().toString(), sidId,
				Boolean.TRUE);
	}

protected void createObjectIdentity ( ObjectIdentity object , Sid owner ) { Long sidId = createOrRetrieveSidPrimaryKey ( owner , true ) ; Long classId = createOrRetrieveClassPrimaryKey ( object . getType ( ) , true , object . getIdentifier ( ) . getClass ( ) ) ; jdbcOperations . update ( insertObjectIdentity , classId , object . getIdentifier ( ) . toString ( ) , sidId , Boolean . TRUE ) ; }

Creates an entry in the acl_object_identity table for the passed ObjectIdentity.
The Sid is also necessary, as acl_object_identity has defined the sid column as
non-null.

@param object to represent an acl_object_identity for
@param owner for the SID column (will be created if there is no acl_sid entry for
this particular Sid already)

Creates an entry in the acl_object_identity table for the passed ObjectIdentity . The Sid is also necessary as acl_object_identity has defined the sid column as non - null .


protected void updateObjectIdentity(MutableAcl acl) {
		Long parentId = null;

		if (acl.getParentAcl() != null) {
			Assert.isInstanceOf(ObjectIdentityImpl.class, acl.getParentAcl()
					.getObjectIdentity(),
					"Implementation only supports ObjectIdentityImpl");

			ObjectIdentityImpl oii = (ObjectIdentityImpl) acl.getParentAcl()
					.getObjectIdentity();
			parentId = retrieveObjectIdentityPrimaryKey(oii);
		}

		Assert.notNull(acl.getOwner(), "Owner is required in this implementation");

		Long ownerSid = createOrRetrieveSidPrimaryKey(acl.getOwner(), true);
		int count = jdbcOperations.update(updateObjectIdentity, parentId, ownerSid,
				Boolean.valueOf(acl.isEntriesInheriting()), acl.getId());

		if (count != 1) {
			throw new NotFoundException("Unable to locate ACL to update");
		}
	}

Updates an existing acl_object_identity row, with new information presented in the
passed MutableAcl object. Also will create an acl_sid entry if needed for the Sid
that owns the MutableAcl.

@param acl to modify (a row must already exist in acl_object_identity)

@throws NotFoundException if the ACL could not be found to update.

Updates an existing acl_object_identity row with new information presented in the passed MutableAcl object . Also will create an acl_sid entry if needed for the Sid that owns the MutableAcl .


public void saveRequest(HttpServletRequest request, HttpServletResponse response) {
		if (requestMatcher.matches(request)) {
			DefaultSavedRequest savedRequest = new DefaultSavedRequest(request,
					portResolver);

			if (createSessionAllowed || request.getSession(false) != null) {
				// Store the HTTP request itself. Used by
				// AbstractAuthenticationProcessingFilter
				// for redirection after successful authentication (SEC-29)
				request.getSession().setAttribute(this.sessionAttrName, savedRequest);
				logger.debug("DefaultSavedRequest added to Session: " + savedRequest);
			}
		}
		else {
			logger.debug("Request not saved as configured RequestMatcher did not match");
		}
	}

Stores the current request, provided the configuration properties allow it.

Stores the current request provided the configuration properties allow it .


public static ServerWebExchangeMatcher pathMatchers(HttpMethod method, String... patterns) {
		List<ServerWebExchangeMatcher> matchers = new ArrayList<>(patterns.length);
		for (String pattern : patterns) {
			matchers.add(new PathPatternParserServerWebExchangeMatcher(pattern, method));
		}
		return new OrServerWebExchangeMatcher(matchers);
	}

Creates a matcher that matches on the specific method and any of the provided patterns.
@param method the method to match on. If null, any method will be matched
@param patterns the patterns to match on
@return the matcher to use

Creates a matcher that matches on the specific method and any of the provided patterns .


public static ServerWebExchangeMatcher anyExchange() {
		// we don't use a lambda to ensure a unique equals and hashcode
		// which otherwise can cause problems with adding multiple entries to an ordered LinkedHashMap
		return new ServerWebExchangeMatcher() {
			@Override
			public Mono<MatchResult> matches(ServerWebExchange exchange) {
				return ServerWebExchangeMatcher.MatchResult.match();
			}
		};
	}

Matches any exchange
@return the matcher to use


public static TextEncryptor delux(CharSequence password, CharSequence salt) {
		return new HexEncodingTextEncryptor(stronger(password, salt));
	}

public static TextEncryptor delux ( CharSequence password , CharSequence salt ) { return new HexEncodingTextEncryptor ( stronger ( password , salt ) ) ; }

Creates a text encryptor that uses "stronger" password-based encryption. Encrypted
text is hex-encoded.

@param password the password used to generate the encryptor's secret key; should
not be shared
@see Encryptors#stronger(CharSequence, CharSequence)

Creates a text encryptor that uses stronger password - based encryption . Encrypted text is hex - encoded .


public static TextEncryptor text(CharSequence password, CharSequence salt) {
		return new HexEncodingTextEncryptor(standard(password, salt));
	}

public static TextEncryptor text ( CharSequence password , CharSequence salt ) { return new HexEncodingTextEncryptor ( standard ( password , salt ) ) ; }

Creates a text encryptor that uses "standard" password-based encryption. Encrypted
text is hex-encoded.

@param password the password used to generate the encryptor's secret key; should
not be shared
@see Encryptors#standard(CharSequence, CharSequence)

Creates a text encryptor that uses standard password - based encryption . Encrypted text is hex - encoded .


public static TextEncryptor queryableText(CharSequence password, CharSequence salt) {
		return new HexEncodingTextEncryptor(new AesBytesEncryptor(password.toString(),
				salt));
	}

public static TextEncryptor queryableText ( CharSequence password , CharSequence salt ) { return new HexEncodingTextEncryptor ( new AesBytesEncryptor ( password . toString ( ) , salt ) ) ; }

Creates an encryptor for queryable text strings that uses standard password-based
encryption. Uses a 16-byte all-zero initialization vector so encrypting the same
data results in the same encryption result. This is done to allow encrypted data to
be queried against. Encrypted text is hex-encoded.

@param password the password used to generate the encryptor's secret key; should
not be shared
@param salt a hex-encoded, random, site-global salt value to use to generate the
secret key

Creates an encryptor for queryable text strings that uses standard password - based encryption . Uses a 16 - byte all - zero initialization vector so encrypting the same data results in the same encryption result . This is done to allow encrypted data to be queried against . Encrypted text is hex - encoded .


public void writeHeaders(HttpServletRequest request, HttpServletResponse response) {
		if (XFrameOptionsMode.ALLOW_FROM.equals(frameOptionsMode)) {
			String allowFromValue = this.allowFromStrategy.getAllowFromValue(request);
			if (XFrameOptionsMode.DENY.getMode().equals(allowFromValue)) {
				if (!response.containsHeader(XFRAME_OPTIONS_HEADER)) {
					response.setHeader(XFRAME_OPTIONS_HEADER, XFrameOptionsMode.DENY.getMode());
				}
			} else if (allowFromValue != null) {
				if (!response.containsHeader(XFRAME_OPTIONS_HEADER)) {
					response.setHeader(XFRAME_OPTIONS_HEADER,
							XFrameOptionsMode.ALLOW_FROM.getMode() + " " + allowFromValue);
				}
			}
		}
		else {
			response.setHeader(XFRAME_OPTIONS_HEADER, frameOptionsMode.getMode());
		}
	}

public
void
writeHeaders
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
if
(
XFrameOptionsMode
.
ALLOW_FROM
.
equals
(
frameOptionsMode
)
)
{
String
allowFromValue
=
this
.
allowFromStrategy
.
getAllowFromValue
(
request
)
;
if
(
XFrameOptionsMode
.
DENY
.
getMode
(
)
.
equals
(
allowFromValue
)
)
{
if
(
!
response
.
containsHeader
(
XFRAME_OPTIONS_HEADER
)
)
{
response
.
setHeader
(
XFRAME_OPTIONS_HEADER
,
XFrameOptionsMode
.
DENY
.
getMode
(
)
)
;
}
}
else
if
(
allowFromValue
!=
)
{
if
(
!
response
.
containsHeader
(
XFRAME_OPTIONS_HEADER
)
)
{
response
.
setHeader
(
XFRAME_OPTIONS_HEADER
,
XFrameOptionsMode
.
ALLOW_FROM
.
getMode
(
)
+
" "
+
allowFromValue
)
;
}
}
}
else
{
response
.
setHeader
(
XFRAME_OPTIONS_HEADER
,
frameOptionsMode
.
getMode
(
)
)
;
}
}

Writes the X-Frame-Options header value, overwritting any previous value.

@param request the servlet request
@param response the servlet response

Writes the X - Frame - Options header value overwritting any previous value .


protected String determineTargetUrl(HttpServletRequest request,
			HttpServletResponse response, Authentication authentication) {
		return determineTargetUrl(request, response);
	}

protected String determineTargetUrl ( HttpServletRequest request , HttpServletResponse response , Authentication authentication ) { return determineTargetUrl ( request , response ) ; }

Builds the target URL according to the logic defined in the main class Javadoc

@since 5.2


protected String determineTargetUrl(HttpServletRequest request,
			HttpServletResponse response) {
		if (isAlwaysUseDefaultTargetUrl()) {
			return defaultTargetUrl;
		}

		// Check for the parameter and use that if available
		String targetUrl = null;

		if (targetUrlParameter != null) {
			targetUrl = request.getParameter(targetUrlParameter);

			if (StringUtils.hasText(targetUrl)) {
				logger.debug("Found targetUrlParameter in request: " + targetUrl);

				return targetUrl;
			}
		}

		if (useReferer && !StringUtils.hasLength(targetUrl)) {
			targetUrl = request.getHeader("Referer");
			logger.debug("Using Referer header: " + targetUrl);
		}

		if (!StringUtils.hasText(targetUrl)) {
			targetUrl = defaultTargetUrl;
			logger.debug("Using default Url: " + targetUrl);
		}

		return targetUrl;
	}

Builds the target URL according to the logic defined in the main class Javadoc.

Builds the target URL according to the logic defined in the main class Javadoc .


public void setTargetUrlParameter(String targetUrlParameter) {
		if (targetUrlParameter != null) {
			Assert.hasText(targetUrlParameter, "targetUrlParameter cannot be empty");
		}
		this.targetUrlParameter = targetUrlParameter;
	}

public
void
setTargetUrlParameter
(
String
targetUrlParameter
)
{
if
(
targetUrlParameter
!=
)
{
Assert
.
hasText
(
targetUrlParameter
,
"targetUrlParameter cannot be empty"
)
;
}
this
.
targetUrlParameter
=
targetUrlParameter
;
}

If this property is set, the current request will be checked for this a parameter
with this name and the value used as the target URL if present.

@param targetUrlParameter the name of the parameter containing the encoded target
URL. Defaults to null.

If this property is set the current request will be checked for this a parameter with this name and the value used as the target URL if present .


private Directory getDirectoryWithImmediateParentPopulated(final Long id) {
		return getJdbcTemplate().queryForObject(SELECT_FROM_DIRECTORY_SINGLE,
				new Object[] { id }, new RowMapper<Directory>() {
					public Directory mapRow(ResultSet rs, int rowNumber)
							throws SQLException {
						Long parentDirectoryId = new Long(rs
								.getLong("parent_directory_id"));
						Directory parentDirectory = Directory.ROOT_DIRECTORY;
						if (parentDirectoryId != null
								&& !parentDirectoryId.equals(new Long(-1))) {
							// Need to go and lookup the parent, so do that first
							parentDirectory = getDirectoryWithImmediateParentPopulated(parentDirectoryId);
						}
						Directory directory = new Directory(rs
								.getString("directory_name"), parentDirectory);
						FieldUtils.setProtectedFieldValue("id", directory,
								new Long(rs.getLong("id")));
						return directory;
					}
				});
	}

Executes recursive SQL as needed to build a full Directory hierarchy of objects


public DistinguishedName buildDn(String username) {
		DistinguishedName dn = new DistinguishedName(userDnBase);

		dn.add(usernameAttribute, username);

		return dn;
	}

public DistinguishedName buildDn ( String username ) { DistinguishedName dn = new DistinguishedName ( userDnBase ) ; dn . add ( usernameAttribute , username ) ; return dn ; }

Assembles the Distinguished Name that should be used the given username.

Assembles the Distinguished Name that should be used the given username .


private Map<Class<? extends Object>, Object> createSharedObjects() {
		Map<Class<? extends Object>, Object> sharedObjects = new HashMap<Class<? extends Object>, Object>();
		sharedObjects.putAll(localConfigureAuthenticationBldr.getSharedObjects());
		sharedObjects.put(UserDetailsService.class, userDetailsService());
		sharedObjects.put(ApplicationContext.class, context);
		sharedObjects.put(ContentNegotiationStrategy.class, contentNegotiationStrategy);
		sharedObjects.put(AuthenticationTrustResolver.class, trustResolver);
		return sharedObjects;
	}

private Map < Class < ? extends Object > , Object > createSharedObjects ( ) { Map < Class < ? extends Object > , Object > sharedObjects = new HashMap < Class < ? extends Object > , Object > ( ) ; sharedObjects . putAll ( localConfigureAuthenticationBldr . getSharedObjects ( ) ) ; sharedObjects . put ( UserDetailsService . class , userDetailsService ( ) ) ; sharedObjects . put ( ApplicationContext . class , context ) ; sharedObjects . put ( ContentNegotiationStrategy . class , contentNegotiationStrategy ) ; sharedObjects . put ( AuthenticationTrustResolver . class , trustResolver ) ; return sharedObjects ; }

Creates the shared objects

@return the shared Objects


private void configureJaasUsingLoop() throws IOException {
		String loginConfigUrl = convertLoginConfigToUrl();
		boolean alreadySet = false;

		int n = 1;
		final String prefix = "login.config.url.";
		String existing;

		while ((existing = Security.getProperty(prefix + n)) != null) {
			alreadySet = existing.equals(loginConfigUrl);

			if (alreadySet) {
				break;
			}

			n++;
		}

		if (!alreadySet) {
			String key = prefix + n;
			log.debug("Setting security property [" + key + "] to: " + loginConfigUrl);
			Security.setProperty(key, loginConfigUrl);
		}
	}

private
void
configureJaasUsingLoop
(
)
throws
IOException
{
String
loginConfigUrl
=
convertLoginConfigToUrl
(
)
;
boolean
alreadySet
=
false
;
int
n
=
1
;
final
String
prefix
=
"login.config.url."
;
String
existing
;
while
(
(
existing
=
Security
.
getProperty
(
prefix
+
n
)
)
!=
)
{
alreadySet
=
existing
.
equals
(
loginConfigUrl
)
;
if
(
alreadySet
)
{
break
;
}
n
++
;
}
if
(
!
alreadySet
)
{
String
key
=
prefix
+
n
;
log
.
debug
(
"Setting security property ["
+
key
+
"] to: "
+
loginConfigUrl
)
;
Security
.
setProperty
(
key
,
loginConfigUrl
)
;
}
}

Loops through the login.config.url.1,login.config.url.2 properties looking for the
login configuration. If it is not set, it will be set to the last available
login.config.url.X property.

Loops through the login . config . url . 1 login . config . url . 2 properties looking for the login configuration . If it is not set it will be set to the last available login . config . url . X property .


public static String getCurrentDate() {
		long now = System.currentTimeMillis();

		if ((now - currentDateGenerated) > 1000) {
			synchronized (format) {
				if ((now - currentDateGenerated) > 1000) {
					currentDateGenerated = now;
					currentDate = format.format(new Date(now));
				}
			}
		}

		return currentDate;
	}

public static String getCurrentDate ( ) { long now = System . currentTimeMillis ( ) ; if ( ( now - currentDateGenerated ) > 1000 ) { synchronized ( format ) { if ( ( now - currentDateGenerated ) > 1000 ) { currentDateGenerated = now ; currentDate = format . format ( new Date ( now ) ) ; } } } return currentDate ; }

Gets the current date in HTTP format.

@return Current date in HTTP format


private static Long internalParseDate(String value, DateFormat[] formats) {
		Date date = null;

		for (int i = 0; (date == null) && (i < formats.length); i++) {
			try {
				date = formats[i].parse(value);
			}
			catch (ParseException ignored) {
			}
		}

		if (date == null) {
			return null;
		}

		return new Long(date.getTime());
	}

private static Long internalParseDate ( String value , DateFormat [ ] formats ) { Date date = null ; for ( int i = 0 ; ( date == null ) && ( i < formats . length ) ; i ++ ) { try { date = formats [ i ] . parse ( value ) ; } catch ( ParseException ignored ) { } } if ( date == null ) { return null ; } return new Long ( date . getTime ( ) ) ; }

Parses date with given formatters.

@param value The string to parse
@param formats Array of formats to use

@return Parsed date (or null if no formatter mached)


@SuppressWarnings("unchecked")
	private static void updateCache(HashMap cache, Object key, Object value) {
		if (value == null) {
			return;
		}

		if (cache.size() > 1000) {
			cache.clear();
		}

		cache.put(key, value);
	}

@ SuppressWarnings ( "unchecked" ) private static void updateCache ( HashMap cache , Object key , Object value ) { if ( value == null ) { return ; } if ( cache . size ( ) > 1000 ) { cache . clear ( ) ; } cache . put ( key , value ) ; }

Updates cache.

@param cache Cache to be updated
@param key Key to be updated
@param value New value


protected void setDetails(HttpServletRequest request,
			UsernamePasswordAuthenticationToken authRequest) {
		authRequest.setDetails(authenticationDetailsSource.buildDetails(request));
	}

protected void setDetails ( HttpServletRequest request , UsernamePasswordAuthenticationToken authRequest ) { authRequest . setDetails ( authenticationDetailsSource . buildDetails ( request ) ) ; }

Provided so that subclasses may configure what is put into the authentication
request's details property.

@param request that an authentication request is being created for
@param authRequest the authentication request object that should have its details
set

Provided so that subclasses may configure what is put into the authentication request s details property .


private static String getSecurityName(final Subject subject) {
		if (logger.isDebugEnabled()) {
			logger.debug("Determining Websphere security name for subject " + subject);
		}
		String userSecurityName = null;
		if (subject != null) {
			// SEC-803
			Object credential = subject.getPublicCredentials(getWSCredentialClass())
					.iterator().next();
			if (credential != null) {
				userSecurityName = (String) invokeMethod(getSecurityNameMethod(),
						credential);
			}
		}
		if (logger.isDebugEnabled()) {
			logger.debug("Websphere security name is " + userSecurityName
					+ " for subject " + subject);
		}
		return userSecurityName;
	}

Get the security name for the given subject.

@param subject The subject for which to retrieve the security name
@return String the security name for the given subject

Get the security name for the given subject .


@SuppressWarnings("unchecked")
	private static List<String> getWebSphereGroups(final String securityName) {
		Context ic = null;
		try {
			// TODO: Cache UserRegistry object
			ic = new InitialContext();
			Object objRef = ic.lookup(USER_REGISTRY);
			Object userReg = invokeMethod(getNarrowMethod(), null , objRef, Class.forName("com.ibm.websphere.security.UserRegistry"));
			if (logger.isDebugEnabled()) {
				logger.debug("Determining WebSphere groups for user " + securityName
						+ " using WebSphere UserRegistry " + userReg);
			}
			final Collection groups = (Collection) invokeMethod(getGroupsForUserMethod(),
					userReg, new Object[] { securityName });
			if (logger.isDebugEnabled()) {
				logger.debug("Groups for user " + securityName + ": " + groups.toString());
			}

			return new ArrayList(groups);
		}
		catch (Exception e) {
			logger.error("Exception occured while looking up groups for user", e);
			throw new RuntimeException(
					"Exception occured while looking up groups for user", e);
		}
		finally {
			try {
				if (ic != null) {
					ic.close();
				}
			}
			catch (NamingException e) {
				logger.debug("Exception occured while closing context", e);
			}
		}
	}

Get the WebSphere group names for the given security name.

@param securityName The security name for which to retrieve the WebSphere group
names
@return the WebSphere group names for the given security name

Get the WebSphere group names for the given security name .


public void changePassword(final String oldPassword, final String newPassword) {
		Authentication authentication = SecurityContextHolder.getContext()
				.getAuthentication();
		Assert.notNull(
				authentication,
				"No authentication object found in security context. Can't change current user's password!");

		String username = authentication.getName();

		logger.debug("Changing password for user '" + username);

		DistinguishedName userDn = usernameMapper.buildDn(username);

		if (usePasswordModifyExtensionOperation) {
			changePasswordUsingExtensionOperation(userDn, oldPassword, newPassword);
		} else {
			changePasswordUsingAttributeModification(userDn, oldPassword, newPassword);
		}
	}

Changes the password for the current user. The username is obtained from the
security context.

There are two supported strategies for modifying the user's password depending on
the capabilities of the corresponding LDAP server.

Configured one way, this method will modify the user's password via the

LDAP Password Modify Extended Operation
.

See {@link LdapUserDetailsManager#setUsePasswordModifyExtensionOperation(boolean)} for details.

By default, though, if the old password is supplied, the update will be made by rebinding as the user,
thus modifying the password using the user's permissions. If
oldPassword is null, the update will be attempted using a standard
read/write context supplied by the context source.

@param oldPassword the old password
@param newPassword the new value of the password.

Changes the password for the current user . The username is obtained from the security context .


protected DistinguishedName buildGroupDn(String group) {
		DistinguishedName dn = new DistinguishedName(groupSearchBase);
		dn.add(groupRoleAttributeName, group.toLowerCase());

		return dn;
	}

protected DistinguishedName buildGroupDn ( String group ) { DistinguishedName dn = new DistinguishedName ( groupSearchBase ) ; dn . add ( groupRoleAttributeName , group . toLowerCase ( ) ) ; return dn ; }

Creates a DN from a group name.

@param group the name of the group
@return the DN of the corresponding group, including the groupSearchBase


protected void allowableSessionsExceeded(List<SessionInformation> sessions,
			int allowableSessions, SessionRegistry registry)
			throws SessionAuthenticationException {
		if (exceptionIfMaximumExceeded || (sessions == null)) {
			throw new SessionAuthenticationException(messages.getMessage(
					"ConcurrentSessionControlAuthenticationStrategy.exceededAllowed",
					new Object[] { Integer.valueOf(allowableSessions) },
					"Maximum sessions of {0} for this principal exceeded"));
		}

		// Determine least recently used session, and mark it for invalidation
		SessionInformation leastRecentlyUsed = null;

		for (SessionInformation session : sessions) {
			if ((leastRecentlyUsed == null)
					|| session.getLastRequest()
							.before(leastRecentlyUsed.getLastRequest())) {
				leastRecentlyUsed = session;
			}
		}

		leastRecentlyUsed.expireNow();
	}

Allows subclasses to customise behaviour when too many sessions are detected.

@param sessions either null or all unexpired sessions associated with
the principal
@param allowableSessions the number of concurrent sessions the user is allowed to
have
@param registry an instance of the SessionRegistry for subclass use

Allows subclasses to customise behaviour when too many sessions are detected .


private void copyDetails(Authentication source, Authentication dest) {
		if ((dest instanceof AbstractAuthenticationToken) && (dest.getDetails() == null)) {
			AbstractAuthenticationToken token = (AbstractAuthenticationToken) dest;

			token.setDetails(source.getDetails());
		}
	}

private void copyDetails ( Authentication source , Authentication dest ) { if ( ( dest instanceof AbstractAuthenticationToken ) && ( dest . getDetails ( ) == null ) ) { AbstractAuthenticationToken token = ( AbstractAuthenticationToken ) dest ; token . setDetails ( source . getDetails ( ) ) ; } }

Copies the authentication details from a source Authentication object to a
destination one, provided the latter does not already have one set.

@param source source authentication
@param dest the destination authentication object

Copies the authentication details from a source Authentication object to a destination one provided the latter does not already have one set .


private List<Filter> getFilters(HttpServletRequest request) {
		for (SecurityFilterChain chain : filterChains) {
			if (chain.matches(request)) {
				return chain.getFilters();
			}
		}

		return null;
	}

private List < Filter > getFilters ( HttpServletRequest request ) { for ( SecurityFilterChain chain : filterChains ) { if ( chain . matches ( request ) ) { return chain . getFilters ( ) ; } } return null ; }

Returns the first filter chain matching the supplied URL.

@param request the request to match
@return an ordered array of Filters defining the filter chain

Returns the first filter chain matching the supplied URL .


public List<Filter> getFilters(String url) {
		return getFilters(firewall.getFirewalledRequest((new FilterInvocation(url, "GET")
				.getRequest())));
	}

public List < Filter > getFilters ( String url ) { return getFilters ( firewall . getFirewalledRequest ( ( new FilterInvocation ( url , "GET" ) . getRequest ( ) ) ) ) ; }

Convenience method, mainly for testing.

@param url the URL
@return matching filter list


protected ApplicationContext getContext(PageContext pageContext) {
		ServletContext servletContext = pageContext.getServletContext();

		return SecurityWebApplicationContextUtils.findRequiredWebApplicationContext(servletContext);
	}

protected ApplicationContext getContext ( PageContext pageContext ) { ServletContext servletContext = pageContext . getServletContext ( ) ; return SecurityWebApplicationContextUtils . findRequiredWebApplicationContext ( servletContext ) ; }

Allows test cases to override where application context obtained from.

@param pageContext so the ServletContext can be accessed as required
by Spring's WebApplicationContextUtils

@return the Spring application context (never null)

Allows test cases to override where application context obtained from .


public static DistinguishedName getFullDn(DistinguishedName dn, Context baseCtx)
			throws NamingException {
		DistinguishedName baseDn = new DistinguishedName(baseCtx.getNameInNamespace());

		if (dn.contains(baseDn)) {
			return dn;
		}

		baseDn.append(dn);

		return baseDn;
	}

public static DistinguishedName getFullDn ( DistinguishedName dn , Context baseCtx ) throws NamingException { DistinguishedName baseDn = new DistinguishedName ( baseCtx . getNameInNamespace ( ) ) ; if ( dn . contains ( baseDn ) ) { return dn ; } baseDn . append ( dn ) ; return baseDn ; }

Gets the full dn of a name by prepending the name of the context it is relative to.
If the name already contains the base name, it is returned unaltered.

Gets the full dn of a name by prepending the name of the context it is relative to . If the name already contains the base name it is returned unaltered .


public MockMvcRequestSpecification sessionAttrs(Map<String, Object> sessionAttributes) {
        notNull(sessionAttributes, "sessionAttributes");
        parameterUpdater.updateParameters(convert(cfg.getMockMvcParamConfig().sessionAttributesUpdateStrategy()), sessionAttributes, this.sessionAttributes);
        return this;
    }

public MockMvcRequestSpecification sessionAttrs ( Map < String , Object > sessionAttributes ) { notNull ( sessionAttributes , "sessionAttributes" ) ; parameterUpdater . updateParameters ( convert ( cfg . getMockMvcParamConfig ( ) . sessionAttributesUpdateStrategy ( ) ) , sessionAttributes , this . sessionAttributes ) ; return this ; }

Set session attributes.

@param sessionAttributes the session attributes


public AuthenticationScheme basic(String userName, String password) {
        final PreemptiveBasicAuthScheme preemptiveBasicAuthScheme = new PreemptiveBasicAuthScheme();
        preemptiveBasicAuthScheme.setUserName(userName);
        preemptiveBasicAuthScheme.setPassword(password);
        return preemptiveBasicAuthScheme;
    }

public AuthenticationScheme basic ( String userName , String password ) { final PreemptiveBasicAuthScheme preemptiveBasicAuthScheme = new PreemptiveBasicAuthScheme ( ) ; preemptiveBasicAuthScheme . setUserName ( userName ) ; preemptiveBasicAuthScheme . setPassword ( password ) ; return preemptiveBasicAuthScheme ; }

Use preemptive http basic authentication. This means that the authentication details are sent in the request
header regardless if the server has challenged for authentication or not.

@param userName The user name.
@param password The password.

@return The Request specification

Use preemptive http basic authentication . This means that the authentication details are sent in the request header regardless if the server has challenged for authentication or not .


public static void filters(List<Filter> filters) {
        Validate.notNull(filters, "Filter list cannot be null");
        RestAssured.filters.addAll(filters);
    }

public
static
void
filters
(
List
<
Filter
>
filters
)
{
Validate
.
notNull
(
filters
,
"Filter list cannot be null"
)
;
RestAssured
.
filters
.
addAll
(
filters
)
;
}

Add default filters that will be applied to each request.

@param filters The filter list

Add default filters that will be applied to each request .


public static void filters(Filter filter, Filter... additionalFilters) {
        Validate.notNull(filter, "Filter cannot be null");
        RestAssured.filters.add(filter);
        if (additionalFilters != null) {
            Collections.addAll(RestAssured.filters, additionalFilters);
        }
    }

public
static
void
filters
(
Filter
filter
,
Filter
...
additionalFilters
)
{
Validate
.
notNull
(
filter
,
"Filter cannot be null"
)
;
RestAssured
.
filters
.
add
(
filter
)
;
if
(
additionalFilters
!=
)
{
Collections
.
addAll
(
RestAssured
.
filters
,
additionalFilters
)
;
}
}

Add default filters to apply to each request.

@param filter            The filter to add
@param additionalFilters An optional array of additional filters to add

Add default filters to apply to each request .


public static AuthenticationScheme basic(String userName, String password) {
        final BasicAuthScheme scheme = new BasicAuthScheme();
        scheme.setUserName(userName);
        scheme.setPassword(password);
        return scheme;
    }

public static AuthenticationScheme basic ( String userName , String password ) { final BasicAuthScheme scheme = new BasicAuthScheme ( ) ; scheme . setUserName ( userName ) ; scheme . setPassword ( password ) ; return scheme ; }

Create a http basic authentication scheme.

@param userName The user name.
@param password The password.
@return The authentication scheme

Create a http basic authentication scheme .


public static AuthenticationScheme ntlm(String userName, String password, String workstation, String domain) {
        final NTLMAuthScheme scheme = new NTLMAuthScheme();
        scheme.setUserName(userName);
        scheme.setPassword(password);
        scheme.setWorkstation(workstation);
        scheme.setDomain(domain);
        return scheme;
    }

public static AuthenticationScheme ntlm ( String userName , String password , String workstation , String domain ) { final NTLMAuthScheme scheme = new NTLMAuthScheme ( ) ; scheme . setUserName ( userName ) ; scheme . setPassword ( password ) ; scheme . setWorkstation ( workstation ) ; scheme . setDomain ( domain ) ; return scheme ; }

Create a NTLM authentication scheme.

@param userName The user name.
@param password The password.
@param workstation The NTLM workstation.
@param domain The NTLM workstation.
@return The authentication scheme


public static AuthenticationScheme form(String userName, String password, FormAuthConfig config) {
        if (userName == null) {
            throw new IllegalArgumentException("Username cannot be null");
        }
        if (password == null) {
            throw new IllegalArgumentException("Password cannot be null");
        }
        final FormAuthScheme scheme = new FormAuthScheme();
        scheme.setUserName(userName);
        scheme.setPassword(password);
        scheme.setConfig(config);
        return scheme;
    }

public
static
AuthenticationScheme
form
(
String
userName
,
String
password
,
FormAuthConfig
config
)
{
if
(
userName
==
)
{
throw
new
IllegalArgumentException
(
"Username cannot be null"
)
;
}
if
(
password
==
)
{
throw
new
IllegalArgumentException
(
"Password cannot be null"
)
;
}
final
FormAuthScheme
scheme
=
new
FormAuthScheme
(
)
;
scheme
.
setUserName
(
userName
)
;
scheme
.
setPassword
(
password
)
;
scheme
.
setConfig
(
config
)
;
return
scheme
;
}

Use form authentication with the supplied configuration.

@param userName The user name.
@param password The password.
@param config   The form authentication config
@return The authentication scheme

Use form authentication with the supplied configuration .


public static void proxy(URI uri) {
        if (uri == null) {
            throw new IllegalArgumentException("Proxy URI cannot be null");
        }
        proxy(new ProxySpecification(uri.getHost(), uri.getPort(), uri.getScheme()));
    }

public
static
void
proxy
(
URI
uri
)
{
if
(
uri
==
)
{
throw
new
IllegalArgumentException
(
"Proxy URI cannot be null"
)
;
}
proxy
(
new
ProxySpecification
(
uri
.
getHost
(
)
,
uri
.
getPort
(
)
,
uri
.
getScheme
(
)
)
)
;
}

Instruct REST Assured to connect to a proxy using a URI.

@param uri The URI of the proxy

Instruct REST Assured to connect to a proxy using a URI .


public static String print(ResponseOptions responseOptions, ResponseBody responseBody, PrintStream stream, LogDetail logDetail, boolean shouldPrettyPrint) {
        final StringBuilder builder = new StringBuilder();
        if (logDetail == ALL || logDetail == STATUS) {
            builder.append(responseOptions.statusLine());
        }
        if (logDetail == ALL || logDetail == HEADERS) {
            final Headers headers = responseOptions.headers();
            if (headers.exist()) {
                appendNewLineIfAll(logDetail, builder).append(toString(headers));
            }
        } else if (logDetail == COOKIES) {
            final Cookies cookies = responseOptions.detailedCookies();
            if (cookies.exist()) {
                appendNewLineIfAll(logDetail, builder).append(cookies.toString());
            }
        }
        if (logDetail == ALL || logDetail == BODY) {
            String responseBodyToAppend;
            if (shouldPrettyPrint) {
                responseBodyToAppend = new Prettifier().getPrettifiedBodyIfPossible(responseOptions, responseBody);
            } else {
                responseBodyToAppend = responseBody.asString();
            }
            if (logDetail == ALL && !isBlank(responseBodyToAppend)) {
                builder.append(SystemUtils.LINE_SEPARATOR).append(SystemUtils.LINE_SEPARATOR);
            }

            builder.append(responseBodyToAppend);
        }
        String response = builder.toString();
        stream.println(response);
        return response;
    }

public static String print ( ResponseOptions responseOptions , ResponseBody responseBody , PrintStream stream , LogDetail logDetail , boolean shouldPrettyPrint ) { final StringBuilder builder = new StringBuilder ( ) ; if ( logDetail == ALL || logDetail == STATUS ) { builder . append ( responseOptions . statusLine ( ) ) ; } if ( logDetail == ALL || logDetail == HEADERS ) { final Headers headers = responseOptions . headers ( ) ; if ( headers . exist ( ) ) { appendNewLineIfAll ( logDetail , builder ) . append ( toString ( headers ) ) ; } } else if ( logDetail == COOKIES ) { final Cookies cookies = responseOptions . detailedCookies ( ) ; if ( cookies . exist ( ) ) { appendNewLineIfAll ( logDetail , builder ) . append ( cookies . toString ( ) ) ; } } if ( logDetail == ALL || logDetail == BODY ) { String responseBodyToAppend ; if ( shouldPrettyPrint ) { responseBodyToAppend = new Prettifier ( ) . getPrettifiedBodyIfPossible ( responseOptions , responseBody ) ; } else { responseBodyToAppend = responseBody . asString ( ) ; } if ( logDetail == ALL && ! isBlank ( responseBodyToAppend ) ) { builder . append ( SystemUtils . LINE_SEPARATOR ) . append ( SystemUtils . LINE_SEPARATOR ) ; } builder . append ( responseBodyToAppend ) ; } String response = builder . toString ( ) ; stream . println ( response ) ; return response ; }

Prints the response to the print stream

@return A string of representing the response


public RestAssuredConfig redirect(RedirectConfig redirectConfig) {
        notNull(redirectConfig, "Redirect config");
        return new RestAssuredConfig(redirectConfig, conf(HttpClientConfig.class), conf(LogConfig.class), conf(EncoderConfig.class),
                conf(DecoderConfig.class), conf(SessionConfig.class), conf(ObjectMapperConfig.class), conf(ConnectionConfig.class),
                conf(JsonConfig.class), conf(XmlConfig.class), conf(SSLConfig.class), conf(MatcherConfig.class),
                conf(HeaderConfig.class), conf(MultiPartConfig.class), conf(ParamConfig.class), conf(OAuthConfig.class), conf(FailureConfig.class));
    }

public
RestAssuredConfig
redirect
(
RedirectConfig
redirectConfig
)
{
notNull
(
redirectConfig
,
"Redirect config"
)
;
return
new
RestAssuredConfig
(
redirectConfig
,
conf
(
HttpClientConfig
.
class
)
,
conf
(
LogConfig
.
class
)
,
conf
(
EncoderConfig
.
class
)
,
conf
(
DecoderConfig
.
class
)
,
conf
(
SessionConfig
.
class
)
,
conf
(
ObjectMapperConfig
.
class
)
,
conf
(
ConnectionConfig
.
class
)
,
conf
(
JsonConfig
.
class
)
,
conf
(
XmlConfig
.
class
)
,
conf
(
SSLConfig
.
class
)
,
conf
(
MatcherConfig
.
class
)
,
conf
(
HeaderConfig
.
class
)
,
conf
(
MultiPartConfig
.
class
)
,
conf
(
ParamConfig
.
class
)
,
conf
(
OAuthConfig
.
class
)
,
conf
(
FailureConfig
.
class
)
)
;
}

Set the redirect config.

@param redirectConfig The {@link RedirectConfig} to set
@return An updated RestAssuredConfiguration


public EncoderConfig defaultQueryParameterCharset(String charset) {
        return new EncoderConfig(defaultContentCharset, charset, shouldAppendDefaultContentCharsetToContentTypeIfUndefined, contentEncoders, contentTypeToDefaultCharset, true);
    }

Specify the default charset for query parameters

@param charset The charset to use.
@return A new instance of {@link EncoderConfig}


public ObjectMapperConfig defaultObjectMapperType(ObjectMapperType defaultObjectMapperType) {
        return new ObjectMapperConfig(defaultObjectMapper, defaultObjectMapperType, gsonObjectMapperFactory,
                jackson1ObjectMapperFactory, jackson2ObjectMapperFactory, jaxbObjectMapperFactory,
                    johnzonObjectMapperFactory, true);
    }

public ObjectMapperConfig defaultObjectMapperType ( ObjectMapperType defaultObjectMapperType ) { return new ObjectMapperConfig ( defaultObjectMapper , defaultObjectMapperType , gsonObjectMapperFactory , jackson1ObjectMapperFactory , jackson2ObjectMapperFactory , jaxbObjectMapperFactory , johnzonObjectMapperFactory , true ) ; }

Creates an object mapper configuration that uses the specified object mapper as default.

@param defaultObjectMapperType The object mapper to use. If null then classpath scanning will be used.

Creates an object mapper configuration that uses the specified object mapper as default .


public ObjectMapperConfig jaxbObjectMapperFactory(JAXBObjectMapperFactory jaxbObjectMapperFactory) {
        return new ObjectMapperConfig(defaultObjectMapper, defaultObjectMapperType, gsonObjectMapperFactory,
                jackson1ObjectMapperFactory, jackson2ObjectMapperFactory, jaxbObjectMapperFactory,
                    johnzonObjectMapperFactory, true);
    }

public ObjectMapperConfig jaxbObjectMapperFactory ( JAXBObjectMapperFactory jaxbObjectMapperFactory ) { return new ObjectMapperConfig ( defaultObjectMapper , defaultObjectMapperType , gsonObjectMapperFactory , jackson1ObjectMapperFactory , jackson2ObjectMapperFactory , jaxbObjectMapperFactory , johnzonObjectMapperFactory , true ) ; }

Specify a custom JAXB object mapper factory.

@param jaxbObjectMapperFactory The object mapper factory

Specify a custom JAXB object mapper factory .


public RestAssuredMockMvcConfig logConfig(LogConfig logConfig) {
        notNull(logConfig, "Log config");
        return new RestAssuredMockMvcConfig(logConfig, encoderConfig, decoderConfig, sessionConfig, objectMapperConfig, jsonConfig, xmlConfig, headerConfig, asyncConfig, multiPartConfig, mockMvcConfig, paramConfig, matcherConfig);
    }

public
RestAssuredMockMvcConfig
logConfig
(
LogConfig
logConfig
)
{
notNull
(
logConfig
,
"Log config"
)
;
return
new
RestAssuredMockMvcConfig
(
logConfig
,
encoderConfig
,
decoderConfig
,
sessionConfig
,
objectMapperConfig
,
jsonConfig
,
xmlConfig
,
headerConfig
,
asyncConfig
,
multiPartConfig
,
mockMvcConfig
,
paramConfig
,
matcherConfig
)
;
}

Set the Log config.

@param logConfig The {@link LogConfig} to set
@return An updated RestAssuredMockMvcConfig


public RestAssuredMockMvcConfig sessionConfig(SessionConfig sessionConfig) {
        notNull(sessionConfig, "Session config");
        return new RestAssuredMockMvcConfig(logConfig, encoderConfig, decoderConfig, sessionConfig, objectMapperConfig, jsonConfig, xmlConfig, headerConfig, asyncConfig, multiPartConfig, mockMvcConfig, paramConfig, matcherConfig);
    }

public
RestAssuredMockMvcConfig
sessionConfig
(
SessionConfig
sessionConfig
)
{
notNull
(
sessionConfig
,
"Session config"
)
;
return
new
RestAssuredMockMvcConfig
(
logConfig
,
encoderConfig
,
decoderConfig
,
sessionConfig
,
objectMapperConfig
,
jsonConfig
,
xmlConfig
,
headerConfig
,
asyncConfig
,
multiPartConfig
,
mockMvcConfig
,
paramConfig
,
matcherConfig
)
;
}

Set the session config.

@param sessionConfig The {@link SessionConfig} to set
@return An updated RestAssuredMockMvcConfig


public RestAssuredMockMvcConfig objectMapperConfig(ObjectMapperConfig objectMapperConfig) {
        notNull(objectMapperConfig, "Object mapper config");
        return new RestAssuredMockMvcConfig(logConfig, encoderConfig, decoderConfig, sessionConfig, objectMapperConfig, jsonConfig, xmlConfig, headerConfig, asyncConfig, multiPartConfig, mockMvcConfig, paramConfig, matcherConfig);
    }

public
RestAssuredMockMvcConfig
objectMapperConfig
(
ObjectMapperConfig
objectMapperConfig
)
{
notNull
(
objectMapperConfig
,
"Object mapper config"
)
;
return
new
RestAssuredMockMvcConfig
(
logConfig
,
encoderConfig
,
decoderConfig
,
sessionConfig
,
objectMapperConfig
,
jsonConfig
,
xmlConfig
,
headerConfig
,
asyncConfig
,
multiPartConfig
,
mockMvcConfig
,
paramConfig
,
matcherConfig
)
;
}

Set the object mapper config.

@param objectMapperConfig The {@link ObjectMapperConfig} to set
@return An updated RestAssuredMockMvcConfig


public RestAssuredMockMvcConfig jsonConfig(JsonConfig jsonConfig) {
        notNull(jsonConfig, "JsonConfig");
        return new RestAssuredMockMvcConfig(logConfig, encoderConfig, decoderConfig, sessionConfig,
                objectMapperConfig, jsonConfig, xmlConfig, headerConfig, asyncConfig, multiPartConfig, mockMvcConfig, paramConfig, matcherConfig);
    }

public RestAssuredMockMvcConfig jsonConfig ( JsonConfig jsonConfig ) { notNull ( jsonConfig , "JsonConfig" ) ; return new RestAssuredMockMvcConfig ( logConfig , encoderConfig , decoderConfig , sessionConfig , objectMapperConfig , jsonConfig , xmlConfig , headerConfig , asyncConfig , multiPartConfig , mockMvcConfig , paramConfig , matcherConfig ) ; }

Set the Json config.

@param jsonConfig The {@link JsonConfig} to set
@return An updated RestAssuredMockMvcConfig


public RestAssuredMockMvcConfig xmlConfig(XmlConfig xmlConfig) {
        notNull(xmlConfig, "XmlConfig");
        return new RestAssuredMockMvcConfig(logConfig, encoderConfig, decoderConfig, sessionConfig,
                objectMapperConfig, jsonConfig, xmlConfig, headerConfig, asyncConfig, multiPartConfig, mockMvcConfig, paramConfig, matcherConfig);
    }

public RestAssuredMockMvcConfig xmlConfig ( XmlConfig xmlConfig ) { notNull ( xmlConfig , "XmlConfig" ) ; return new RestAssuredMockMvcConfig ( logConfig , encoderConfig , decoderConfig , sessionConfig , objectMapperConfig , jsonConfig , xmlConfig , headerConfig , asyncConfig , multiPartConfig , mockMvcConfig , paramConfig , matcherConfig ) ; }

Set the Xml config.

@param xmlConfig The {@link XmlConfig} to set
@return An updated RestAssuredMockMvcConfig


public RestAssuredMockMvcConfig encoderConfig(EncoderConfig encoderConfig) {
        notNull(encoderConfig, "EncoderConfig");
        return new RestAssuredMockMvcConfig(logConfig, encoderConfig, decoderConfig, sessionConfig,
                objectMapperConfig, jsonConfig, xmlConfig, headerConfig, asyncConfig, multiPartConfig, mockMvcConfig, paramConfig, matcherConfig);
    }

public RestAssuredMockMvcConfig encoderConfig ( EncoderConfig encoderConfig ) { notNull ( encoderConfig , "EncoderConfig" ) ; return new RestAssuredMockMvcConfig ( logConfig , encoderConfig , decoderConfig , sessionConfig , objectMapperConfig , jsonConfig , xmlConfig , headerConfig , asyncConfig , multiPartConfig , mockMvcConfig , paramConfig , matcherConfig ) ; }

Set the encoder config

@param encoderConfig The {@link EncoderConfig} to set
@return An updated RestAssuredMockMvcConfig


public RestAssuredMockMvcConfig headerConfig(HeaderConfig headerConfig) {
        notNull(headerConfig, "HeaderConfig");
        return new RestAssuredMockMvcConfig(logConfig, encoderConfig, decoderConfig, sessionConfig,
                objectMapperConfig, jsonConfig, xmlConfig, headerConfig, asyncConfig, multiPartConfig, mockMvcConfig, paramConfig, matcherConfig);
    }

public RestAssuredMockMvcConfig headerConfig ( HeaderConfig headerConfig ) { notNull ( headerConfig , "HeaderConfig" ) ; return new RestAssuredMockMvcConfig ( logConfig , encoderConfig , decoderConfig , sessionConfig , objectMapperConfig , jsonConfig , xmlConfig , headerConfig , asyncConfig , multiPartConfig , mockMvcConfig , paramConfig , matcherConfig ) ; }

Set the header config

@param headerConfig The {@link HeaderConfig} to set
@return An updated RestAssuredMockMvcConfig


public RestAssuredMockMvcConfig asyncConfig(AsyncConfig asyncConfig) {
        notNull(asyncConfig, AsyncConfig.class);
        return new RestAssuredMockMvcConfig(logConfig, encoderConfig, decoderConfig, sessionConfig,
                objectMapperConfig, jsonConfig, xmlConfig, headerConfig, asyncConfig, multiPartConfig, mockMvcConfig, paramConfig, matcherConfig);
    }

public RestAssuredMockMvcConfig asyncConfig ( AsyncConfig asyncConfig ) { notNull ( asyncConfig , AsyncConfig . class ) ; return new RestAssuredMockMvcConfig ( logConfig , encoderConfig , decoderConfig , sessionConfig , objectMapperConfig , jsonConfig , xmlConfig , headerConfig , asyncConfig , multiPartConfig , mockMvcConfig , paramConfig , matcherConfig ) ; }

Set the async config

@param asyncConfig The {@link AsyncConfig} to set
@return An updated RestAssuredMockMvcConfig


public RestAssuredMockMvcConfig mockMvcConfig(MockMvcConfig mockMvcConfig) {
        notNull(mockMvcConfig, MockMvcConfig.class);
        return new RestAssuredMockMvcConfig(logConfig, encoderConfig, decoderConfig, sessionConfig,
                objectMapperConfig, jsonConfig, xmlConfig, headerConfig, asyncConfig, multiPartConfig, mockMvcConfig, paramConfig, matcherConfig);
    }

public RestAssuredMockMvcConfig mockMvcConfig ( MockMvcConfig mockMvcConfig ) { notNull ( mockMvcConfig , MockMvcConfig . class ) ; return new RestAssuredMockMvcConfig ( logConfig , encoderConfig , decoderConfig , sessionConfig , objectMapperConfig , jsonConfig , xmlConfig , headerConfig , asyncConfig , multiPartConfig , mockMvcConfig , paramConfig , matcherConfig ) ; }

Set the MockMVC config

@param mockMvcConfig The {@link MockMvcConfig} to set
@return An updated RestAssuredMockMvcConfig


public RestAssuredMockMvcConfig multiPartConfig(MultiPartConfig multiPartConfig) {
        notNull(multiPartConfig, MultiPartConfig.class);
        return new RestAssuredMockMvcConfig(logConfig, encoderConfig, decoderConfig, sessionConfig,
                objectMapperConfig, jsonConfig, xmlConfig, headerConfig, asyncConfig, multiPartConfig, mockMvcConfig, paramConfig, matcherConfig);
    }

public RestAssuredMockMvcConfig multiPartConfig ( MultiPartConfig multiPartConfig ) { notNull ( multiPartConfig , MultiPartConfig . class ) ; return new RestAssuredMockMvcConfig ( logConfig , encoderConfig , decoderConfig , sessionConfig , objectMapperConfig , jsonConfig , xmlConfig , headerConfig , asyncConfig , multiPartConfig , mockMvcConfig , paramConfig , matcherConfig ) ; }

Set the multi-part config

@param multiPartConfig The {@link MultiPartConfig} to set
@return An updated RestAssuredMockMvcConfig


public RestAssuredMockMvcConfig paramConfig(MockMvcParamConfig paramConfig) {
        notNull(paramConfig, MultiPartConfig.class);
        return new RestAssuredMockMvcConfig(logConfig, encoderConfig, decoderConfig, sessionConfig,
                objectMapperConfig, jsonConfig, xmlConfig, headerConfig, asyncConfig, multiPartConfig, mockMvcConfig, paramConfig, matcherConfig);
    }

public RestAssuredMockMvcConfig paramConfig ( MockMvcParamConfig paramConfig ) { notNull ( paramConfig , MultiPartConfig . class ) ; return new RestAssuredMockMvcConfig ( logConfig , encoderConfig , decoderConfig , sessionConfig , objectMapperConfig , jsonConfig , xmlConfig , headerConfig , asyncConfig , multiPartConfig , mockMvcConfig , paramConfig , matcherConfig ) ; }

Set the parameter config

@param paramConfig The {@link MockMvcParamConfig} to set
@return An updated RestAssuredMockMvcConfig


public RestAssuredMockMvcConfig matcherConfig(MatcherConfig matcherConfig) {
        notNull(matcherConfig, MatcherConfig.class);
        return new RestAssuredMockMvcConfig(logConfig, encoderConfig, decoderConfig, sessionConfig,
                objectMapperConfig, jsonConfig, xmlConfig, headerConfig, asyncConfig, multiPartConfig, mockMvcConfig, paramConfig, matcherConfig);
    }

public RestAssuredMockMvcConfig matcherConfig ( MatcherConfig matcherConfig ) { notNull ( matcherConfig , MatcherConfig . class ) ; return new RestAssuredMockMvcConfig ( logConfig , encoderConfig , decoderConfig , sessionConfig , objectMapperConfig , jsonConfig , xmlConfig , headerConfig , asyncConfig , multiPartConfig , mockMvcConfig , paramConfig , matcherConfig ) ; }

Set the matcher config

@param matcherConfig The {@link MockMvcParamConfig} to set
@return An updated RestAssuredMockMvcConfig


public CertificateAuthSettings allowAllHostnames() {
        return new CertificateAuthSettings(keystoreType, trustStoreType, port, trustStore, keyStore, ALLOW_ALL_HOSTNAME_VERIFIER, sslSocketFactory);
    }

public CertificateAuthSettings allowAllHostnames ( ) { return new CertificateAuthSettings ( keystoreType , trustStoreType , port , trustStore , keyStore , ALLOW_ALL_HOSTNAME_VERIFIER , sslSocketFactory ) ; }

Configure the CertificateAuthSettings to allow all host names.

@return A new CertificateAuthSettings instance
@see org.apache.http.conn.ssl.SSLSocketFactory#ALLOW_ALL_HOSTNAME_VERIFIER

Configure the CertificateAuthSettings to allow all host names .


public XmlPathConfig declareNamespaces(Map<String, String> namespacesToDeclare) {
        return new XmlPathConfig(jaxbObjectMapperFactory, defaultParserType, defaultDeserializer, charset, features, namespacesToDeclare,
                properties, validating, namespaceAware, allowDocTypeDeclaration);
    }

public XmlPathConfig declareNamespaces ( Map < String , String > namespacesToDeclare ) { return new XmlPathConfig ( jaxbObjectMapperFactory , defaultParserType , defaultDeserializer , charset , features , namespacesToDeclare , properties , validating , namespaceAware , allowDocTypeDeclaration ) ; }

Specify declared namespaces that will be used when parsing XML.

@param namespacesToDeclare A map containing features that will be used by the underlying {@link groovy.util.XmlSlurper}.
@return A new instance of XmlPathConfig
@see org.xml.sax.XMLReader#setFeature(java.lang.String, boolean)

Specify declared namespaces that will be used when parsing XML .


public XmlPathConfig declaredNamespace(String prefix, String namespaceURI) {
        Validate.notEmpty(prefix, "Prefix cannot be empty");
        Validate.notEmpty(namespaceURI, "Namespace URI cannot be empty");
        Map<String, String> updatedNamespaces = new HashMap<String, String>(declaredNamespaces);
        updatedNamespaces.put(prefix, namespaceURI);
        return new XmlPathConfig(jaxbObjectMapperFactory, defaultParserType, defaultDeserializer, charset, features, updatedNamespaces,
                properties, validating, true, allowDocTypeDeclaration);
    }

public
XmlPathConfig
declaredNamespace
(
String
prefix
,
String
namespaceURI
)
{
Validate
.
notEmpty
(
prefix
,
"Prefix cannot be empty"
)
;
Validate
.
notEmpty
(
namespaceURI
,
"Namespace URI cannot be empty"
)
;
Map
<
String
,
String
>
updatedNamespaces
=
new
HashMap
<
String
,
String
>
(
declaredNamespaces
)
;
updatedNamespaces
.
put
(
prefix
,
namespaceURI
)
;
return
new
XmlPathConfig
(
jaxbObjectMapperFactory
,
defaultParserType
,
defaultDeserializer
,
charset
,
features
,
updatedNamespaces
,
properties
,
validating
,
true
,
allowDocTypeDeclaration
)
;
}

Declares a namespace.

@param prefix       The feature name, which is a fully-qualified URI.
@param namespaceURI The requested value of the feature (true or false).
@return A new XmlPathConfig instance
@see org.xml.sax.XMLReader#setFeature(java.lang.String, boolean)


public Object request(String method, boolean hasBody, Closure configClosure) throws ClientProtocolException, IOException {
        return this.doRequest(this.defaultURI.toURI(), method, this.defaultContentType, hasBody, configClosure);
    }

public Object request ( String method , boolean hasBody , Closure configClosure ) throws ClientProtocolException , IOException { return this . doRequest ( this . defaultURI . toURI ( ) , method , this . defaultContentType , hasBody , configClosure ) ; }

Make an HTTP request to the default URI, and parse using the default
content-type.

@param method        {@link HttpRequestFactory HTTP method}
@param configClosure request configuration options
@return whatever value was returned by the executed response handler.
@throws ClientProtocolException
@throws IOException
@see #request(Object, HttpRequestFactory, Object, Closure)

Make an HTTP request to the default URI and parse using the default content - type .


public void setHeaders(Map<?, ?> headers) {
        this.defaultRequestHeaders.clear();
        if (headers == null) return;
        for (Object key : headers.keySet()) {
            Object val = headers.get(key);
            if (val == null) continue;
            this.defaultRequestHeaders.put(key.toString(), val.toString());
        }
    }

public void setHeaders ( Map < ? , ? > headers ) { this . defaultRequestHeaders . clear ( ) ; if ( headers == null ) return ; for ( Object key : headers . keySet ( ) ) { Object val = headers . get ( key ) ; if ( val == null ) continue ; this . defaultRequestHeaders . put ( key . toString ( ) , val . toString ( ) ) ; } }

Set the default headers to add to all requests made by this builder
instance.  These values will replace any previously set default headers.

@param headers map of header names & values.

Set the default headers to add to all requests made by this builder instance . These values will replace any previously set default headers .


public void setProxy(String host, int port, String scheme) {
        getClient().getParams().setParameter(
                ConnRoutePNames.DEFAULT_PROXY,
                new HttpHost(host, port, scheme));
    }

public void setProxy ( String host , int port , String scheme ) { getClient ( ) . getParams ( ) . setParameter ( ConnRoutePNames . DEFAULT_PROXY , new HttpHost ( host , port , scheme ) ) ; }

Set the default HTTP proxy to be used for all requests.

@param host   host name or IP
@param port   port, or -1 for the default port
@param scheme usually "http" or "https," or null for the default
@see HttpHost#HttpHost(String, int, String)

Set the default HTTP proxy to be used for all requests .


public MultiPartSpecBuilder controlName(String controlName) {
        Validate.notEmpty(controlName, "Control name cannot be empty");
        this.controlName = controlName;
        this.isControlNameExplicit = true;
        return this;
    }

public
MultiPartSpecBuilder
controlName
(
String
controlName
)
{
Validate
.
notEmpty
(
controlName
,
"Control name cannot be empty"
)
;
this
.
controlName
=
controlName
;
this
.
isControlNameExplicit
=
true
;
return
this
;
}

Specify the control name of this multi-part.

@param controlName The control name to use. Default is file.
@return An instance of MultiPartSpecBuilder

Specify the control name of this multi - part .


public MultiPartSpecBuilder header(String name, String value) {
        Validate.notEmpty(name, "Header name cannot be empty");
        Validate.notEmpty(value, "Header value cannot be empty");

        // Replace previous header if exists
        final Set<String> headerNames = headers.keySet();
        final String trimmedName = name.trim();
        for (String headerName : headerNames) {
            if (headerName.equalsIgnoreCase(trimmedName)) {
                headers.remove(headerName);
            }
        }
        // Put the name header in the header list
        headers.put(name, value);
        return this;
    }

Add a header to this multipart specification.

@param name The name of the header
@param value The value of the header
@return An instance of MultiPartSpecBuilder

Add a header to this multipart specification .


public void basic(String host, int port, String user, String pass) {
        builder.getClient().getCredentialsProvider().setCredentials(
                new AuthScope(host, port),
                new UsernamePasswordCredentials(user, pass)
        );
    }

public void basic ( String host , int port , String user , String pass ) { builder . getClient ( ) . getCredentialsProvider ( ) . setCredentials ( new AuthScope ( host , port ) , new UsernamePasswordCredentials ( user , pass ) ) ; }

Set authentication credentials to be used for the given host and port.

@param host
@param port
@param user
@param pass

Set authentication credentials to be used for the given host and port .


public void ntlm(String host, int port, String user, String pass, String workstation, String domain) {
        builder.getClient().getCredentialsProvider().setCredentials(
                new AuthScope(host, port),
                new NTCredentials(user, pass, workstation, domain)
        );
    }

public void ntlm ( String host , int port , String user , String pass , String workstation , String domain ) { builder . getClient ( ) . getCredentialsProvider ( ) . setCredentials ( new AuthScope ( host , port ) , new NTCredentials ( user , pass , workstation , domain ) ) ; }

Set NTLM authentication credentials to be used for the given host and port.

@param host
@param port
@param user
@param pass
@param workstation
@param domain

Set NTLM authentication credentials to be used for the given host and port .


public static Headers headers(Header header, Header... additionalHeaders) {
        notNull(header, "Header");
        final List<Header> headerList = new LinkedList<Header>();
        headerList.add(header);
        if (additionalHeaders != null) {
            Collections.addAll(headerList, additionalHeaders);
        }
        return new Headers(headerList);
    }

public static Headers headers ( Header header , Header ... additionalHeaders ) { notNull ( header , "Header" ) ; final List < Header > headerList = new LinkedList < Header > ( ) ; headerList . add ( header ) ; if ( additionalHeaders != null ) { Collections . addAll ( headerList , additionalHeaders ) ; } return new Headers ( headerList ) ; }

An alternative way to create a Headers object from the constructor.

@param header            The header to be included
@param additionalHeaders Additional headers to be included (optional)
@return A new headers object containing the specified headers

An alternative way to create a Headers object from the constructor .


public static void reset() {
        mockMvcFactory = null;
        config = null;
        basePath = "/";
        resultHandlers.clear();
        requestPostProcessors.clear();
        responseSpecification = null;
        requestSpecification = null;
        authentication = null;
    }

public static void reset ( ) { mockMvcFactory = null ; config = null ; basePath = "/" ; resultHandlers . clear ( ) ; requestPostProcessors . clear ( ) ; responseSpecification = null ; requestSpecification = null ; authentication = null ; }

Reset all static configurations to their default values.

Reset all static configurations to their default values .


public ResponseBuilder setHeader(String name, String value) {
        notNull(name, "Header name");
        notNull(value, "Header value");

        List<Header> newHeaders = new ArrayList<Header>(restAssuredResponse.headers().asList());
        newHeaders.add(new Header(name, value));
        restAssuredResponse.setResponseHeaders(new Headers(newHeaders));

        if (trim(name).equalsIgnoreCase(CONTENT_TYPE)) {
            restAssuredResponse.setContentType(value);
        }
        return this;
    }

public
ResponseBuilder
setHeader
(
String
name
,
String
value
)
{
notNull
(
name
,
"Header name"
)
;
notNull
(
value
,
"Header value"
)
;
List
<
Header
>
newHeaders
=
new
ArrayList
<
Header
>
(
restAssuredResponse
.
headers
(
)
.
asList
(
)
)
;
newHeaders
.
add
(
new
Header
(
name
,
value
)
)
;
restAssuredResponse
.
setResponseHeaders
(
new
Headers
(
newHeaders
)
)
;
if
(
trim
(
name
)
.
equalsIgnoreCase
(
CONTENT_TYPE
)
)
{
restAssuredResponse
.
setContentType
(
value
)
;
}
return
this
;
}

Set a specific header

@return The builder


public Response build() {
        final int statusCode = restAssuredResponse.statusCode();

        if (statusCode < 100 || statusCode >= 600) {
            throw new IllegalArgumentException(format("Status code must be greater than 100 and less than 600, was %d.", statusCode));
        }

        if (StringUtils.isBlank(restAssuredResponse.statusLine())) {
            restAssuredResponse.setStatusLine(restAssuredResponse.statusCode());
        }

        restAssuredResponse.setRpr(new ResponseParserRegistrar());
        return restAssuredResponse;
    }

Build the actual response

@return The response object


public DetailedCookieMatcher value(Matcher<? super String> valueMatcher) {
        return new DetailedCookieMatcher(and(Matchers.hasProperty("value", valueMatcher)));
    }

public DetailedCookieMatcher value ( Matcher < ? super String > valueMatcher ) { return new DetailedCookieMatcher ( and ( Matchers . hasProperty ( "value" , valueMatcher ) ) ) ; }

Verifies whether value of cookie satisfies specified matcher.
@param valueMatcher value assertion
@return A {@link DetailedCookieMatcher} instance with and-composed value property assertion

Verifies whether value of cookie satisfies specified matcher .


public DetailedCookieMatcher comment(Matcher<? super String> commentMatcher) {
        return new DetailedCookieMatcher(and(Matchers.hasProperty("comment", commentMatcher)));
    }

public DetailedCookieMatcher comment ( Matcher < ? super String > commentMatcher ) { return new DetailedCookieMatcher ( and ( Matchers . hasProperty ( "comment" , commentMatcher ) ) ) ; }

Verifies whether comment of cookie satisfies specified matcher.
@param commentMatcher comment assertion
@return A {@link DetailedCookieMatcher} instance with and-composed comment property assertion

Verifies whether comment of cookie satisfies specified matcher .


public DetailedCookieMatcher expiryDate(Matcher<? super Date> expiryDateMatcher) {
        return new DetailedCookieMatcher(and(Matchers.hasProperty("expiryDate", expiryDateMatcher)));
    }

public DetailedCookieMatcher expiryDate ( Matcher < ? super Date > expiryDateMatcher ) { return new DetailedCookieMatcher ( and ( Matchers . hasProperty ( "expiryDate" , expiryDateMatcher ) ) ) ; }

Verifies whether expiry date of cookie satisfies specified matcher.
@param expiryDateMatcher expiry date assertion
@return A {@link DetailedCookieMatcher} instance with and-composed expiry date property assertion

Verifies whether expiry date of cookie satisfies specified matcher .


public DetailedCookieMatcher domain(Matcher<? super String> domainMatcher) {
        return new DetailedCookieMatcher(and(Matchers.hasProperty("domain", domainMatcher)));
    }

public DetailedCookieMatcher domain ( Matcher < ? super String > domainMatcher ) { return new DetailedCookieMatcher ( and ( Matchers . hasProperty ( "domain" , domainMatcher ) ) ) ; }

Verifies whether domain of cookie satisfies specified matcher.
@param domainMatcher assertion for domain property
@return A {@link DetailedCookieMatcher} instance with and-composed domain property assertion

Verifies whether domain of cookie satisfies specified matcher .


public DetailedCookieMatcher path(Matcher<? super String> pathMatcher) {
        return new DetailedCookieMatcher(and(Matchers.hasProperty("path", pathMatcher)));
    }

public DetailedCookieMatcher path ( Matcher < ? super String > pathMatcher ) { return new DetailedCookieMatcher ( and ( Matchers . hasProperty ( "path" , pathMatcher ) ) ) ; }

Verifies whether path of cookie satisfies specified matcher.
@param pathMatcher assertion for path property
@return A {@link DetailedCookieMatcher} instance with and-composed path property assertion

Verifies whether path of cookie satisfies specified matcher .


public DetailedCookieMatcher secured(Matcher<? super Boolean> securedMatcher) {
        return new DetailedCookieMatcher(and(Matchers.hasProperty("secured", securedMatcher)));
    }

public DetailedCookieMatcher secured ( Matcher < ? super Boolean > securedMatcher ) { return new DetailedCookieMatcher ( and ( Matchers . hasProperty ( "secured" , securedMatcher ) ) ) ; }

Verifies whether secured property of cookie satisfies specified matcher.
@param securedMatcher assertion for secured property
@return A {@link DetailedCookieMatcher} instance with and-composed secured property assertion

Verifies whether secured property of cookie satisfies specified matcher .


public DetailedCookieMatcher httpOnly(Matcher<? super Boolean> httpOnlyMatcher) {
        return new DetailedCookieMatcher(and(Matchers.hasProperty("httpOnly", httpOnlyMatcher)));
    }

public DetailedCookieMatcher httpOnly ( Matcher < ? super Boolean > httpOnlyMatcher ) { return new DetailedCookieMatcher ( and ( Matchers . hasProperty ( "httpOnly" , httpOnlyMatcher ) ) ) ; }

Verifies whether http-only property of cookie satisfies specified matcher.
@param httpOnlyMatcher assertion for domain property
@return A {@link DetailedCookieMatcher} instance with and-composed http-only property assertion

Verifies whether http - only property of cookie satisfies specified matcher .


public DetailedCookieMatcher version(Matcher<? super Integer> versionMatcher) {
        return new DetailedCookieMatcher(and(Matchers.hasProperty("version", versionMatcher)));
    }

public DetailedCookieMatcher version ( Matcher < ? super Integer > versionMatcher ) { return new DetailedCookieMatcher ( and ( Matchers . hasProperty ( "version" , versionMatcher ) ) ) ; }

Verifies whether version of cookie satisfies specified matcher.
@param versionMatcher assertion for version property
@return A {@link DetailedCookieMatcher} instance with and-composed version property assertion

Verifies whether version of cookie satisfies specified matcher .


public DetailedCookieMatcher maxAge(Matcher<? super Integer> maxAgeMatcher) {
        return new DetailedCookieMatcher(and(Matchers.hasProperty("maxAge", maxAgeMatcher)));
    }

public DetailedCookieMatcher maxAge ( Matcher < ? super Integer > maxAgeMatcher ) { return new DetailedCookieMatcher ( and ( Matchers . hasProperty ( "maxAge" , maxAgeMatcher ) ) ) ; }

Verifies whether max age of cookie satisfies specified matcher.
@param maxAgeMatcher assertion for max age property
@return A {@link DetailedCookieMatcher} instance with and-composed max age property assertion

Verifies whether max age of cookie satisfies specified matcher .


public ResponseSpecBuilder expectHeader(String headerName, Matcher<String> expectedValueMatcher) {
        spec.header(headerName, expectedValueMatcher);
        return this;
    }

public ResponseSpecBuilder expectHeader ( String headerName , Matcher < String > expectedValueMatcher ) { spec . header ( headerName , expectedValueMatcher ) ; return this ; }

Expect that a response header matches the supplied header name and hamcrest matcher.

@param headerName           The name of the expected header
@param expectedValueMatcher The Hamcrest matcher that must conform to the value
@return The builder

Expect that a response header matches the supplied header name and hamcrest matcher .


public ResponseSpecBuilder expectHeader(String headerName, String expectedValue) {
        spec.header(headerName, expectedValue);
        return this;
    }

public ResponseSpecBuilder expectHeader ( String headerName , String expectedValue ) { spec . header ( headerName , expectedValue ) ; return this ; }

Expect that a response header matches the supplied name and value.

@param headerName    The name of the expected header
@param expectedValue The value of the expected header
@return The builder

Expect that a response header matches the supplied name and value .


public ResponseSpecBuilder expectCookie(String cookieName, String expectedValue) {
        spec.cookie(cookieName, expectedValue);
        return this;
    }

public ResponseSpecBuilder expectCookie ( String cookieName , String expectedValue ) { spec . cookie ( cookieName , expectedValue ) ; return this ; }

Expect that a response cookie matches the supplied name and value.

@param cookieName    The name of the expected cookie
@param expectedValue The value of the expected cookie
@return The builder

Expect that a response cookie matches the supplied name and value .


public ProxySpecification withHost(String host) {
        return new ProxySpecification(host, port, scheme, username, password);
    }

public ProxySpecification withHost ( String host ) { return new ProxySpecification ( host , port , scheme , username , password ) ; }

Specify the hostname of the proxy.

@param host The hostname of the proxy.
@return A new ProxySpecification instance


public JsonPathConfig numberReturnType(NumberReturnType numberReturnType) {
        return new JsonPathConfig(numberReturnType, defaultParserType, gsonObjectMapperFactory,
                jackson1ObjectMapperFactory, jackson2ObjectMapperFactory,
                    johnzonObjectMapperFactory, defaultDeserializer, charset);
    }

public JsonPathConfig numberReturnType ( NumberReturnType numberReturnType ) { return new JsonPathConfig ( numberReturnType , defaultParserType , gsonObjectMapperFactory , jackson1ObjectMapperFactory , jackson2ObjectMapperFactory , johnzonObjectMapperFactory , defaultDeserializer , charset ) ; }

Specifies if JsonPath should use floats and doubles or BigDecimals to represent Json numbers.

@param numberReturnType The choice.
@return A new instance of JsonPathConfig with the given configuration

Specifies if JsonPath should use floats and doubles or BigDecimals to represent Json numbers .


public JsonPathConfig defaultParserType(JsonParserType defaultParserType) {
        return new JsonPathConfig(numberReturnType, defaultParserType, gsonObjectMapperFactory,
                jackson1ObjectMapperFactory, jackson2ObjectMapperFactory,
                    johnzonObjectMapperFactory, defaultDeserializer, charset);
    }

public JsonPathConfig defaultParserType ( JsonParserType defaultParserType ) { return new JsonPathConfig ( numberReturnType , defaultParserType , gsonObjectMapperFactory , jackson1ObjectMapperFactory , jackson2ObjectMapperFactory , johnzonObjectMapperFactory , defaultDeserializer , charset ) ; }

Creates an json path configuration that uses the specified parser type as default.

@param defaultParserType The parser type to use. If null then classpath scanning will be used.

Creates an json path configuration that uses the specified parser type as default .


public LogConfig defaultStream(PrintStream printStream) {
        return new LogConfig(printStream, true, logDetailIfValidationFails, urlEncodeRequestUri, true);
    }

public LogConfig defaultStream ( PrintStream printStream ) { return new LogConfig ( printStream , true , logDetailIfValidationFails , urlEncodeRequestUri , true ) ; }

Specify a new default stream to the print to.

@param printStream The stream
@return A new LogConfig instance

Specify a new default stream to the print to .


public LogConfig enableLoggingOfRequestAndResponseIfValidationFails(LogDetail logDetail) {
        return new LogConfig(defaultPrintStream, prettyPrintingEnabled, logDetail, urlEncodeRequestUri, true);
    }

Enable logging of both the request and the response if REST Assureds test validation fails with the specified log detail

@param logDetail The log detail to show in the log
@return A new LogConfig instance


static HttpRequestBase createHttpRequest(URI uri, String httpMethod, boolean hasBody) {
        String method = notNull(upperCase(trimToNull(httpMethod)), "Http method");
        Class<? extends HttpRequestBase> type = HTTP_METHOD_TO_HTTP_REQUEST_TYPE.get(method);
        final HttpRequestBase httpRequest;
        // If we are sending HTTP method that does not allow body (like GET) then HTTP library prevents
        // us from including it, however we chose to allow deviations from standard if user wants so,
        // so it needs custom handling - hence the second condition below.
        // Otherwise we should use standard implementation found in the map
        if (type == null || (!(type.isInstance(HttpEntityEnclosingRequest.class)) && hasBody)) {
            httpRequest = new CustomHttpMethod(method, uri);
        } else {
            try {
                httpRequest = type.newInstance();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
            httpRequest.setURI(uri);
        }
        return httpRequest;
    }

Get the HttpRequest class that represents this request type.

@return a non-abstract class that implements {@link HttpRequest}

Get the HttpRequest class that represents this request type .


public MultiPartConfig defaultBoundary(String defaultBoundary) {
        return new MultiPartConfig(defaultControlName, defaultFileName, defaultSubtype, defaultBoundary, defaultCharset, true);
    }

public MultiPartConfig defaultBoundary ( String defaultBoundary ) { return new MultiPartConfig ( defaultControlName , defaultFileName , defaultSubtype , defaultBoundary , defaultCharset , true ) ; }

Specify an explicit default multipart boundary to use when sending multi-part data.

@param defaultBoundary The boundary to set
@return An updated MultiPartConfig

Specify an explicit default multipart boundary to use when sending multi - part data .


public MockMvcRequestSpecBuilder addAttribute(String attributeName, Object attributeValue) {
        spec.attribute(attributeName, attributeValue);
        return this;
    }

public MockMvcRequestSpecBuilder addAttribute ( String attributeName , Object attributeValue ) { spec . attribute ( attributeName , attributeValue ) ; return this ; }

Add request attribute

@param attributeName  The attribute name
@param attributeValue The attribute value
@return The request specification builder


public MockMvcRequestSpecBuilder addHeader(String headerName, String headerValue) {
        spec.header(headerName, headerValue);
        return this;
    }

public MockMvcRequestSpecBuilder addHeader ( String headerName , String headerValue ) { spec . header ( headerName , headerValue ) ; return this ; }

Add a header to be sent with the request

@param headerName  The header name
@param headerValue The header value
@return The request specification builder


public MockMvcRequestSpecBuilder addMultiPart(String controlName, String contentBody, String mimeType) {
        spec.multiPart(controlName, mimeType);
        return this;
    }

public MockMvcRequestSpecBuilder addMultiPart ( String controlName , String contentBody , String mimeType ) { spec . multiPart ( controlName , mimeType ) ; return this ; }

Specify a string to send to the server using multi-part form data with a specific mime-type.

@param controlName Defines the control name of the body part. In HTML this is the attribute name of the input tag.
@param contentBody The string to send
@param mimeType    The mime-type
@return The request specification

Specify a string to send to the server using multi - part form data with a specific mime - type .


public MockMvcRequestSpecBuilder addResultHandlers(ResultHandler resultHandler, ResultHandler... additionalResultHandlers) {
        spec.resultHandlers(resultHandler, additionalResultHandlers);
        return this;
    }

public MockMvcRequestSpecBuilder addResultHandlers ( ResultHandler resultHandler , ResultHandler ... additionalResultHandlers ) { spec . resultHandlers ( resultHandler , additionalResultHandlers ) ; return this ; }

Add a result handler

@param resultHandler The result handler
@return MockMvcRequestSpecBuilder


public <T> HttpClientConfig setParam(String parameterName, T parameterValue) {
        notNull(parameterName, "Parameter name");
        final Map<String, Object> newParams = new HashMap<String, Object>(httpClientParams);
        newParams.put(parameterName, parameterValue);
        return new HttpClientConfig(httpClientFactory, newParams, httpMultipartMode, shouldReuseHttpClientInstance, NO_HTTP_CLIENT, true);
    }

public
<
T
>
HttpClientConfig
setParam
(
String
parameterName
,
T
parameterValue
)
{
notNull
(
parameterName
,
"Parameter name"
)
;
final
Map
<
String
,
Object
>
newParams
=
new
HashMap
<
String
,
Object
>
(
httpClientParams
)
;
newParams
.
put
(
parameterName
,
parameterValue
)
;
return
new
HttpClientConfig
(
httpClientFactory
,
newParams
,
httpMultipartMode
,
shouldReuseHttpClientInstance
,
NO_HTTP_CLIENT
,
true
)
;
}

Set a http client parameter.

@param parameterName  The name of the parameter
@param parameterValue The value of the parameter (may be null)
@param <T>            The parameter type
@return An updated HttpClientConfig


public HttpClientConfig addParams(Map<String, ?> httpClientParams) {
        notNull(httpClientParams, "httpClientParams");
        final Map<String, Object> newParams = new HashMap<String, Object>(this.httpClientParams);
        newParams.putAll(httpClientParams);
        return new HttpClientConfig(httpClientFactory, newParams, httpMultipartMode, shouldReuseHttpClientInstance, NO_HTTP_CLIENT, true);
    }

public HttpClientConfig addParams ( Map < String , ? > httpClientParams ) { notNull ( httpClientParams , "httpClientParams" ) ; final Map < String , Object > newParams = new HashMap < String , Object > ( this . httpClientParams ) ; newParams . putAll ( httpClientParams ) ; return new HttpClientConfig ( httpClientFactory , newParams , httpMultipartMode , shouldReuseHttpClientInstance , NO_HTTP_CLIENT , true ) ; }

Add the given parameters to an already configured number of parameters.

@param httpClientParams The parameters.
@return An updated HttpClientConfig

Add the given parameters to an already configured number of parameters .


public HttpClientConfig httpClientFactory(HttpClientFactory httpClientFactory) {
        return new HttpClientConfig(httpClientFactory, httpClientParams, httpMultipartMode, shouldReuseHttpClientInstance, NO_HTTP_CLIENT, true);
    }

public HttpClientConfig httpClientFactory ( HttpClientFactory httpClientFactory ) { return new HttpClientConfig ( httpClientFactory , httpClientParams , httpMultipartMode , shouldReuseHttpClientInstance , NO_HTTP_CLIENT , true ) ; }

Set the http client factory that Rest Assured should use when making request. For each request REST Assured will invoke the factory to get the a the HttpClient instance.

@param httpClientFactory The http client factory to use.
@return An updated HttpClientConfig

Set the http client factory that Rest Assured should use when making request . For each request REST Assured will invoke the factory to get the a the HttpClient instance .


public HttpClientConfig httpMultipartMode(HttpMultipartMode httpMultipartMode) {
        return new HttpClientConfig(httpClientFactory, httpClientParams, httpMultipartMode, shouldReuseHttpClientInstance, httpClient, true);
    }

public HttpClientConfig httpMultipartMode ( HttpMultipartMode httpMultipartMode ) { return new HttpClientConfig ( httpClientFactory , httpClientParams , httpMultipartMode , shouldReuseHttpClientInstance , httpClient , true ) ; }

Specify the HTTP Multipart mode when sending multi-part data.

@param httpMultipartMode The multi-part mode to set.
@return An updated HttpClientConfig

Specify the HTTP Multipart mode when sending multi - part data .


public <T> T get(String path) {
        final JSONAssertion jsonAssertion = createJsonAssertion(path, params);
        final Object json = jsonParser.parseWith(createConfigurableJsonSlurper());
        return (T) jsonAssertion.getResult(json, null);
    }

public < T > T get ( String path ) { final JSONAssertion jsonAssertion = createJsonAssertion ( path , params ) ; final Object json = jsonParser . parseWith ( createConfigurableJsonSlurper ( ) ) ; return ( T ) jsonAssertion . getResult ( json , null ) ; }

Get the result of an Object path expression as a boolean.

@param path The Object path.
@return The object matching the Object path. This may be any primitive type, a List or a Map.  A {@link java.lang.ClassCastException} will be thrown if the object
cannot be casted to the expected type.

Get the result of an Object path expression as a boolean .


public int getInt(String path) {
        //The type returned from Groovy depends on the input, so we need to handle different numerical types.
        Object value = get(path);
        if (value instanceof Integer) {
            return (Integer) value;
        } else if (value instanceof Short) {
            return ((Short) value).intValue();
        } else if (value instanceof Long) {
            return ((Long) value).intValue();
        } else {
            return ObjectConverter.convertObjectTo(value, Integer.class);
        }
    }

Get the result of an Object path expression as an int.

@param path The Object path.
@return The int matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object
cannot be casted to the expected type.

Get the result of an Object path expression as an int .


public byte getByte(String path) {
        //The type returned from Groovy depends on the input, so we need to handle different numerical types.
        Object value = get(path);
        if (value instanceof Byte) {
            return (Byte) value;
        } else if (value instanceof Long) {
            return ((Long) value).byteValue();
        } else if (value instanceof Integer) {
            return ((Integer) value).byteValue();
        } else {
            return ObjectConverter.convertObjectTo(value, Byte.class);
        }
    }

Get the result of an Object path expression as a byte.

@param path The Object path.
@return The object matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object
cannot be casted to the expected type.

Get the result of an Object path expression as a byte .


public short getShort(String path) {
        //The type returned from Groovy depends on the input, so we need to handle different numerical types.
        Object value = get(path);
        if (value instanceof Short) {
            return (Short) value;
        } else if (value instanceof Long) {
            return ((Long) value).shortValue();
        } else if (value instanceof Integer) {
            return ((Integer) value).shortValue();
        } else {
            return ObjectConverter.convertObjectTo(value, Short.class);
        }
    }

Get the result of an Object path expression as a short.

@param path The Object path.
@return The object matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object
cannot be casted to the expected type.

Get the result of an Object path expression as a short .


public float getFloat(String path) {
        final Object value = get(path);
        //Groovy will always return a Double for floating point values.
        if (value instanceof Double) {
            return ((Double) value).floatValue();
        } else {
            return ObjectConverter.convertObjectTo(value, Float.class);
        }
    }

Get the result of an Object path expression as a float.

@param path The Object path.
@return The object matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object
cannot be casted to the expected type.

Get the result of an Object path expression as a float .


public double getDouble(String path) {
        final Object value = get(path);
        if (value instanceof Double) {
            return (Double) value;
        }
        return ObjectConverter.convertObjectTo(value, Double.class);
    }

public double getDouble ( String path ) { final Object value = get ( path ) ; if ( value instanceof Double ) { return ( Double ) value ; } return ObjectConverter . convertObjectTo ( value , Double . class ) ; }

Get the result of an Object path expression as a double.

@param path The Object path.
@return The object matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object
cannot be casted to the expected type.

Get the result of an Object path expression as a double .


public long getLong(String path) {
        //The type returned from Groovy depends on the input, so we need to handle different numerical types.
        Object value = get(path);
        if (value instanceof Long) {
            return (Long) value;
        } else if (value instanceof Short) {
            return ((Short) value).longValue();
        } else if (value instanceof Integer) {
            return ((Integer) value).longValue();
        } else {
            return ObjectConverter.convertObjectTo(value, Long.class);
        }
    }

Get the result of an Object path expression as a long.

@param path The Object path.
@return The object matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object
cannot be casted to the expected type.

Get the result of an Object path expression as a long .


public <T> List<T> getList(String path, Class<T> genericType) {
        if (genericType == null) {
            throw new IllegalArgumentException("Generic type cannot be null");
        }
        final List<T> original = get(path);
        final List<T> newList = new LinkedList<T>();
        if (original != null) {
            for (T t : original) {
                T e;
                if (t instanceof Map && !genericType.isAssignableFrom(Map.class)) {
                    // TODO Avoid double parsing
                    String str = objectToString(t);
                    //noinspection unchecked
                    e = (T) jsonStringToObject(str, genericType);
                } else {
                    e = ObjectConverter.convertObjectTo(t, genericType);
                }
                newList.add(e);
            }
        }
        return Collections.unmodifiableList(newList);
    }

public
<
T
>
List
<
T
>
getList
(
String
path
,
Class
<
T
>
genericType
)
{
if
(
genericType
==
)
{
throw
new
IllegalArgumentException
(
"Generic type cannot be null"
)
;
}
final
List
<
T
>
original
=
get
(
path
)
;
final
List
<
T
>
newList
=
new
LinkedList
<
T
>
(
)
;
if
(
original
!=
)
{
for
(
T
t
:
original
)
{
T
e
;
if
(
t
instanceof
Map
&&
!
genericType
.
isAssignableFrom
(
Map
.
class
)
)
{
// TODO Avoid double parsing
String
str
=
objectToString
(
t
)
;
//noinspection unchecked
e
=
(
T
)
jsonStringToObject
(
str
,
genericType
)
;
}
else
{
e
=
ObjectConverter
.
convertObjectTo
(
t
,
genericType
)
;
}
newList
.
add
(
e
)
;
}
}
return
Collections
.
unmodifiableList
(
newList
)
;
}

Get the result of an Object path expression as a list.

@param path        The Object path.
@param genericType The generic list type
@param <T>         The type
@return The object matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object
cannot be casted to the expected type.

Get the result of an Object path expression as a list .


public <K, V> Map<K, V> getMap(String path) {
        return get(path);
    }

public < K , V > Map < K , V > getMap ( String path ) { return get ( path ) ; }

Get the result of an Object path expression as a map.

@param path The Object path.
@param <K>  The type of the expected key
@param <V>  The type of the expected value
@return The map matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object
cannot be casted to the expected type.

Get the result of an Object path expression as a map .


public <T> T getObject(String path, Class<T> objectType) {
        Object object = getFromPath(path, false);
        return getObjectAsType(object, objectType);
    }

public < T > T getObject ( String path , Class < T > objectType ) { Object object = getFromPath ( path , false ) ; return getObjectAsType ( object , objectType ) ; }

Get an XML document as a Java Object.

@param objectType The type of the java object.
@param <T>        The type of the java object
@return A Java object representation of the XML document


public RequestSpecBuilder setBody(Object object, ObjectMapper mapper) {
        spec.body(object, mapper);
        return this;
    }

public RequestSpecBuilder setBody ( Object object , ObjectMapper mapper ) { spec . body ( object , mapper ) ; return this ; }

Specify an Object request content that will automatically be serialized to JSON or XML and sent with the request using a specific object mapper.
This works for the POST, PATCH and PUT methods only. Trying to do this for the other http methods will cause an exception to be thrown.

@param object The object to serialize and send with the request
@param mapper The object mapper
@return The request specification

Specify an Object request content that will automatically be serialized to JSON or XML and sent with the request using a specific object mapper . This works for the POST PATCH and PUT methods only . Trying to do this for the other http methods will cause an exception to be thrown .