Search in sources :

Example 1 with NonNull

use of org.springframework.lang.NonNull in project joinfaces by joinfaces.

the class ViewScope method getViewRoot.

@NonNull
private UIViewRoot getViewRoot() {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    if (facesContext == null) {
        throw new IllegalStateException("No FacesContext found.");
    }
    UIViewRoot viewRoot = facesContext.getViewRoot();
    if (viewRoot == null) {
        throw new IllegalStateException("No ViewRoot found");
    }
    return viewRoot;
}
Also used : FacesContext(javax.faces.context.FacesContext) UIViewRoot(javax.faces.component.UIViewRoot) NonNull(org.springframework.lang.NonNull)

Example 2 with NonNull

use of org.springframework.lang.NonNull in project spring-security by spring-projects.

the class OAuth2AuthorizedClientArgumentResolver method resolveArgument.

@NonNull
@Override
public Object resolveArgument(MethodParameter parameter, @Nullable ModelAndViewContainer mavContainer, NativeWebRequest webRequest, @Nullable WebDataBinderFactory binderFactory) {
    String clientRegistrationId = this.resolveClientRegistrationId(parameter);
    if (StringUtils.isEmpty(clientRegistrationId)) {
        throw new IllegalArgumentException("Unable to resolve the Client Registration Identifier. " + "It must be provided via @RegisteredOAuth2AuthorizedClient(\"client1\") or " + "@RegisteredOAuth2AuthorizedClient(registrationId = \"client1\").");
    }
    Authentication principal = SecurityContextHolder.getContext().getAuthentication();
    if (principal == null) {
        principal = ANONYMOUS_AUTHENTICATION;
    }
    HttpServletRequest servletRequest = webRequest.getNativeRequest(HttpServletRequest.class);
    HttpServletResponse servletResponse = webRequest.getNativeResponse(HttpServletResponse.class);
    // @formatter:off
    OAuth2AuthorizeRequest authorizeRequest = OAuth2AuthorizeRequest.withClientRegistrationId(clientRegistrationId).principal(principal).attribute(HttpServletRequest.class.getName(), servletRequest).attribute(HttpServletResponse.class.getName(), servletResponse).build();
    // @formatter:on
    return this.authorizedClientManager.authorize(authorizeRequest);
}
Also used : HttpServletRequest(jakarta.servlet.http.HttpServletRequest) Authentication(org.springframework.security.core.Authentication) HttpServletResponse(jakarta.servlet.http.HttpServletResponse) OAuth2AuthorizeRequest(org.springframework.security.oauth2.client.OAuth2AuthorizeRequest) NonNull(org.springframework.lang.NonNull)

Example 3 with NonNull

use of org.springframework.lang.NonNull in project spring-framework by spring-projects.

the class ClientHttpConnectorTests method randomBody.

@NonNull
private Buffer randomBody(int size) {
    Buffer responseBody = new Buffer();
    Random rnd = new Random();
    for (int i = 0; i < size; i++) {
        byte[] bytes = new byte[BUF_SIZE];
        rnd.nextBytes(bytes);
        responseBody.write(bytes);
    }
    return responseBody;
}
Also used : Buffer(okio.Buffer) DataBuffer(org.springframework.core.io.buffer.DataBuffer) Random(java.util.Random) NonNull(org.springframework.lang.NonNull)

Example 4 with NonNull

use of org.springframework.lang.NonNull in project gwt-test-utils by gwt-test-utils.

the class GwtTestContextLoader method createBeanDefinitionReader.

@NonNull
@Override
protected BeanDefinitionReader createBeanDefinitionReader(GenericApplicationContext context) {
    XmlBeanDefinitionReader beanDefinitionReader = new XmlBeanDefinitionReader(context);
    beanDefinitionReader.setResourceLoader(new DefaultResourceLoader(GwtFactory.get().getClassLoader()));
    return beanDefinitionReader;
}
Also used : XmlBeanDefinitionReader(org.springframework.beans.factory.xml.XmlBeanDefinitionReader) DefaultResourceLoader(org.springframework.core.io.DefaultResourceLoader) NonNull(org.springframework.lang.NonNull)

Example 5 with NonNull

use of org.springframework.lang.NonNull in project spring-framework by spring-projects.

the class SqlScriptsTestExecutionListener method createDatabasePopulator.

@NonNull
private ResourceDatabasePopulator createDatabasePopulator(MergedSqlConfig mergedSqlConfig) {
    ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
    populator.setSqlScriptEncoding(mergedSqlConfig.getEncoding());
    populator.setSeparator(mergedSqlConfig.getSeparator());
    populator.setCommentPrefixes(mergedSqlConfig.getCommentPrefixes());
    populator.setBlockCommentStartDelimiter(mergedSqlConfig.getBlockCommentStartDelimiter());
    populator.setBlockCommentEndDelimiter(mergedSqlConfig.getBlockCommentEndDelimiter());
    populator.setContinueOnError(mergedSqlConfig.getErrorMode() == ErrorMode.CONTINUE_ON_ERROR);
    populator.setIgnoreFailedDrops(mergedSqlConfig.getErrorMode() == ErrorMode.IGNORE_FAILED_DROPS);
    return populator;
}
Also used : ResourceDatabasePopulator(org.springframework.jdbc.datasource.init.ResourceDatabasePopulator) NonNull(org.springframework.lang.NonNull)

Aggregations

NonNull (org.springframework.lang.NonNull)5 HttpServletRequest (jakarta.servlet.http.HttpServletRequest)1 HttpServletResponse (jakarta.servlet.http.HttpServletResponse)1 Random (java.util.Random)1 UIViewRoot (javax.faces.component.UIViewRoot)1 FacesContext (javax.faces.context.FacesContext)1 Buffer (okio.Buffer)1 XmlBeanDefinitionReader (org.springframework.beans.factory.xml.XmlBeanDefinitionReader)1 DefaultResourceLoader (org.springframework.core.io.DefaultResourceLoader)1 DataBuffer (org.springframework.core.io.buffer.DataBuffer)1 ResourceDatabasePopulator (org.springframework.jdbc.datasource.init.ResourceDatabasePopulator)1 Authentication (org.springframework.security.core.Authentication)1 OAuth2AuthorizeRequest (org.springframework.security.oauth2.client.OAuth2AuthorizeRequest)1