Skip to content

Commit

Permalink
Create constant variables for constant strings.
Browse files Browse the repository at this point in the history
  • Loading branch information
mpmadhavig committed Nov 22, 2023
1 parent 1dbc5cc commit 19a2fdd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
import java.net.URL;
import java.net.URLEncoder;

import static org.wso2.carbon.identity.authenticator.x509Certificate.X509CertificateUtil.DOMAIN_PATH_SEPARATOR;
import static org.wso2.carbon.identity.authenticator.x509Certificate.X509CertificateUtil.DOMAIN_PORT_SEPARATOR;
import static org.wso2.carbon.identity.authenticator.x509Certificate.X509CertificateUtil.PROTOCOL_DOMAIN_SEPARATOR;

/**
* X509 Certificate Servlet.
*/
Expand Down Expand Up @@ -80,9 +84,11 @@ protected void doPost(HttpServletRequest servletRequest, HttpServletResponse ser
String host = authenticationEndpointURL.getHost();
int port = authenticationEndpointURL.getPort();
if (port == -1) {
commonAuthURL = protocol + "://" + host + "/" + X509CertificateConstants.COMMON_AUTH;
commonAuthURL = protocol + PROTOCOL_DOMAIN_SEPARATOR + host + DOMAIN_PATH_SEPARATOR
+ X509CertificateConstants.COMMON_AUTH;
} else {
commonAuthURL = protocol + "://" + host + ":" + port + "/" + X509CertificateConstants.COMMON_AUTH;
commonAuthURL = protocol + PROTOCOL_DOMAIN_SEPARATOR + host + DOMAIN_PORT_SEPARATOR
+ port + DOMAIN_PATH_SEPARATOR + X509CertificateConstants.COMMON_AUTH;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
public class X509CertificateUtil {
private static final Log log = LogFactory.getLog(X509CertificateUtil.class);

public static final String PROTOCOL_DOMAIN_SEPARATOR = "://";
public static final String DOMAIN_PORT_SEPARATOR = ":";
public static final String DOMAIN_PATH_SEPARATOR = "/";

/**
* Get certificate from claims.
*
Expand Down

0 comments on commit 19a2fdd

Please sign in to comment.