server {
listen jira.orgname.local:80;
server_name jira.orgname.local;
location / {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://jira.orgname.local:8080/;
client_max_body_size 1000M;
}
}
Есть Java веб-приложение, гвоздями прибитое к Windows (работает на локальном Jetty) и доступное по адресу localhost:8080/app
<PC-NAME>:8080/app
, где PC-NAME - это имя вашего компьютера ?Caused by: org.h2.jdbc.JdbcSQLException: Таблица "LEGAL_ENTITY" не найдена
Table "LEGAL_ENTITY" not found; SQL statement:
select legalentit0_.id as id1_2_, legalentit0_.inn as inn2_2_, legalentit0_.name as name3_2_, legalentit0_.version as version4_2_ from legal_entity legalentit0_
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/j_spring_security_logout</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/security"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-4.0.xsd">
<beans:bean id="tokenPersistRepo"
class="org.springframework.security.web.authentication.rememberme.JdbcTokenRepositoryImpl">
<beans:property name="dataSource" ref="dataSource"/>
</beans:bean>
<beans:bean id="nonAjaxRequestMatcher" class="org.whatever.NonAjaxRequestMatcher"/>
<beans:bean id="loginUrlAuthenticationEntryPoint"
class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint">
<beans:constructor-arg value="/login"/>
</beans:bean>
<beans:bean id="ajaxAuthenticationEntryPoint"
class="org.springframework.security.web.authentication.HttpStatusEntryPoint">
<beans:constructor-arg name="httpStatus"
value="#{T(org.springframework.http.HttpStatus).UNAUTHORIZED}"/>
</beans:bean>
<beans:bean id="authenticationRequestCache"
class="org.springframework.security.web.savedrequest.HttpSessionRequestCache">
<beans:property name="requestMatcher" ref="nonAjaxRequestMatcher"/>
</beans:bean>
<beans:bean id="authenticationEntryPoint"
class="org.springframework.security.web.authentication.DelegatingAuthenticationEntryPoint">
<beans:constructor-arg>
<beans:map>
<beans:entry key-ref="nonAjaxRequestMatcher" value-ref="loginUrlAuthenticationEntryPoint"/>
</beans:map>
</beans:constructor-arg>
<beans:property name="defaultEntryPoint" ref="ajaxAuthenticationEntryPoint"/>
</beans:bean>
<http entry-point-ref="authenticationEntryPoint" use-expressions="true">
<request-cache ref="authenticationRequestCache"/>
<headers>
<frame-options disabled="true"/>
</headers>
<intercept-url pattern="/backend/roles/**" access="hasAnyRole('ROLE_ADMINISTRATOR')"/>
<intercept-url pattern="/backend/**" access="hasAnyRole('ROLE_ADMINISTRATOR', 'ROLE_SYS')"/>
<intercept-url pattern="/registries/**" access="hasAnyRole('ROLE_ADMINISTRATOR', 'ROLE_SYS', 'ROLE_REGISTRY')"/>
<intercept-url pattern="/registries" access="hasAnyRole('ROLE_ADMINISTRATOR', 'ROLE_SYS', 'ROLE_REGISTRY')"/>
<intercept-url pattern="/login/**" access="permitAll"/>
<intercept-url pattern="/logout/**" access="permitAll"/>
<intercept-url pattern="/resources/**" access="permitAll"/>
<intercept-url pattern="/bundles/**" access="permitAll"/>
<intercept-url pattern="/jawr/**" access="permitAll"/>
<intercept-url pattern="/error/**" access="permitAll"/>
<access-denied-handler error-page="/403"/>
<intercept-url pattern="/**" access="isAuthenticated()"/>
<form-login login-page="/login" default-target-url="/"
authentication-failure-url="/login?error" username-parameter="username"
password-parameter="password"/>
<logout logout-success-url="/" logout-url="/j_spring_security_logout" delete-cookies="JSESSIONID,remember-me"/>
<remember-me
key="${app.remember-me-key}"
remember-me-parameter="remember-me"
remember-me-cookie="remember-me"
token-validity-seconds="86400"
token-repository-ref="tokenPersistRepo"/>
<csrf/>
</http>
<authentication-manager alias="authenticationManager">
<authentication-provider user-service-ref="usersManager">
<password-encoder hash="bcrypt"/>
</authentication-provider>
</authentication-manager>
</beans:beans>
@RequestMapping(value = {"/url/to/profileAction/{id}"}, method = RequestMethod.GET)
public ModelAndView profileAction(@PathVariable("id") Long id) {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("profile");
UserDTO data = getUserDTOsService().getById(id);
if (data != null) {
modelAndView.getModel().put("data", data);
return modelAndView;
}
return "redirect:/";/*ну или бросить исключение, что нет пользователя*/
}
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9.7</version>
</dependency>
// check if user is login
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
if ((!(auth instanceof AnonymousAuthenticationToken)) && auth != null) {
UserDetails userDetail = (UserDetails) auth.getPrincipal();
if (userDetail != null) {
model.addObject("username", userDetail.getUsername());
} else {
model.addObject("username", "");
}
}
,<authentication-manager alias="authenticationManager">
<authentication-provider user-service-ref="usersManager">
<password-encoder hash="bcrypt"/>
</authentication-provider>
</authentication-manager>
<bean id="usersManager" class="org.whatever.impl.UsersServiceImpl">
<property name="usersDAO" ref="usersDAO"/>
<property name="languageDao" ref="languagesDAO"/>
<property name="roleDAO" ref="roleDAO"/>
<property name="usersViewDAO" ref="usersViewDAO"/>
</bean>
package org.whatever.impl;
/*импорты убрал */
/* интерфейс UsersService наследует org.springframework.security.core.userdetails.UserDetailsService */
public class UsersServiceImpl extends ServiceBase implements UsersService {
@Autowired
private UsersDAO usersDAO;
public void setUsersViewDAO(UsersViewDAO usersViewDAO) {
this.usersViewDAO = usersViewDAO;
}
public UsersDAO getUsersDAO() {
return usersDAO;
}
/*сократил код*/
/**
* Детали по пользователю, полученному из базы
*/
@Override
@Transactional(readOnly = true)
public UserDetails loadUserByUsername(String login) throws UsernameNotFoundException {
User userFromDb = this.getUsersDAO().getUserByLogin(login);
if (userFromDb != null) {
return new org.whatever.UserView(userFromDb); /*применяет org.springframework.security.core.userdetails.UserDetails*/
}
String result = new Formatter().format("User with login %s not found", login).toString();
throw new UsernameNotFoundException(result);
}
}
javax.servlet.ServletException: Circular view path [greeting.html]: would dispatch back to the current handler URL [/greeting.html] again. Check your ViewResolver setup!
return "greeting.html";
на return "greeting";
public class Class1<T> {
public void Run(T another){
//TODO Do something with another
}
}
public class Class2<T extends Synker> extends Class1<T> {
}
Class2<Synker> cl = new Class2<>();
cl.Run(new Synker());