Tomcat / JKS / Keytool - 重新生成私钥?(Tomcat / JKS / Keytool - regenerate private key?)
是否可以使用keytool或等效工具在.JKS密钥库中重新生成私钥?
我已经获得了证书和JKS密钥库,但是在导入证书时,看起来已经删除了用于生成CSR的私钥。
我可以看到如何使用新的私钥创建新的密钥库,但这不会与CSR或证书匹配。
Is it possible to regenerate a private key in a .JKS keystore using keytool or equivalent?
I've been supplied with a certificate and a JKS keystore, but on importing the cert it looks like the private key that was used to generate the CSR has been deleted.
I can see how to create a new keystore with a new private key, but this won't then match the CSR or certificate.
原文:https://stackoverflow.com/questions/12094986
最满意答案
您只需在编译时使用注释。 如果注释类在运行时不可用,则它们将不存在。
例如,如果客户端代码在域模型类上调用AnnotatedElement.getAnnotations(),并且编译的注释在类路径中不可用,则不会返回它们。
如果使用maven,则应声明注释依赖项,并使用scope可选。 可选的依赖项不会包含在客户端中。 因此,只有客户声明它们时才可用。
例如:
如果Proj-A在Proj-B上有可选的依赖项(? - >)
Proj-A ?-> Proj-B
并且Proj-X将Proj-A引用为编译依赖项,它将不会获得可选的依赖项Proj-B。
Proj-X -> Proj-A
因为传递依赖性解析以可选依赖关系结束。
期望在名为
annotations.jar
的jar文件中包含以下annotations.jar
@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) public @interface ARuntimeAnnotation { }
并且你有一个
model.jar
包含的以下模型类@ARuntimeAnnotation public class Model { }
并且
model.jar
与model.jar
有依赖关系,因为它需要它来编译。<depdendency> <groupId>someGroup</groupId> <artifactId>annotations</artifactId> <scope>optional</scope> </dependency>
如果此依赖项是可选的,那么它将不会自动成为某人的传递依赖关系,它仅依赖于
model.jar
。现在客户想要使用
Model
类。 因此它对model.jar
有依赖性。<depdendency> <groupId>someGroup</groupId> <artifactId>model</artifactId> </dependency>
如果客户端还想要查看注释
ARuntimeAnnotation
那么它还必须包含annotations.jar作为依赖项,因为它是可选的。如果客户端不包含对annotations.jar的依赖,则以下调用将返回一个空数组:
Model.class.getAnnotations(); // will be empty if the annotations.jar is not available at runtime
You only have to use the annotations at compile time. If the annotation classes are not available at runtime they will simply not exist.
E.g. if the client code calls AnnotatedElement.getAnnotations() on a domain model class and the annotations it was compiled with are not available in the class path they will not be returned.
If you use maven you should declare the annotation dependencies with scope optional. Optional dependencies will not be included in the client. Thus they are only available if the client declares them.
For example:
If Proj-A has a optional dependency ( ?-> ) on Proj-B
Proj-A ?-> Proj-B
and a Proj-X references Proj-A as a compile dependency it will not get the optional dependency Proj-B.
Proj-X -> Proj-A
because transitive dependency resolution ends on an optional dependency.
Expect that you have the following annotation in a jar file called
annotations.jar
@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) public @interface ARuntimeAnnotation { }
and you have the following model class contained in a
model.jar
@ARuntimeAnnotation public class Model { }
and the
model.jar
has a dependency to theannotations.jar
because it needs it to compile.<depdendency> <groupId>someGroup</groupId> <artifactId>annotations</artifactId> <scope>optional</scope> </dependency>
If this dependency is optional it will not be automatically become a transitive dependency of someone how only has a dependency on the
model.jar
.Now a client wants to use the
Model
class. Thus it has a dependency tomodel.jar
.<depdendency> <groupId>someGroup</groupId> <artifactId>model</artifactId> </dependency>
If the client also wants to see the annotation
ARuntimeAnnotation
it must also include the annotations.jar as a dependency, because it is optional.If the client does not include dependency on the annotations.jar the following call will return an empty array:
Model.class.getAnnotations(); // will be empty if the annotations.jar is not available at runtime
相关问答
更多-
我找到的最佳选择是等待。 GWT团队仍在开展客户端验证工作,并将于今年夏天结束。 http://code.google.com/p/google-web-toolkit/wiki/BeanValidation 评论由项目成员ncha ... @ google.com,2012年4月10日: “我计划今年夏天完成规范的实施。” 由于这个应用程序没有太多的输入数据,我选择仅在服务器上进行验证。 Best option that I've found is to wait. GWT team is still w ...
-
是。 Hibernate工具是一个eclipse插件,它具有可视化实体结构及其之间关系的功能。 Yes. Hibernate tool is an eclipse plug-in that has a feature to visualize the structure of entities and the relationships between them.
-
您只需在编译时使用注释。 如果注释类在运行时不可用,则它们将不存在。 例如,如果客户端代码在域模型类上调用AnnotatedElement.getAnnotations(),并且编译的注释在类路径中不可用,则不会返回它们。 如果使用maven,则应声明注释依赖项,并使用scope可选。 可选的依赖项不会包含在客户端中。 因此,只有客户声明它们时才可用。 例如: 如果Proj-A在Proj-B上有可选的依赖项(? - >) Proj-A ?-> Proj-B 并且Proj-X将Proj-A引用为编译依赖 ...
-
我发现总是有效的实体而不是依赖外部验证对象会更好。 话虽这么说,唯一的检查有点例外,因为它通常不是聚合本身可以自己确定的东西,你必须查看所有现有的聚合以查看该值是否尚未被采用。 我所做的是在创建实体之前检查值的可用性,并在数据库中放置一个约束,该约束将在持久性时验证唯一性。 您还可以尝试查找包含所有实体的域概念,并使其成为具有所有代码列表的聚合,并强制执行唯一性不变量。 I find it better to have always valid entities rather than rely on an ...
-
矮小的回答:不,他们不一样。 域对象实际上是(删除) ..看看@meze的评论..有一个链接。 这部分“实体方案,它们的属性和关系”与数据结构有点相关。 但是你的Domain对象不应该知道它们被存储的事实,或者甚至存在存储。 这是数据访问层的责任。 而域模型是操纵不同类型和数量的域对象的总体结构。 Shorty answer: no, they are not the same. Domain objects actually are (removed) .. look at the comment fro ...
-
像这样考虑一下; OOP的一个关键组成部分是关注点; 对数据进行操作的方法应与该数据分组。 通常,域模型将捕获问题域,但由于问题域“怪癖”,域模型可能无法反映关注的适当聚类。 面向对象的域建模只是将域模型重新映射到面向对象(即关注群集)模型。 他们捕获相同的东西你是对的,但关键是域模型更关注纯粹代表问题域; OODM关注的是以反映适当OOP技术的方式表示问题域。 Consider it like this; one critical component of OOP is the clustering of ...
-
逻辑模型和域模型(The logical model and the domain model)[2023-03-07]
以下是有关逻辑模型和域模型的维基百科文章。 根据我的阅读,逻辑模型涉及数据对象建模和数据对象之间的关系,无需任何数据库考虑。 域模型涉及对流程建模和流程之间的关系,而不考虑任何计算机语言。 我通常使用单个逻辑/域模型用于两个目的。 第一个是为我的物理数据模型建立一个起点。 另一种是在我的业务层中映射我的类。 您的业务对象类不必与您的数据模型匹配。 例如,您可能有一个Person类,它在关系数据库上映射到几个不同的表; 人,地址,电话号码等 Here are the Wikipedia articles on ... -
在域模型中验证?(Validation in domain model?)[2021-06-16]
如果验证规则构成业务域的一部分,则它们属于模型。 一个聚合根负责维护它所包含的不变量,因此验证它们属于它的责任范围。 如果您发现验证规则非常复杂,则可以创建验证服务,该验证服务将由聚合根用于此功能。 If the validation rules form part of the business domain, they belong in the model. An aggregate root is responsible of maintaining the invariants encompass ... -
你可以使用hibernate-tools.jar中的hbm2java ant任务。 这是一个称为Hibernate Tool的工具。 hbm2java将从hbm文件生成JPA注释的POJOS。 请参阅http://www.hibernate.org/hib_docs/tools/reference/en/html/ant.html You could use hbm2java ant task from hibernate-tools.jar. This is a tool known as Hiberna ...
-
什么是域模型中的贫血?(What is anemia in domain model?)[2022-09-11]
它由代码展出,其中: 大多数代码都以域对象(例如Account或TransactionEntity)的形式处理传递数据结构(如果你愿意的话,属性包)。 它们是“域对象”主要是因为它们具有域中存在的东西的名称。 大多数逻辑都驻留在外部“服务”中 - 包含在(或单个)数据结构列表上运行的脚本。 因此,服务需要访问/修改域对象的内部信息。因此域对象会自发地生成大量的getter和setter。 RIP封装。 贫血是指域类中域逻辑/行为的缺失或缺乏。 更多指标: 'Ask'方法超过'Tell / Do'方法 It ...