Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/wso2/product-apim into ma…
Browse files Browse the repository at this point in the history
…ster-checkstyles
  • Loading branch information
AnuGayan committed Mar 6, 2024
2 parents 7de00ad + 68e8e23 commit 04fe633
Show file tree
Hide file tree
Showing 58 changed files with 1,600 additions and 849 deletions.
1,227 changes: 608 additions & 619 deletions LICENSE.txt

Large diffs are not rendered by default.

60 changes: 0 additions & 60 deletions modules/callhome/pom.xml

This file was deleted.

14 changes: 13 additions & 1 deletion modules/distribution/product/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@
<groupId>org.wso2.orbit.com.lmax</groupId>
<artifactId>disruptor</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.diagnostics</groupId>
<artifactId>runtime-diagnostics</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
Expand All @@ -92,6 +96,15 @@
<overWrite>true</overWrite>
<outputDirectory>target</outputDirectory>
</artifactItem>
<artifactItem>
<groupId>org.wso2.diagnostics</groupId>
<artifactId>runtime-diagnostics</artifactId>
<version>${diagnostics.tool.version}</version>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>target</outputDirectory>
<destFileName>diagnostics-tool</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
Expand Down Expand Up @@ -414,7 +427,6 @@
<delete dir="target/sources" />
<delete dir="target/site" />
<delete dir="src/site" />
<delete dir="target/forget-me" />
</tasks>
</configuration>
<goals>
Expand Down
46 changes: 46 additions & 0 deletions modules/distribution/product/src/main/assembly/bin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,26 @@
<exclude>**/lib/xalan*.jar</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>target/diagnostics-tool</directory>
<outputDirectory>wso2am-${pom.version}/diagnostics-tool</outputDirectory>
<excludes>
<exclude>bin/diagnostics</exclude>
<exclude>lib/**</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>target/diagnostics-tool/lib</directory>
<outputDirectory>wso2am-${pom.version}/lib</outputDirectory>
<excludes>
<exclude>antlr-runtime-*.jar</exclude>
<exclude>gson*.jar</exclude>
<exclude>commons-lang3-*.jar</exclude>
<exclude>log4j-api-*.jar</exclude>
<exclude>log4j-core-*.jar</exclude>
<exclude>cava-toml-*.jar</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>target/wso2carbon-core-${carbon.kernel.version}</directory>
<outputDirectory>wso2am-${pom.version}</outputDirectory>
Expand Down Expand Up @@ -713,6 +733,16 @@
<include>client-registration#v0.17.war</include>
</includes>
</fileSet>
<fileSet>
<directory>
../../p2-profile/product/target/wso2carbon-core-${carbon.kernel.version}/repository/deployment/server/webapps
</directory>
<outputDirectory>${pom.artifactId}-${pom.version}/repository/deployment/server/webapps
</outputDirectory>
<includes>
<include>api#identity#auth#v1.1.war</include>
</includes>
</fileSet>


<!-- Copy sample calculator api webapp-->
Expand Down Expand Up @@ -780,6 +810,7 @@
<excludes>
<exclude>**/cxf3/spring-asm-3.1.4.RELEASE.jar</exclude>
<exclude>**/cxf3/snakeyaml-1.28.jar</exclude>
<exclude>**/cxf3/spring-*.jar</exclude>
</excludes>
</fileSet>

Expand Down Expand Up @@ -1292,6 +1323,21 @@
<fileMode>755</fileMode>
</file>

<file>
<source>src/main/startup-scripts/diagnostics.sh</source>
<outputDirectory>wso2am-${pom.version}/diagnostics-tool/bin/</outputDirectory>
<filtered>true</filtered>
<fileMode>755</fileMode>
</file>

<file>
<source>src/main/resources/conf/templates/diagnostics-tool/conf/config.toml.j2</source>
<outputDirectory>wso2am-${pom.version}/repository/resources/conf/templates/diagnostics-tool/conf</outputDirectory>
<destName>config.toml.j2</destName>
<filtered>true</filtered>
<fileMode>644</fileMode>
</file>

<file>
<source>../../../config/bam.xml</source>
<outputDirectory>wso2am-${pom.version}/repository/conf/etc</outputDirectory>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ product.key=AM
product.version=4.3.0
product.wum.name=wso2am

carbon.version=4.9.26.alpha1
carbon.version=4.9.26.alpha2
am.version=4.3.0
default.server.role=APIManager
bundle.creators=org.wso2.carbon.mediator.bridge.MediatorBundleCreator
25 changes: 0 additions & 25 deletions modules/distribution/product/src/main/bin/forgetme/forgetme.bat

This file was deleted.

37 changes: 0 additions & 37 deletions modules/distribution/product/src/main/bin/forgetme/forgetme.sh

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ appender.ERROR_LOGFILE.name = ERROR_LOGFILE
appender.ERROR_LOGFILE.fileName = ${sys:carbon.home}/repository/logs/wso2-apigw-errors.log
appender.ERROR_LOGFILE.filePattern = ${sys:carbon.home}/repository/logs/wso2-apigw-errors-%d{MM-dd-yyyy}-%i.log.gz
appender.ERROR_LOGFILE.layout.type = PatternLayout
appender.ERROR_LOGFILE.layout.pattern = %d{ISO8601} [%X{ip}-%X{host}] [%t] %5p %c{1} %m%n
appender.ERROR_LOGFILE.layout.pattern = %d{ISO8601} [%X{ip}-%X{host}] [%t] %5p {%c} %m%n
appender.ERROR_LOGFILE.policies.type = Policies
appender.ERROR_LOGFILE.policies.time.type = TimeBasedTriggeringPolicy
appender.ERROR_LOGFILE.policies.time.interval = 1
Expand Down
72 changes: 71 additions & 1 deletion modules/distribution/product/src/main/extensions/basicauth.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@
~ under the License.
--%>

<%@ page import="org.apache.cxf.jaxrs.client.Client" %>
<%@ page import="org.apache.cxf.configuration.jsse.TLSClientParameters" %>
<%@ page import="org.apache.cxf.transport.http.HTTPConduit" %>
<%@ page import="org.apache.cxf.jaxrs.client.JAXRSClientFactory" %>
<%@ page import="org.apache.cxf.jaxrs.provider.json.JSONProvider" %>
<%@ page import="org.apache.cxf.jaxrs.client.WebClient" %>
<%@ page import="org.apache.http.HttpStatus" %>
<%@ page import="org.json.JSONObject" %>
<%@ page import="org.owasp.encoder.Encode" %>
<%@ page import="org.wso2.carbon.identity.application.authentication.endpoint.util.client.SelfUserRegistrationResource" %>
<%@ page import="org.wso2.carbon.identity.application.authentication.endpoint.util.AuthenticationEndpointUtil" %>
Expand All @@ -37,16 +41,25 @@
<%@ page import="static org.wso2.carbon.identity.core.util.IdentityUtil.getServerURL" %>
<%@ page import="org.apache.commons.codec.binary.Base64" %>
<%@ page import="org.apache.commons.text.StringEscapeUtils" %>
<%@ page import="org.apache.commons.logging.Log" %>
<%@ page import="org.apache.commons.logging.LogFactory" %>
<%@ page import="java.nio.charset.Charset" %>
<%@ page import="org.wso2.carbon.base.ServerConfiguration" %>
<%@ page import="org.wso2.carbon.identity.application.authentication.endpoint.util.EndpointConfigManager" %>
<%@ page import="org.wso2.carbon.identity.core.URLBuilderException" %>
<%@ page import="org.wso2.carbon.identity.core.ServiceURLBuilder" %>
<%@ page import="org.wso2.carbon.identity.mgt.endpoint.util.IdentityManagementEndpointUtil" %>
<%@ page import="org.wso2.carbon.identity.mgt.endpoint.util.client.AdminAdvisoryDataRetrievalClient" %>
<%@ page import="org.wso2.carbon.identity.mgt.endpoint.util.client.ApplicationDataRetrievalClient" %>
<%@ page import="org.wso2.carbon.identity.mgt.endpoint.util.client.ApplicationDataRetrievalClientException" %>
<%@ page import="org.wso2.carbon.identity.mgt.endpoint.util.client.PreferenceRetrievalClient" %>
<%@ page import="org.wso2.carbon.identity.mgt.endpoint.util.client.PreferenceRetrievalClientException" %>
<%@ page import="org.wso2.carbon.utils.CustomHostNameVerifier" %>
<%@ page import="javax.net.ssl.HostnameVerifier" %>
<%@ page import="static org.wso2.carbon.CarbonConstants.ALLOW_ALL" %>
<%@ page import="static org.wso2.carbon.CarbonConstants.DEFAULT_AND_LOCALHOST" %>
<%@ page import="static org.wso2.carbon.CarbonConstants.HOST_NAME_VERIFIER" %>
<%@ page import="org.apache.http.conn.ssl.AllowAllHostnameVerifier" %>

<jsp:directive.include file="includes/init-loginform-action-url.jsp"/>
<jsp:directive.include file="plugins/basicauth-extensions.jsp"/>
Expand Down Expand Up @@ -134,8 +147,27 @@
private static final String ACCOUNT_RECOVERY_ENDPOINT = "/accountrecoveryendpoint";
private static final String ACCOUNT_RECOVERY_ENDPOINT_RECOVER = "/recoveraccountrouter.do";
private static final String ACCOUNT_RECOVERY_ENDPOINT_REGISTER = "/register.do";
private Log log = LogFactory.getLog(this.getClass());
%>
<%
String system_app = request.getParameter("sp");
Boolean isAdminBannerAllowedInSP = system_app != null && system_app.endsWith("apim_admin_portal");
Boolean isAdminAdvisoryBannerEnabledInTenant = false;
String adminAdvisoryBannerContentOfTenant = "";
try {
if (isAdminBannerAllowedInSP) {
AdminAdvisoryDataRetrievalClient adminBannerPreferenceRetrievalClient =
new AdminAdvisoryDataRetrievalClient();
JSONObject adminAdvisoryBannerConfig = adminBannerPreferenceRetrievalClient
.getAdminAdvisoryBannerDataFromServiceStub();
isAdminAdvisoryBannerEnabledInTenant = adminAdvisoryBannerConfig.getBoolean("enableBanner");
adminAdvisoryBannerContentOfTenant = adminAdvisoryBannerConfig.getString("bannerContent");
}
} catch (Exception e) {
log.error("Error in displaying admin advisory banner", e);
}
String emailUsernameEnable = application.getInitParameter("EnableEmailUserName");
Boolean isEmailUsernameEnabled = false;
String usernameLabel = "username";
Expand Down Expand Up @@ -206,6 +238,32 @@
SelfUserRegistrationResource selfUserRegistrationResource = JAXRSClientFactory
.create(url, SelfUserRegistrationResource.class, providers);
Client client = WebClient.client(selfUserRegistrationResource);
HTTPConduit conduit = WebClient.getConfig(client).getHttpConduit();
TLSClientParameters tlsParams = conduit.getTlsClientParameters();
if (tlsParams == null) {
tlsParams = new TLSClientParameters();
}
HostnameVerifier allowAllHostnameVerifier = new AllowAllHostnameVerifier();
if (EndpointConfigManager.isHostnameVerificationEnabled()) {
if (DEFAULT_AND_LOCALHOST.equals(System.getProperty(HOST_NAME_VERIFIER))) {
/*
* If hostname verifier is set to DefaultAndLocalhost, allow following domains in addition to the
* hostname:
* ["::1", "127.0.0.1", "localhost", "localhost.localdomain"]
*/
tlsParams.setHostnameVerifier(new CustomHostNameVerifier());
} else if (ALLOW_ALL.equals(System.getProperty(HOST_NAME_VERIFIER))) {
// If hostname verifier is set to AllowAll, disable hostname verification.
tlsParams.setHostnameVerifier(allowAllHostnameVerifier);
}
} else {
// Disable hostname verification
tlsParams.setHostnameVerifier(allowAllHostnameVerifier);
}
conduit.setTlsClientParameters(tlsParams);
WebClient.client(selfUserRegistrationResource).header("Authorization", header);
Response selfRegistrationResponse = selfUserRegistrationResource.regenerateCode(selfRegistrationRequest);
if (selfRegistrationResponse != null && selfRegistrationResponse.getStatus() == HttpStatus.SC_CREATED) {
Expand All @@ -224,6 +282,12 @@
}
%>

<% if (isAdminBannerAllowedInSP && isAdminAdvisoryBannerEnabledInTenant) { %>
<div class="ui warning message" data-componentid="login-page-admin-session-advisory-banner">
<%=Encode.forHtmlContent(adminAdvisoryBannerContentOfTenant)%>
</div>
<% } %>

<form class="ui large form" action="<%=loginFormActionURL%>" method="post" id="loginForm">
<%
if (loginFormActionURL.equals(samlssoURL) || loginFormActionURL.equals(oauth2AuthorizeURL)) {
Expand All @@ -233,7 +297,13 @@
}
%>

<% if (Boolean.parseBoolean(loginFailed)) { %>
<% if (StringUtils.equals(request.getParameter("errorCode"), IdentityCoreConstants.USER_ACCOUNT_LOCKED_ERROR_CODE) &&
StringUtils.equals(request.getParameter("remainingAttempts"), "0") ) { %>
<div class="ui visible negative message" id="error-msg" data-testid="login-page-error-message">
<%=AuthenticationEndpointUtil.i18n(resourceBundle, "error.user.account.locked.incorrect.login.attempts")%>
</div>
<% } else if (Boolean.parseBoolean(loginFailed) &&
!errorCode.equals(IdentityCoreConstants.USER_ACCOUNT_NOT_CONFIRMED_ERROR_CODE)) { %>
<div class="ui visible negative message" id="error-msg" data-testid="login-page-error-message">
<%= AuthenticationEndpointUtil.i18n(resourceBundle, errorMessage) %>
</div>
Expand Down
Loading

0 comments on commit 04fe633

Please sign in to comment.