更新:清理并直接指出问题和解决方案.
问题:
Docker-tomcat已正确安装并运行,但Manager App中的403 Access错误除外.我的docker tomcat似乎也找不到我的tomcat-users.xml配置.
解
[文件]:
Dockerfile
FROM tomcat:8.5.11
MAINTAINER Borgy Manotoy <borgymanotoy@ujeaze.com>
# Update Apt and then install Nano editor (RUN can be removed)
RUN apt-get update && apt-get install -y \
nano \
&& mkdir -p /usr/local/tomcat/conf
# Copy configurations (Tomcat users, Manager app)
COPY tomcat-users.xml /usr/local/tomcat/conf/
COPY context.xml /usr/local/tomcat/webapps/manager/META-INF/
Run Code Online (Sandbox Code Playgroud)
Tomcat用户配置(conf/tomcat-users.xml)
<tomcat-users xmlns="http://tomcat.apache.org/xml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
version="1.0">
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<user username="admin" password="password" roles="manager-gui,manager-script" />
</tomcat-users>
Run Code Online (Sandbox Code Playgroud)
应用程序上下文(webapps/manager/META-INF/context.xml)
<?xml version="1.0" encoding="UTF-8"?> …Run Code Online (Sandbox Code Playgroud) 我想比较 joda LocalDate 对象并检查/比较日期是否在两个日期之间。
例子:
LocalDate date = new LocalDate(2019, 2, 2);
LocalDate end = new LocalDate();
LocalDate start = end.minusYears(1);
Run Code Online (Sandbox Code Playgroud)
现在,我想检查是否date在start和 之间end。gte另外,我希望它像and lte... 之前或等于并且之后或等于一样工作。
我只能找到isBefore, isAfter, isEqual... 但找不到isBeforeOrEqual和isAfterOrEqual。
有没有可以与 joda LocalDate 一起使用的实用程序?有什么有效的方法可以解决这个问题吗?
我想检查一下isBefore,与那时isEqual一样......但我认为它很长或效率低下。isAfterisEqual
private boolean isBeforeOrEqual(LocalDate date, LocalDate compareToDate) {
if (date == null || compareToDate == null) {
return false;
}
return compareToDate.isBefore(date) || compareToDate.isEqual(date); …Run Code Online (Sandbox Code Playgroud) 如果标题不清楚,我很抱歉,让我通过给出示例代码来澄清:
更新配置文件Dto
public class UpdateProfileDto {
@NotEmpty
private String firstName;
@NotEmpty
private String lastName;
@Size(max = 20)
private String currentPassword;
@Size(max = 20)
private String newPassword;
@Size(max = 20)
private String confirmNewPassword;
// getters and setters
}
Run Code Online (Sandbox Code Playgroud)
编码映射
@Qualifier
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.CLASS)
public @interface EncodedMapping {
}
Run Code Online (Sandbox Code Playgroud)
密码编码器映射器
public class PasswordEncoderMapper {
protected final PasswordEncoder passwordEncoder;
public PasswordEncoderMapper(PasswordEncoder passwordEncoder) {
this.passwordEncoder = passwordEncoder;
}
@EncodedMapping
public String encode(String value) {
return passwordEncoder.encode(value);
}
}
Run Code Online (Sandbox Code Playgroud)
用户映射器
@Mapper(config = MapperConfig.class, componentModel = "spring", …Run Code Online (Sandbox Code Playgroud) 使用XPath,如何检查节点或标签值是否为空?
鉴于示例 XML:
问题(以下需要 XPath 表达式):
1. 我将如何检查 ExceptionMessage1 是否为空。
2. 我将如何检查 ExceptionMessage2 @nil == true?
3.怎么样,如果会有ExceptionMessage3,它可以是:
一。包含异常消息
b. 没有消息,@nil="true"(组合 ExceptionMessage1 和 ExceptionMessage2 行为)
<Envelope>
<Body>
<SellResponse>
<SellResult>
<ExceptionMessage1>JourneyManager.SellJourney(segment): Segment already booked under different class of service</ExceptionMessage1>
<ExceptionMessage2 nil="true"/>
<NSProcessTime>0</NSProcessTime>
<ProcessTime>0</ProcessTime>
<Booking nil="true"/>
<Success nil="true"/>
<Warning nil="true"/>
<Error nil="true"/>
<OtherServiceInformations nil="true"/>
</SellResult>
</SellResponse>
</Body>
</Envelope>
Run Code Online (Sandbox Code Playgroud)
TIA
我需要创建一个通过curl 调用我的登录API 的shell 脚本。该脚本应该能够存储和处理来自curl api 调用的响应。
myscript.sh
#!/bin/bash
echo "Extract bearer token from curl calling login api"
echo
# Check cURL command if available (required), abort if does not exists
type curl >/dev/null 2>&1 || { echo >&2 "Required curl but it's not installed. Aborting."; exit 1; }
echo
PAYLOAD='{"email": "dummy-user@acme.com", "password": "secret"}'
curl -s --request POST -H "Content-Type:application/json" http://acme.com/api/authentications/login --data "${PAYLOAD}"
Run Code Online (Sandbox Code Playgroud)
我在给定脚本中的问题是:
示例登录 API 响应:
{
"user": {
"id": 123,
"token": "<GENERATED-TOKEN-HERE>",
"email": "dummy-user@acme.com",
"refreshToken": …Run Code Online (Sandbox Code Playgroud) 问题: 我想从authenticate.getName()中获取/提取用户名/电子邮件...如果可能,不要使用解析字符串.
authentication.getName()或principal.getName()值:
[username]: org.springframework.security.core.userdetails.User@21463e7a: Username: butitoy@iyotbihagay.com; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Not granted any authorities
Run Code Online (Sandbox Code Playgroud)
在这个例子中,我只想获得Username的值,即butitoy@iyotbihagay.com
解:
由于我只想获得用户名/电子邮件(butitoy@iyotbihagay.com),并且它返回了整个主要内容/文本(上图),我将主题中设置的值从主要值...替换为电子邮件价值..它现在有效.
@Override
protected void successfulAuthentication(HttpServletRequest req,
HttpServletResponse res,
FilterChain chain,
Authentication auth) throws IOException, ServletException {
String email = auth.getName();
String principal = auth.getPrincipal().toString();
Date expiration = new Date(System.currentTimeMillis() + SecurityConstants.EXPIRATION_TIME);
String token = Jwts.builder()
.setSubject(email) //from principal to email
.setExpiration(expiration)
.signWith(SignatureAlgorithm.HS512, SecurityConstants.SECRET.getBytes())
.compact();
AuthenticatedUser loginUser = new AuthenticatedUser(email);
loginUser.setToken(token);
String jsonUser = Util.objectToJsonResponseAsString(loginUser, "user");
res.addHeader(SecurityConstants.HEADER_STRING, SecurityConstants.TOKEN_PREFIX …Run Code Online (Sandbox Code Playgroud) 我需要使用ES REST高级客户端(Java)创建类似高级搜索的内容。
首先,我有一个搜索关键字,可以搜索所有字段。
我用QueryStringQueryBuilder这个。
SearchSourceBuilder ticketInfoSourceBuilder = new SearchSourceBuilder();
ticketInfoSourceBuilder.from(pageable.getOffset());
ticketInfoSourceBuilder.size(pageable.getPageSize());
ticketInfoSourceBuilder.sort(new FieldSortBuilder(sortField).order(sortOrder));
ticketInfoSourceBuilder.query(QueryBuilders.queryStringQuery("ABC1234"));
Run Code Online (Sandbox Code Playgroud)
现在,我需要使用添加更多过滤器TermsQueryBuilder。
是否可以将两个查询构建器结合在一起?
我想添加以下过滤器:
"terms" : { "ticket.inquiryType" : ["INQTYP01", "INQTYP06"]}
"terms" : { "ticket.status" : ["NEW", "CLOSED"]}
"terms" : { "ticket.ownership" : ["OWNED", "OTHER_OWNER"]}
Run Code Online (Sandbox Code Playgroud)
是否可以将两个查询构建器结合起来以实现类似高级搜索的功能?
谢谢!