修改shiro拦截器问题

This commit is contained in:
limqhz
2021-08-27 14:30:55 +08:00
parent 2b44b16bd9
commit 87b6ae5480
3 changed files with 121 additions and 7 deletions

View File

@@ -14,6 +14,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Properties;
@@ -45,6 +46,11 @@ public class RequestSearchPlugin implements Interceptor {
@Override
public Object intercept(Invocation invocation) throws Throwable {
Method method = invocation.getMethod();
logger.info("method is " + method.getName());
if ("findByAccount".equals(method.getName())){
return invocation.proceed();
}
// 准备参数
Executor executor = (Executor) invocation.getTarget();
Object[] args = invocation.getArgs();

View File

@@ -14,8 +14,8 @@
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_HOME}/common-default.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${LOG_HOME}/common-default-%d{yyyy-MM-dd}.log
</fileNamePattern>
<fileNamePattern>${LOG_HOME}/common-default-%d{yyyy-MM-dd}.log</fileNamePattern>
<MaxHistory>30</MaxHistory>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
@@ -29,17 +29,46 @@
<level>ERROR</level>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${LOG_HOME}/common-error-%d{yyyy-MM-dd}.log
</fileNamePattern>
<fileNamePattern>${LOG_HOME}/common-error-%d{yyyy-MM-dd}.log</fileNamePattern>
<MaxHistory>30</MaxHistory>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
</encoder>
</appender>
<appender name="SERVICE"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_HOME}/service/service.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${LOG_HOME}/service/service-%d{yyyy-MM-dd}.log</fileNamePattern>
<MaxHistory>30</MaxHistory>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
</encoder>
</appender>
<loggers>
<logger name="org.springframework" additivity="false" level="info">
<appender-ref ref="STDOUT" />
<appender-ref ref="COMMON-DEFAULT" />
<appender-ref ref="COMMON-ERROR" />
</logger>
<logger name="com" additivity="false" level="info">
<appender-ref ref="STDOUT" />
<appender-ref ref="COMMON-DEFAULT" />
<appender-ref ref="COMMON-ERROR" />
</logger>
<logger name="com.ydd.oms.config.mybatis" additivity="false" level="info">
<appender-ref ref="SERVICE" />
</logger>
</loggers>
<!-- root -->
<root level="info">
<appender-ref ref="STDOUT" />
<appender-ref ref="SERVICE" />
<appender-ref ref="COMMON-DEFAULT" />
<appender-ref ref="COMMON-ERROR" />
</root>

View File

@@ -1,14 +1,93 @@
package com;
import java.net.URI;
import java.net.URISyntaxException;
import org.apache.http.NameValuePair;
import org.apache.http.client.CookieStore;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
public class TestWebSocket {
public static void main(String args[]) throws URISyntaxException {
public static void main(String args[]) throws IOException {
CookieStore cookieStore = new BasicCookieStore();
CloseableHttpClient httpClient = HttpClients.custom().setDefaultCookieStore(cookieStore).build();
HttpPost httpPost = new HttpPost("https://www.imstlife.com.cn/ClubManage/login.do?ret=");
httpPost.addHeader("Content-Type", "application/x-www-form-urlencoded");
RequestConfig requestConfig = RequestConfig.custom().setConnectionRequestTimeout(7000)
.setSocketTimeout(7000).setConnectTimeout(1000).build();
httpPost.setConfig(requestConfig);
List<NameValuePair> nameValuePairList = new ArrayList<>();
NameValuePair p1 = new BasicNameValuePair("username","上海弘娱管理员");
NameValuePair p2 = new BasicNameValuePair("password","12345678");
nameValuePairList.add(p1);
nameValuePairList.add(p2);
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairList, "UTF-8"));
CloseableHttpResponse response = httpClient.execute(httpPost);
String s = convertStreamToString(response.getEntity().getContent());
System.out.println(s);
HttpPost httpPost2 = new HttpPost("https://www.imstlife.com.cn/ClubManage/class/editClassInfo.do?aclModuleId=45240&buttonId=127290");
httpPost2.addHeader("Content-Type", "application/x-www-form-urlencoded");
httpPost2.setConfig(requestConfig);
List<NameValuePair> param = new ArrayList<>();
NameValuePair c1 = new BasicNameValuePair("id","8353");
NameValuePair c2 = new BasicNameValuePair("thumbnailUrl","");
NameValuePair c3 = new BasicNameValuePair("name","晚间及周末自由训练");
NameValuePair c4 = new BasicNameValuePair("classTypeId","3810");
NameValuePair c5 = new BasicNameValuePair("duration","120");
NameValuePair c6 = new BasicNameValuePair("difficulLevel","0");
NameValuePair c7 = new BasicNameValuePair("freeState","1");
NameValuePair c8 = new BasicNameValuePair("price","15");
NameValuePair c9 = new BasicNameValuePair("isSingle","1");
NameValuePair c10 = new BasicNameValuePair("wechatShow","1");
param.add(c1);
param.add(c2);
param.add(c3);
param.add(c4);
param.add(c5);
param.add(c6);
param.add(c7);
param.add(c8);
param.add(c9);
param.add(c10);
httpPost2.setEntity(new UrlEncodedFormEntity(param, "UTF-8"));
CloseableHttpResponse res = httpClient.execute(httpPost2);
String result = convertStreamToString(res.getEntity().getContent());
System.out.println(result);
}
public static String convertStreamToString(InputStream is) {
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line = null;
try {
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return sb.toString();
}
}