Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
abook_check
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abook_android
abook_check
Commits
c0214b71
Commit
c0214b71
authored
Dec 24, 2020
by
onuma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【Android】Biz SmartLink getits check API29/TrustManager対応
parent
6a14738f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
16 deletions
+52
-16
ABVJE_BL/src/jp/agentec/adf/net/http/AGTX509TrustManager.java
+50
-0
ABVJE_BL/src/jp/agentec/adf/net/http/HttpRequestSender.java
+2
-16
No files found.
ABVJE_BL/src/jp/agentec/adf/net/http/AGTX509TrustManager.java
0 → 100644
View file @
c0214b71
package
jp
.
agentec
.
adf
.
net
.
http
;
import
java.security.KeyStore
;
import
java.security.KeyStoreException
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.cert.CertificateException
;
import
java.security.cert.X509Certificate
;
import
javax.net.ssl.TrustManager
;
import
javax.net.ssl.TrustManagerFactory
;
import
javax.net.ssl.X509TrustManager
;
public
class
AGTX509TrustManager
implements
X509TrustManager
{
private
X509TrustManager
standardTrustManager
=
null
;
/**
* Constructor for EasyX509TrustManager.
*/
public
AGTX509TrustManager
(
KeyStore
keystore
)
throws
NoSuchAlgorithmException
,
KeyStoreException
{
super
();
TrustManagerFactory
factory
=
TrustManagerFactory
.
getInstance
(
TrustManagerFactory
.
getDefaultAlgorithm
());
factory
.
init
(
keystore
);
TrustManager
[]
trustmanagers
=
factory
.
getTrustManagers
();
if
(
trustmanagers
.
length
==
0
)
{
throw
new
NoSuchAlgorithmException
(
"no trust manager found"
);
}
this
.
standardTrustManager
=
(
X509TrustManager
)
trustmanagers
[
0
];
}
@Override
public
void
checkClientTrusted
(
X509Certificate
[]
x509Certificates
,
String
s
)
throws
CertificateException
{
standardTrustManager
.
checkClientTrusted
(
x509Certificates
,
s
);
}
@Override
public
void
checkServerTrusted
(
X509Certificate
[]
x509Certificates
,
String
s
)
throws
CertificateException
{
if
((
x509Certificates
!=
null
)
&&
(
x509Certificates
.
length
==
1
))
{
x509Certificates
[
0
].
checkValidity
();
}
else
{
standardTrustManager
.
checkServerTrusted
(
x509Certificates
,
s
);
}
}
@Override
public
X509Certificate
[]
getAcceptedIssuers
()
{
return
this
.
standardTrustManager
.
getAcceptedIssuers
();
}
}
ABVJE_BL/src/jp/agentec/adf/net/http/HttpRequestSender.java
View file @
c0214b71
...
...
@@ -1013,26 +1013,12 @@ public class HttpRequestSender {
}
};
private
static
TrustManager
[]
trustAllCerts
=
new
TrustManager
[]
{
new
X509TrustManager
()
{
@Override
public
java
.
security
.
cert
.
X509Certificate
[]
getAcceptedIssuers
()
{
return
new
java
.
security
.
cert
.
X509Certificate
[]
{};
}
@Override
public
void
checkClientTrusted
(
X509Certificate
[]
chain
,
String
authType
)
throws
CertificateException
{}
@Override
public
void
checkServerTrusted
(
X509Certificate
[]
chain
,
String
authType
)
throws
CertificateException
{}
}
};
private
static
void
trustAllHosts
()
{
// Install the all-trusting trust manager
try
{
SSLContext
sc
=
SSLContext
.
getInstance
(
"TLS"
);
sc
.
init
(
null
,
trustAllCerts
,
new
java
.
security
.
SecureRandom
());
//sc.init(null, trustAllCerts, new java.security.SecureRandom());
sc
.
init
(
null
,
new
TrustManager
[]{
new
AGTX509TrustManager
(
null
)},
new
java
.
security
.
SecureRandom
());
HttpsURLConnection
.
setDefaultSSLSocketFactory
(
sc
.
getSocketFactory
());
}
catch
(
Exception
e
)
{
throw
new
ABVRuntimeException
(
e
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment