public static MockMvcAuthenticationScheme principalWithCredentials(final Object principal, final Object credentials, final String... authorities) {
        return new MockMvcAuthenticationScheme() {
            public void authenticate(MockMvcRequestSpecification mockMvcRequestSpecification) {
                mockMvcRequestSpecification.auth().principalWithCredentials(principal, credentials, authorities);
            }
        };
    }
public static MockMvcAuthenticationScheme principalWithCredentials(final Object principal, final Object credentials, final String... authorities) {
        return new MockMvcAuthenticationScheme() {
            public void authenticate(MockMvcRequestSpecification mockMvcRequestSpecification) {
                mockMvcRequestSpecification.auth().principalWithCredentials(principal, credentials, authorities);
            }
        };
    }
public static MockMvcAuthenticationScheme principalWithCredentials ( final Object principal , final Object credentials , final String ... authorities ) { return new MockMvcAuthenticationScheme ( ) { public void authenticate ( MockMvcRequestSpecification mockMvcRequestSpecification ) { mockMvcRequestSpecification . auth ( ) . principalWithCredentials ( principal , credentials , authorities ) ; } } ; }
Authenticate using the given principal and credentials. Used as:
<pre>
RestAssured.authentication = principalWithCredentials(myPrincipal, myCredentials);
</pre>
or in a {@link MockMvcRequestSpecBuilder}:
<pre>
MockMvcRequestSpecification req = new MockMvcRequestSpecBuilder().setAuth(principalWithCredentials(myPrincipal, myCredentials)). ..
</pre>

@param principal   The principal to use.
@param credentials The credentials to use
@param authorities Optional list of authorities
@return A {@link MockMvcAuthenticationScheme} instance.
@see MockMvcAuthenticationSpecification#principalWithCredentials(Object, Object, String...)
Authenticate using the given principal and credentials . Used as : <pre > RestAssured . authentication = principalWithCredentials ( myPrincipal myCredentials ) ; < / pre > or in a { @link MockMvcRequestSpecBuilder } : <pre > MockMvcRequestSpecification req = new MockMvcRequestSpecBuilder () . setAuth ( principalWithCredentials ( myPrincipal myCredentials )) . .. < / pre >