Server:
TLS Version: v1.2
Cipher Suite: TLS_RSA_WITH_AES_256_CBC_SHA256
Client:
JRE 1.7
Run Code Online (Sandbox Code Playgroud)
当我尝试通过SSL直接从客户端连接到服务器时,我收到以下错误:
Caused by: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
at sun.security.ssl.Alerts.getSSLException(Alerts.java:154)
Run Code Online (Sandbox Code Playgroud)
以下代码启用TLSv1.2
Set<String> enabledTLSSet = new HashSet<String>(Arrays.asList(sslsocket.getEnabledProtocols()));
enabledTLSSet.add("TLSv1.2");
sslsocket.setEnabledProtocols(enabledTLSSet.toArray(new String[enabledTLSSet.size()]));
Run Code Online (Sandbox Code Playgroud)
以下代码启用了TLS_RSA_WITH_AES_256_CBC_SHA256密码套件:
Set<String> enabledCipherSuitesSet = new HashSet<String>(Arrays.asList(sslsocket.getEnabledCipherSuites()));
enabledCipherSuitesSet.add("TLS_RSA_WITH_AES_256_CBC_SHA256");
sslsocket.setEnabledCipherSuites(enabledCipherSuitesSet.toArray(new String[enabledCipherSuitesSet.size()]));
Run Code Online (Sandbox Code Playgroud)
从Java代码执行上述两个操作后,我可以通过SSL成功连接到服务器.
是否有可能使/力TLSv1.2
和TLS_RSA_WITH_AES_256_CBC_SHA256
Java 7中,而无需通过性能,参数或调试道具改变任何Java代码?
我尝试了所有形式和组合(启用和禁用)以及失败的所有以下属性.
-Dhttps.protocols=TLSv1.2
-Dhttps.cipherSuites=TLS_RSA_WITH_AES_256_CBC_SHA256
-Ddeployment.security.TLSv1.2=true
Run Code Online (Sandbox Code Playgroud)
我正在执行类似下面的程序:
java -jar -Dhttps.protocols=TLSv1.2 -Dhttps.cipherSuites=TLS_RSA_WITH_AES_256_CBC_SHA256 Ddeployment.security.TLSv1.2=true -Djavax.net.debug=ssl:handshake SSLPoker.jar <SERVER> 443
Run Code Online (Sandbox Code Playgroud)
SSLPoker包含以下代码:
package com.ashok.ssl;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import java.io.*;
/**
* Establish a SSL connection to a host and …
Run Code Online (Sandbox Code Playgroud) 我需要一个纯Apache Commons VFS解决方案/代码/示例
通过SFTP电话.
解决方案应该只使用Apache Commons VFS api,不应该引用底层的JSCH库.
问题就是这一切.我知道Singleton模式(同类的最终版)是一个解决方案.我们还有其他可能的方法吗?抽象类使其不可实例化.最终使它成为不可继承的.我们如何结合两者?
public final class SingletonObject
{
private SingletonObject()
{
// no code req'd
}
/*public static SingletonObject getSingletonObject()
{
if (ref == null)
// it's ok, we can call this constructor
ref = new SingletonObject();
return ref;
}*/
public Object clone()
throws CloneNotSupportedException
{
throw new CloneNotSupportedException();
// that'll teach 'em
}
private static SingletonObject ref;
}
Run Code Online (Sandbox Code Playgroud)
代码参考:http://www.javacoffeebreak.com/articles/designpatterns/index.html
我正在尝试从此URL检索JSON
http://www.iheartquotes.com/api/v1/random?format=json
Run Code Online (Sandbox Code Playgroud)
通过jQuery.我知道解决方案是JSONP,但由于我无法控制服务的响应文本或将其包装在我自己的回调函数中,我的目的是以某种方式使用客户端脚本检索上述URL的响应.
我已尝试从StackOverflow的几个答案中建议的几乎所有方法.这些是我尝试的代码块和我得到的响应.
1.直接调用返回预期的Access-Control-Allow-Origin错误
Run Code Online (Sandbox Code Playgroud)$.getJSON("http://www.iheartquotes.com/api/v1/random?format=json", function(data) { alert(data); });
响应:
XMLHttpRequest无法加载= 1376682146029"> http://www.iheartquotes.com/api/v1/random?format=json&=1376682146029.Access-Control-Allow-Origin 不允许使用Origin http://stackoverflow.com.
2.添加了回调参数的上述代码:
Run Code Online (Sandbox Code Playgroud)$.getJSON("http://www.iheartquotes.com/api/v1/random?format=json&callback=?", function(data) { alert(data); });
响应:
未捕获的SyntaxError:意外的令牌:
请注意,当我单击错误时,它会转到我预期的JSON响应.
{"json_class":"Fortune","tags":["simpsons_homer"],"quote":"Holy Moly! The bastard's rich!\n\n\t\t-- Homer Simpson\n\t\t Oh Brother, Where Art Thou?","link":"http://iheartquotes.com/fortune/show/5501","source":"simpsons_homer"}
Run Code Online (Sandbox Code Playgroud)
这也是预期的,因为响应中没有定义回调函数.
3.通过jQuery的Ajax方法
Run Code Online (Sandbox Code Playgroud)$.ajax({ type: "GET", dataType: "jsonp", url: "http://www.iheartquotes.com/api/v1/random?format=json", success: function(data){ alert(data); }, });
响应:
未捕获的SyntaxError:意外的令牌:
将回调参数添加到上述函数不会更改响应.
来自专家的任何帮助或指示从URL检索JSON?我正在使用Chrome开发工具对此进行测试.我知道我可以从服务器端代码调用该服务,然后将其发送到客户端.但我想看看是否可以通过客户端单独的jQuery来完成.
编辑:基于Kevin B的评论:使用jQuery的Ajax通过YQL获得预期的输出.但我的问题仍然是一样的.是否存在通过jQuery执行此操作的本机方式,因为YQL仍然是依赖项?
// Using YQL and JSONP
$.ajax({
url: "http://query.yahooapis.com/v1/public/yql",
// the name of the callback parameter, as specified by the YQL service
jsonp: …
Run Code Online (Sandbox Code Playgroud) 在Liferay的LDAP身份验证设置中使用时,b/n memberOf属性和groupMembership属性有何区别?
用户已成功导入.这些组也成功导入.
但是用户不会自动分配到组.当我将组变量从'groupMembership'更改为'memberOf'时,多个用户无法登录Liferay.
memberOf和groupMembership变量究竟是什么?
寻找高层差异/比较
当具体情况不详时,请使用相对比较。
我正在寻找一种通过Liferay Portal将PDF(直接显示)文件发送到浏览器的方法.找到了许多解决方案 - 最受欢迎的解决方案是编写一个可以完成工作的Servlet.我已经阅读了JSR 286规范中关于Portlet资源服务的内容,有人可以为Spring 3.0 Portlet MVC详细说明吗?
<servlet>
<display-name>DownloadServlet</display-name>
<servlet-name>DownloadServlet</servlet-name>
<servlet-class>com.liferay.portal.pdf.DownloadServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>DownloadServlet</servlet-name>
<url-pattern>/DownloadServlet/*</url-pattern>
</servlet-mapping>
Run Code Online (Sandbox Code Playgroud)
Servlet包括:
private void downloadServlet(HttpServletRequest req,
HttpServletResponse resp) throws ServletException, IOException {
logger.debug(" downloadServlet :: ");
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
ServletOutputStream op = null;
try {
//Something
pdfContentVO=//getpdf VO here
String filename = "PDFFILE_"+pdfNumber+".pdf";
op = resp.getOutputStream();
resp.setContentType("application/pdf");
resp.setHeader("Content-Disposition", "attachment; filename="
+ filename);
resp.setContentLength(pdfContentVO.getPdfData().length);
System.out.println("pdfcontent"+pdfContentVO.getPdfData());
op.write(pdfContentVO.getPdfData());
op.flush();
op.close();
} catch(final IOException e) {
System.out.println ( "IOException." );
throw e;
} …
Run Code Online (Sandbox Code Playgroud) 我已经能够在Liferay插件SDK中基于此示例定义自定义portlet操作/权限
https://github.com/liferay/liferay-plugins/tree/master/portlets/sample-permissions-portlet
我想知道从portlet中删除自定义portlet操作/权限(而不是模型权限)所需的必要步骤.
我记得当我重新部署具有修改的自定义操作/权限的portlet时,旧的自定义操作/权限会一直存在.
我尝试从Tomcat的webapps中删除portlet文件夹,但它已成功取消注册.但是,在我从相应的XML中删除自定义操作/权限后再次部署portlet之后,我仍然可以在"定义角色权限"中看到权限.
我尝试在Liferay的控制面板的服务器管理中清除权限设置,但它没有改变任何东西(它不应该).
在使用已删除/修改的权限重新部署portlet并重新启动服务器之后,我仍然看到分配给portlet的自定义操作/权限,但是当我选择portlet时,我没有看到删除的权限,这就是我需要.
取消部署portlet是否会从Liferay Portal和门户网站的数据库中删除所有相关的自定义操作/权限?或者我是否需要进行单独的liferay服务调用?在这方面的任何投入都非常感谢.
Liferay版本:6.1.2 CE GA3
portlet.properties
include-and-override=portlet-ext.properties
language.bundle=content.Language
resource.actions.configs=resource-actions/default.xml
Run Code Online (Sandbox Code Playgroud)
资源行动/ default.xml中
<?xml version="1.0"?>
<!DOCTYPE resource-action-mapping PUBLIC "-//Liferay//DTD Resource Action Mapping 6.2.0//EN" "http://www.liferay.com/dtd/liferay-resource-action-mapping_6_2_0.dtd">
<resource-action-mapping>
<portlet-resource>
<portlet-name>1</portlet-name>
<permissions>
<supports>
<action-key>ADD_SOMETHING</action-key>
<action-key>CONFIGURATION</action-key>
<action-key>VIEW</action-key>
</supports>
<site-member-defaults>
<action-key>VIEW</action-key>
</site-member-defaults>
<guest-defaults>
<action-key>VIEW</action-key>
</guest-defaults>
<guest-unsupported />
</permissions>
</portlet-resource>
</resource-action-mapping>
Run Code Online (Sandbox Code Playgroud)
内容/ language.properties
action.ADD_SOMETHING=Add Something
Run Code Online (Sandbox Code Playgroud)
portlet.xml中
<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" version="2.0">
<portlet>
<portlet-name>1</portlet-name>
<display-name>Sample Permissions</display-name>
<portlet-class>com.liferay.util.bridges.mvc.MVCPortlet</portlet-class>
<init-param>
<name>view-template</name>
<value>/view.jsp</value>
</init-param>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
</supports>
<resource-bundle>content.Language</resource-bundle>
<portlet-info>
<title>Sample Permissions</title>
<short-title>Sample Permissions</short-title>
<keywords>Sample …
Run Code Online (Sandbox Code Playgroud) 当 Kubernetes Spring-Boot 应用程序启动有 8 个实例时,每个节点中运行的应用程序需要获取 pod/容器的序列号。运行同一应用程序的 Pod/容器不应有重复的数字。假设一个 Pod 运行单个容器,而一个容器仅运行应用程序的一个实例。
应用程序可以从 Kubernetes API 为每个 Pod 提取一些唯一标识符,例如:
networkInterface.getHardwareAddress()
)aks-default-12345677-3
my-sample-service-sandbox-54k47696e9-abcde
)aa7k6278-abcd-11ef-e531-kdk8jjkkllmm
)12.34.56.78
)但是从 API 获取此信息的应用程序无法在指定的 pod 范围 [0 - 最大节点计数-1] 内安全地生成并为其分配唯一的编号。任何在这些唯一标识符上运行的缩减器步骤(按位 &)最终都会重复这些数字。与其他 Pod 进行通信是一种反模式,尽管有些方法采用共识/协议模式来实现这一点。
我的问题是: Kubernetes 是否有一种简单的方法可以在创建每个节点/容器/pod 时为每个节点/容器/pod 分配一个序列号 - 可能是在 pod 中的环境变量中?这些数字可以从 0 或 1 开始,并且应该达到住宅区 pod 数量的最大计数。
背景信息和一些研究:
执行UUID.randomUUID().hashCode() & 7
八次将会重复 0 到 7 之间的数字。请参阅中存在此错误的文章createNodeId()
。上述减速器步骤实际运行的示例输出。
{0=2, 1=1, 2=0, …
Run Code Online (Sandbox Code Playgroud) distributed-system id-generation spring-boot kubernetes twitter-snowflake
我需要一个应该始终运行的服务,直到我的活动显式停止它,并且即使由于某些问题(START_STICKY
标志)而停止它也应该重新开始.这项服务应该持续做一些事情(每隔几秒钟)使用一个TimerTask
.我最终得到了以下代码.
public class SomeService extends Service {
@Override
public IBinder onBind(Intent intent) {
return null;
}
TimerTask timerTask;
final Handler handler = new Handler();
Timer timer = new Timer();
@Override
public void onCreate() {
// code to execute when the service is first created
super.onCreate();
}
@Override
public void onDestroy() {
// code to execute when the service is shutting down
super.onDestroy();
}
@Override
public void onStart(Intent intent, int startid) {
// code to execute when …
Run Code Online (Sandbox Code Playgroud) 有没有办法从浏览器通过Javascript/jQuery或源代码找出服务器上部署的Liferay版本?
我看过Liferay的Javascript API.它包含许多有用的方法.
我可以使用API中的方法找出正在运行的加载页面的Liferay版本吗?
编辑:或者还有其他方法,如从客户端检查加载的资源(js/images/css/source/theme)名称,以确认门户网站在特定的liferay版本上运行?欢迎任何粗略的建议.
liferay ×4
liferay-6 ×4
java ×2
jquery ×2
ajax ×1
android ×1
comparison ×1
cross-domain ×1
data-lake ×1
database ×1
datamart ×1
download ×1
encryption ×1
java-7 ×1
javascript ×1
kubernetes ×1
ldap ×1
ldap-query ×1
permissions ×1
portal ×1
service ×1
sftp ×1
spring-boot ×1
spring-mvc ×1
ssl ×1
timer ×1
timertask ×1
tls1.2 ×1
upload ×1