小编Ang*_*chs的帖子

如何使Spring Security接受JSON而不是表单参数?

我正在尝试更改JHipster,因此它使用JSON对象进行身份验证而不是表单参数.我已经成功地为其JWT认证机制做了这项工作.现在我想为其他身份验证选项做这件事.

是否有一种简单的方法可以更改Spring Security的默认安全配置以允许此操作?以下是JHipster现在使用的内容:

.and()
    .rememberMe()
    .rememberMeServices(rememberMeServices)
    .rememberMeParameter("remember-me")
    .key(env.getProperty("jhipster.security.rememberme.key"))
.and()
    .formLogin()
    .loginProcessingUrl("/api/authentication")
    .successHandler(ajaxAuthenticationSuccessHandler)
    .failureHandler(ajaxAuthenticationFailureHandler)
    .usernameParameter("j_username")
    .passwordParameter("j_password")
    .permitAll()
Run Code Online (Sandbox Code Playgroud)

我想发送以下作为JSON而不是表单参数:

{username: "admin", password: "admin", rememberMe: true}
Run Code Online (Sandbox Code Playgroud)

java spring-security spring-boot jhipster

7
推荐指数
1
解决办法
2615
查看次数

从不同的地方调用时,不能在方法参数中使用List <Future <?>>

在我的代码中,我有多个实例,List<Future<something>>我希望有一个方法来处理等待它们完成.但我得到一个编译器异常告诉我actual argument List<Future<Boolean>> cannot be converted to List<Future<?>>.

这是方法头:

public void waitForIt(<List<Future<?>> params)
Run Code Online (Sandbox Code Playgroud)

这就是它的名称:

...
List<Future<Boolean>> actions = new ArrayList<Future<Boolean>>();
waitForIt(actions); <-- compiler error here
...
Run Code Online (Sandbox Code Playgroud)

我需要这个List<Future<Map<String, String>>>和其他几个人一起工作.

java generics list

6
推荐指数
1
解决办法
391
查看次数

如何更改我的Web方法调用的http版本以停止505错误?

我需要从服务提供商处获取一些数据,并将我们的.net应用程序配置为指向其托管的Web服务以获取数据.使用下面的代码,当调用web方法时(ws.DoTransfer)我得到以下错误...

    private void DoTransferLocal()
    {
            Version version = new Version();
            string error = string.Empty;
            try
            {
                    RemoteService ws = new RemoteService();
                    ServicePoint spm = ServicePointManager.FindServicePoint(new Uri(ws.Url));
                    spm.Expect100Continue = true;
                    version = spm.ProtocolVersion;
                    ws.Credentials = credentials;
                    ws.PreAuthenticate = true;
                    RemoteResult result = ws.DoTransfer();
                    MessageBox.Show("Result = " + result.transferStatus);
            }
            catch (Exception ex)
            {
                    error = ex.Message;
            }
            finally
            {
                    MessageBox.Show(version.ToString() + Environment.NewLine + error);
            }
    }
Run Code Online (Sandbox Code Playgroud)

错误:

HTTP状态505请求失败:HTTP版本不受支持.

我被告知HTTP的版本需要为1.0,但我的版本是1.1

我已经阅读了几篇有关此内容的谷歌帖子,并且已经看到了覆盖此GetWebRequest方法的建议...

    protected override System.Net.WebRequest GetWebRequest(Uri uri)
    {   
            System.Net.HttpWebRequest …
Run Code Online (Sandbox Code Playgroud)

.net web-services http version http-status-code-505

5
推荐指数
2
解决办法
8188
查看次数

OOo:UNO(Java)TrackedChanges:隐藏文档时如何接受(或隐藏)Tracked Changes?

我的问题:我编写了一个需要读取 .doc 和 .odt 的自动化系统,对其执行一些操作并再次将其导出为 pdf。

目前这对我需要的一切都很好,我可以解决所有问题,直到这个问题:

如果用户提供记录了更改(红线)的文档,我需要自动接受所有更改或隐藏它们。

只要 OOo 显示在屏幕上,我就可以用下面的代码解决这个问题。当我隐藏启动它时,我的调用根本不执行任何操作。

所以,这是我目前所做的:

    // DO NOT try to cast this to Desktop as com.sun.star.frame.Desktop is NOT a valid class!
    // keep it as Object and cast it to XDesktop later (via queryInterface)
    Object desktop = xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", xContext);
    XMultiServiceFactory xFactory = (XMultiServiceFactory) UnoRuntime.queryInterface(
        XMultiServiceFactory.class, xMCF);
    // what goes for desktop above is valid for DispatchHelper as well.
    Object dispatchHelper = xFactory.createInstance("com.sun.star.frame.DispatchHelper");

    // the DispatchHelper is the class that handles the interaction with …
Run Code Online (Sandbox Code Playgroud)

java openoffice.org dispatcher uno

5
推荐指数
1
解决办法
1338
查看次数

java.util.Date的替代方案

目前我正在使用已弃用的set方法java.util.Date.由于我想远离它,有什么替代方案,它们有什么优势?

我需要Date设置一个今天,午夜的时间HQL查询,选择今天发生的所有事情.

目前我使用:

Date startingDate = new Date();
startingDate.setHours(0);
startingDate.setMinutes(0);
startingDate.setSeconds(0);
Run Code Online (Sandbox Code Playgroud)

java java.util.date

5
推荐指数
1
解决办法
9534
查看次数

Shingle过滤器工厂startOffset必须是非负的,endOffset必须是> = startOffset

我正在使用lucene版本4.4与这些分析仪:

worddelimeter, patternFilter, synonyms, lowercase,
stopwords, kStemFilter, shingle, trimfilter.
Run Code Online (Sandbox Code Playgroud)

分析仪按我使用它们的顺序列出.当我尝试添加文档时,我得到以下异常:

startOffset must be non-negative, and endOffset must be >= startOffset,
            startOffset=37571,endOffset=37569
Run Code Online (Sandbox Code Playgroud)

仅对特定文件发生此异常.但是当我改变顺序并放置stopwords过滤器之前worddelimeter它工作正常.但这不是正确的做法!

为什么会这样?在什么情况下过滤器会以某种方式改变数据以导致异常?

java lucene solr

5
推荐指数
1
解决办法
1080
查看次数

不可解析的父POM

我正在尝试通过遵循http://www.mulesoft.org/documentation/display/current/Creating+a+Connector+Project教程为m子开发自定义连接器。如本教程所示,我通过执行以下命令通过命令行创建项目

mvn archetype:generate
    -DarchetypeGroupId=org.mule.tools.devkit
    -DarchetypeArtifactId=mule-devkit-archetype-cloud-connector
    -DarchetypeVersion=3.4.3
    -DgroupId=org.hello
    -DartifactId=hello-connector
    -Dversion=1.0-SNAPSHOT
    -DmuleConnectorName=Hello
    -Dpackage=org.hello
    -DarchetypeRepository=http://repository.mulesoft.org/releases
Run Code Online (Sandbox Code Playgroud)

将项目导入到Mule Studio后,我pom.xml在父标记附近的文件中收到以下错误。

Project build error: Non-resolvable parent POM:
        Could not transfer artifact
        org.mule.tools.devkit:mule-devkit-parent:pom:3.4.3 from/to
        mulesoft-releases (http://repository.mulesoft.org/releases/):
        connection timed out to
        http://repository.mulesoft.org/releases/org/mule/tools/devkit/mule-devkit-parent/3.4.3/mule-devkit-parent-3.4.3.pom
        and 'parent.relativePath' points at wrong local POM.
Run Code Online (Sandbox Code Playgroud)

这是我的pom.xml档案。

<?xml version="1.0" encoding="UTF-8"?>
project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.hello</groupId>
    <artifactId>hello-connector</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>mule-module</packaging>
    <name>Hello Connector</name>

    <parent>
        <groupId>org.mule.tools.devkit</groupId>
        <artifactId>mule-devkit-parent</artifactId>
        <version>3.4.3</version>
    </parent>

    <properties>
        <junit.version>4.9</junit.version>
        <mockito.version>1.8.2</mockito.version>
        <jdk.version>1.7</jdk.version>
        <category>Community</category>
        <licensePath>LICENSE.md</licensePath>
        <devkit.studio.package.skip>false</devkit.studio.package.skip>
    </properties>

    <scm>
        <connection>scm:git:git://github.com:mulesoft/hello-connector.git</connection>
        <developerConnection>scm:git:git@github.com:mulesoft/hello-connector.git</developerConnection>
        <url>http://github.com/mulesoft/hello-connector</url>
    </scm> …
Run Code Online (Sandbox Code Playgroud)

mule pom.xml maven parent-pom mule-studio

5
推荐指数
1
解决办法
2万
查看次数

crontab是否接受命令行参数?

我写了一段代码,将.trc文件从源指令移到备份指令。现在,我已将时间(更旧了多少时间),源路径和备份路径用作此文件的命令行参数。现在,当我从中调用脚本时sh,它可以正常工作。但是在crontab中它不起作用,这让我想知道crontab是否允许传递命令行参数。我的sh命令是:

sh trace_bkp.sh 2 /home/adhikarisubir/test/basic_unix /home/adhikarisubir/test_bkp
Run Code Online (Sandbox Code Playgroud)

其中2定义了2分钟的旧文件,下一个是资源路径,最后一个是目标路径。我在crontab中设置为:

*/5 * * * * sh /home/adhikarisubir/test/basic_unix/trace_bkp.sh 2 /home/adhikarisubir/test/basic_unix /home/adhikarisubir/test_bkp
Run Code Online (Sandbox Code Playgroud)

linux bash shell crontab

5
推荐指数
1
解决办法
2万
查看次数

如何结合 TABLE_PER_CLASS 和 GenerationType.IDENTITY

亲爱的未来读者:在完成Sannes 的回答和他提供的链接之后,我决定改用 Sequence。较新的 Hibernates 注意它也适用于 MySQL。


我有一个abstract类,其中包含我希望在所有实体中拥有的一些基本值(例如 ID、创建日期、创建用户等)。目前,我在为每个具体类拥有一张表并使其 id 工作的组合而苦苦挣扎。

似乎我可以为每个班级设置一个表,也可以在一个地方设置 ID,但不能同时设置两者。这对我来说似乎很奇怪而且不太可能,所以我想确保情况确实如此。

可能相关的版本:hibernate 5、mysql 5.5、java 1.8、spring 4.3。

@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@MappedSuperclass
public abstract class GeneralData implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(nullable = false)
    protected int id;
    protected String name;

    // getters, setters, constructors, etc.
}
Run Code Online (Sandbox Code Playgroud)

示例子类:

@Entity
public class ExampleClass extends GeneralData {
    // own values, constructors, getters, setters, etc.
}
Run Code Online (Sandbox Code Playgroud)

我得到的错误:

Cannot use identity column key generation with <union-subclass> mapping for: org.example.ExampleClass …
Run Code Online (Sandbox Code Playgroud)

java mysql spring persistence hibernate

5
推荐指数
1
解决办法
2055
查看次数

从服务器获得505响应

嗨,在我的android项目中我调用webservice并通过查询字符串参数发送get参数,现在问题是如果查询字符串参数值包含任何空格,那么我得到505错误

                    URL url = new URL(urlstring.trim());                        
                    urlConnection = (HttpURLConnection) url.openConnection();
                    int response = urlConnection.getResponseCode();
Run Code Online (Sandbox Code Playgroud)

我有一个疑问,如果我使用URLEncode(urlstring.trim(),"UTF-8"),我还需要更改我的网络服务代码?

java apache android http-status-code-505

3
推荐指数
1
解决办法
7631
查看次数