Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/sun/security/util/RegisteredDomain.java
38830 views
1
/*
2
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
15
* accompanied this code).
16
*
17
* You should have received a copy of the GNU General Public License version
18
* 2 along with this work; if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
*
21
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* questions.
24
*/
25
26
package sun.security.util;
27
28
import java.util.Optional;
29
30
/**
31
* A domain that is registered under a "public suffix". The public suffix is
32
* a top-level domain under which names can be registered. For example,
33
* "com" and "co.uk" are public suffixes, and "example.com" and "example.co.uk"
34
* are registered domains.
35
* <p>
36
* The primary purpose of this class is to determine if domains are safe to
37
* use in various use-cases.
38
*/
39
public interface RegisteredDomain {
40
41
public enum Type {
42
/**
43
* An ICANN registered domain.
44
*/
45
ICANN,
46
/**
47
* A private registered domain.
48
*/
49
PRIVATE
50
}
51
52
/**
53
* Returns the name of the registered domain.
54
*
55
* @return the name of the registered domain
56
*/
57
String name();
58
59
/**
60
* Returns the type of the registered domain.
61
*
62
* @return the type of the registered domain
63
*/
64
Type type();
65
66
/**
67
* Returns the public suffix of the registered domain.
68
*
69
* @return the public suffix of the registered domain
70
*/
71
String publicSuffix();
72
73
/**
74
* Returns an {@code Optional<RegisteredDomain>} representing the
75
* registered part of the specified domain.
76
*
77
* {@implNote}
78
* The default implementation is based on the legacy
79
* {@code sun.net.RegisteredDomain} class which is no longer maintained.
80
* It should be updated or replaced with an appropriate implementation.
81
*
82
* @param domain the domain name
83
* @return an {@code Optional<RegisteredDomain>}; the {@code Optional} is
84
* empty if the domain is unknown or not registerable
85
* @throws NullPointerException if domain is null
86
*/
87
public static Optional<RegisteredDomain> from(String domain) {
88
if (domain == null) {
89
throw new NullPointerException();
90
}
91
return Optional.ofNullable(sun.net.RegisteredDomain.registeredDomain(domain));
92
}
93
}
94
95