小编tgg*_*ggm的帖子

Dotnetopenauth使用自定义身份提供商进行单点登录

我正在尝试设置DotNetOpenAuth示例,以便为自定义提供程序提供可用的SSO解决方案.我正在使用OpenIdProviderMvc示例项目,看起来工作正常.

我的问题是设置"消费者",在这种情况下是OpenIdRelyingPartyMvc示例项目,我无法将其配置为使用OpenIdProvider.

我试图在消费者的web.config上设置一个端点,如下所示:

<trustedProviders rejectAssertionsFromUntrustedProviders="true">
    <add endpoint="http://localhost:4864/OpenID/Provider" />
</trustedProviders>
Run Code Online (Sandbox Code Playgroud)

但我得到的是"找不到OpenID端点".错误(实际上,我不太确定在OpenID框上放什么......)

该项目几乎没有记录.有人能指出我正确的方向吗?

至少让供应商和消费者互相工作和交谈?

asp.net-mvc dotnetopenauth asp.net-mvc-4

12
推荐指数
1
解决办法
5790
查看次数

实体框架:跨不同的DbContexts共享实体

我正在使用EF6开发一个插件应用程序,代码优先.

我有一个主要的上下文与一个名为的实体User:

public class MainDataContext : DbContext
{
    public MainDataContext(): base("MainDataContextCS") {}
    public DbSet<User> Users { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

然后是PluginX的另一个上下文,在另一个引用基类的项目上:

public class PluginDataContext : DbContext
{
    public PluginDataContext () : base("MainDataContextCS") {
    }

    protected override void OnModelCreating(DbModelBuilder modelBuilder) {
        modelBuilder.HasDefaultSchema("PluginX");
        base.OnModelCreating(modelBuilder);
    }

    public DbSet<Booking> Bookings { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

这可以在同一个数据库(相同的连接字符串)上整齐地创建PluginX.Bookings表.

这里的问题是Booking实体包含对实体的引用User:

public class Booking
{
    public int Id { get; set;}
    public virtual User CreationUser { get; set;}
    public BookingStatus …
Run Code Online (Sandbox Code Playgroud)

entity-framework ef-code-first ef-migrations entity-framework-6

10
推荐指数
1
解决办法
6017
查看次数

访问spring-mvc中的当前模型

我正在学习从asp.net MVC传入的Spring-MVC 4,我正在寻找一种方法将数据传递给View,而不必在每次调用中声明Model Atrribute.

例如,现在我有了这个.

public class BaseController {
    public void AddMessage(Model model, String m) {
        Model.addAttribute("msg", m);
    }
}

public class PersonController extends BaseController{
        @RequestMapping("details/{Id}")
        public String details(@PathVariable int Id, Model model) {
             Person p = service.LoadById(Id);

             if(p == null) {
                AddMessage(model, "Record not found...");
             } else {
                model.addAttribute("bean", q);
             }

             return "person/details";
         }
}
Run Code Online (Sandbox Code Playgroud)

但我真正想要的是有一种方法来访问我的基本控制器方法中的Model实例,而不必将其作为参数传递.类似于asp.net MVC中ViewData或TempData的用法.

是否可以以这种方式将数据传递给视图?

谢谢

spring-mvc

9
推荐指数
1
解决办法
1752
查看次数

客户端和服务器上都有证书的WCF(消息安全性和wsHttpBinding)

我正在尝试在客户端和服务器上使用证书身份验证设置WCF服务.我正在经历地狱,循环遍历所有可能的错误消息.

这里的最终目标是用证书对双方进行身份验证.我会为每个客户发出一份特定的证书,希望能让我分开.

到目前为止,我有以下配置文件:

服务器配置文件

<configuration>
    <system.serviceModel>
        <services>
            <service name="ServiceApiImplementation" behaviorConfiguration="myBehaviour">
                <host>
                    <baseAddresses><add baseAddress="http://localhost:9110/MyService"/></baseAddresses>
                </host>
                <endpoint address="" binding="wsHttpBinding" contract="IServiceAPI" bindingName="SOAP12Binding">
                    <identity>
                        <certificateReference findValue="ServerCertificate" storeName="My" storeLocation="LocalMachine" x509FindType="FindBySubjectName"/>
                    </identity>
                </endpoint>
            </service>
        </services>
        <bindings>
            <wsHttpBinding>
                <binding name="SOAP12Binding" receiveTimeout="00:02:00" closeTimeout="00:01:00" openTimeout="00:01:00" sendTimeout="00:01:00">
                    <security mode="Message">
                        <message clientCredentialType="Certificate" negotiateServiceCredential="false" establishSecurityContext="false" />
                    </security>
                </binding>
            </wsHttpBinding>
        </bindings>
        <behaviors>
            <serviceBehaviors>
                <behavior name="myBehaviour">
                    <serviceMetadata httpGetEnabled="true" />
                    <serviceDebug includeExceptionDetailInFaults="true" />
                    <serviceCredentials>
                        <serviceCertificate findValue="ServerCertificate" storeName="My" storeLocation="LocalMachine" x509FindType="FindBySubjectName" />
                        <clientCertificate>
                            <authentication certificateValidationMode="ChainTrust" revocationMode="NoCheck"/>
                        </clientCertificate>
                    </serviceCredentials>
                </behavior>
            </serviceBehaviors>
        </behaviors>
    </system.serviceModel>
</configuration>
Run Code Online (Sandbox Code Playgroud)

客户端配置文件

<system.serviceModel>
    <client>
        <endpoint …
Run Code Online (Sandbox Code Playgroud)

wcf certificate wshttpbinding

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

制作一个与Jboss wildfly兼容的春季5瘦身战争

我一直在尝试创建一个瘦的WAR,这将允许我将所有常见的jar提取到wildfly模块.这是因为70MB WAR在日常运营中变得不可持续.

我的方法是:

  1. 使用所有Jars创建一个wildfly模块(手动),除了我自己的库和spring-web.jar.

  2. 修改了我的war项目pom.xml,添加了:(其中mystuff - *.jar是我们自己的项目库)

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <configuration>
                <skinnyWars>true</skinnyWars>
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                        </manifest>
                </archive>
                <packagingExcludes>
                    %regex[WEB-INF/lib/(?!spring-web|mystuff-).*.jar]
                </packagingExcludes>
            </configuration>
        </plugin>
    
    Run Code Online (Sandbox Code Playgroud)
  3. 添加了一个jboss-deployment-structure.xml,其中包含以下内容:

    <jboss-deployment-structure>
        <deployment>
            <dependencies>
                <module name="my-company.core-libs" />
            </dependencies>
        </deployment>
    </jboss-deployment-structure>
    
    Run Code Online (Sandbox Code Playgroud)

现在这有两个问题:首先,我得到了"在类路径上检测到No Spring WebApplicationInitialized类型,因此应用程序根本没有启动.

其次,/ wildfly_root/ bin /content/spring-tx-5.1.3-relase.jar中的"类路径入口spring-tx-5.1.3.RELEASE.jar"的一个香椿没有指向一个有效的jar类 -路径引用"消息.(这是一个例子,一个spring-boot应用程序有70MB的罐子,所有这些都给出了这个警告).

检查清单我看到Class-Path下的很多jar看起来没问题.

我怎样才能解决这个问题?肯定有办法强迫wildfly找到我的SpringBootServletInitializer类并启动应用程序.

顺便说一下,我在maven-war-plugin上尝试了一些选项,上面的那个是(到目前为止)唯一允许Eclipe直接部署到服务器的选项.

堆:

  • Wildfly 15
  • 弹簧5.1.3弹簧启动.
  • 最新的maven和eclipse.

任何帮助赞赏.

eclipse spring maven-3 wildfly spring-boot

7
推荐指数
0
解决办法
210
查看次数

如何在跨域方案中避免使用signalR的"混合内容警告"?

我正在尝试使用SignalR构建浏览器< - > windows app通信的原型.

目标很简单:我在每个客户端上运行托盘应用程序,该应用程序读取智能卡并生成应传递给Web应用程序的值.

我在托盘应用程序上构建了一个自托管的SignalR集线器,并且网页与它成功通信.

问题是,在生产中,webapp是通过HTTPS提供的,而signalR集线器是通过经典HTTP传递的(例如http://localhost:8080),正如预期的那样,大多数现代浏览器抛出混合内容警告并拒绝与signalR交谈.

我的问题是:

1)有没有办法避免混合内容警告?

2)构建支持HTTPS的自托管http服务器是否值得?如果是这样,浏览器是否会https://localhost/通过一些自签名证书与客户交谈?

谢谢

cross-domain cors signalr

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

如何使用带有 Spring-Boot JPA 和 Maven 的 Liquibase 来管理来自 JPA 实体的迁移

我一直在尝试使用liquibase来管理 Spring JPA 项目上的迁移,就像 Python/Django 使用makemigrations. Liquibase文档非常混乱,我尝试遵循我在网上找到的一些 SA 答案和教程,但无济于事。

这是我想要做的:

  1. 通过 JPA 注释类定义实体。
  2. 生成迁移以反映 MySQL 数据库上的这些实体。
  3. 在数据库上应用所述迁移。(最初为空)

到目前为止,我能够生成一个“差异”更改日志文件,并以某种方式设法让 liquibase在空数据库上创建databasechangelogdatabasechangeloglock表。但是,我无法master.xml使用差异更新文件或将差异应用于数据库。

到目前为止,这是我的配置(基本的 spring-jpa 项目,只有一个用于测试的实体):

Pom.xml(缩写)

<project>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.3</version>
        <relativePath/>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <groupId>my-group</groupId>
    <artifactId>web</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>15</maven.compiler.source>
        <maven.compiler.target>15</maven.compiler.target>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-validation</artifactId>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
        <dependency>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-core</artifactId>
            <version>4.3.2</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins> …
Run Code Online (Sandbox Code Playgroud)

java hibernate jpa spring-boot liquibase-hibernate

6
推荐指数
0
解决办法
772
查看次数

在IE9中渲染具有清晰边缘的SVG形状

IE9似乎不尊重SVG shape-rendering="crispEdges"属性.

这是一个示例SVG:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns="http://www.w3.org/2000/svg" height="600" id="svgroot" version="1.1" width="800" x="0" y="0">
<line style="stroke:#000000;stroke-width:1px;stroke-opacity:1" y2="300" y1="300" x2="750" x1="50" shape-rendering="crispEdges" />
</svg>
Run Code Online (Sandbox Code Playgroud)

它在Firefox和Safari下正确显示,但在IE9和IE10(平台预览)下显示模糊

是否有一些解决方法来禁用IE9中的抗锯齿?

谢谢!

svg antialiasing internet-explorer-9

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

如何在 Spring Webclient 中处理 HTTP 状态码

在调用远程服务时,我一直在尝试进行简单的错误处理。该服务返回一个 Map。我正在寻找的行为是:

  • HTTP 200 --> 返回正文 ( Map<String, String>)。
  • HTTP 500 --> 抛出一个特定的异常
  • HTTP 404 --> 只需返回Null.

这是我的代码:

private Map<String, String> loadTranslations(String languageTag) {
    try {
        WebClient webClient = WebClient.create(serviceUrl);
        Map<String, String> result = webClient.get()
            .uri("/translations/{language}", languageTag)
            .accept(MediaType.APPLICATION_JSON)
            .retrieve()
            .onStatus(httpStatus -> HttpStatus.NOT_FOUND.equals(httpStatus),
                clientResponse -> Mono.error(new MyServiceException(HttpStatus.NOT_FOUND)))
            .onStatus(HttpStatus::is5xxServerError, response -> Mono.error(new MyServiceException(response.statusCode())))
            .bodyToMono(Map.class)
            .block();

        return result;
    } catch (MyServiceException ex) {  // doesn't work as in reality it throws ReactiveException
        ....
    }
}
Run Code Online (Sandbox Code Playgroud)

我不知道如何让 block() 的结果返回 NULL(或者我可以解释为“收到 404”的东西)。这个想法是只在 …

spring spring-webclient

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