8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster/**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Copyright (c) 2007 Sun Microsystems Inc. All Rights Reserved
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The contents of this file are subject to the terms
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * of the Common Development and Distribution License
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * (the License). You may not use this file except in
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * compliance with the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * You can obtain a copy of the License at
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * https://opensso.dev.java.net/public/CDDLv1.0.html or
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * opensso/legal/CDDLv1.0.txt
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * See the License for the specific language governing
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * permission and limitations under the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * When distributing Covered Code, include this CDDL
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Header Notice in each file and include the License file
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * at opensso/legal/CDDLv1.0.txt.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * If applicable, add the following below the CDDL Header,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * with the fields enclosed by brackets [] replaced by
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * your own identifying information:
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * "Portions Copyrighted [year] [name of copyright owner]"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * $Id: Step5.java,v 1.9 2009/01/05 23:17:10 veiming Exp $
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
67486d6b1ecf210ee0fba21ef9298f4fb6213d2cTom Rumsey * Portions Copyrighted 2011-2016 ForgeRock AS.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpackage com.sun.identity.config.wizard;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
67486d6b1ecf210ee0fba21ef9298f4fb6213d2cTom Rumseyimport java.net.MalformedURLException;
67486d6b1ecf210ee0fba21ef9298f4fb6213d2cTom Rumseyimport java.net.URL;
67486d6b1ecf210ee0fba21ef9298f4fb6213d2cTom Rumsey
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport org.apache.click.control.ActionLink;
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk
67486d6b1ecf210ee0fba21ef9298f4fb6213d2cTom Rumseyimport com.sun.identity.config.SessionAttributeNames;
67486d6b1ecf210ee0fba21ef9298f4fb6213d2cTom Rumseyimport com.sun.identity.config.util.ProtectedPage;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk/**
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk * Wizard Step # 5: Site Name, URL and Session HA Failover indicator.
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk * Session Failover indicator new @since 10.1
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk *
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk * This Step should be skipped when installing a secondary instance,
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk * as this information will be replicated by the underlying store.
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk *
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk */
532e14cdd83d81cef3bb65d5c2c3748fb61914f7Mark de Reeperpublic class Step5 extends ProtectedPage {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public ActionLink clearLink = new ActionLink(
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk "clear", this, "clear");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public ActionLink validateLink = new ActionLink(
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk "validateURL", this, "validateURL");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public ActionLink validateSiteLink = new ActionLink(
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk "validateSite", this, "validateSite");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk public Step5() {
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void onInit() {
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk String host = (String) getContext().getSessionAttribute(
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk SessionAttributeNames.LB_SITE_NAME);
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk String port = (String) getContext().getSessionAttribute(
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk SessionAttributeNames.LB_PRIMARY_URL);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (host != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster addModel("host", host);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (port != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster addModel("port", port);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk // Initialize our Parent.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster super.onInit();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk /**
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk * Clear all Site / VIP / Load Balancer Settings
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk *
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk * @return boolean indicator to view.
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public boolean clear() {
89503929c8983c48e2049c77284b52e79ad37c32jeff.schenk getContext().removeSessionAttribute(SessionAttributeNames.LB_SITE_NAME);
89503929c8983c48e2049c77284b52e79ad37c32jeff.schenk getContext().removeSessionAttribute(SessionAttributeNames.LB_PRIMARY_URL);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster setPath(null);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return false;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk /**
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk * Validate the Site Name
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * host= site config name
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * port = primary loadURL
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk * Just a little confusing!
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk */
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk public boolean validateSite() {
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk boolean returnVal = false;
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk String siteName = toString("host");
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk if ( (siteName == null) || (siteName.trim().isEmpty()) ) {
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk writeInvalid(getLocalizedString("missing.site.name"));
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk returnVal = true;
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk } else {
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk getContext().setSessionAttribute(
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk SessionAttributeNames.LB_SITE_NAME, siteName);
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk writeValid("ok.label");
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk }
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk setPath(null);
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk return returnVal;
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk }
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk /**
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk * Validate the Site URL
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk *
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk * host= site config name
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk * port = primary loadURL
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk * Just a little confusing!
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public boolean validateURL() {
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk boolean returnVal = false;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String primaryURL = toString("port");
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk if ( (primaryURL == null) || (primaryURL.trim().isEmpty()) ) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster writeToResponse(getLocalizedString("missing.primary.url"));
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk returnVal = true;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } else {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster try {
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk URL hostURL = new URL(primaryURL);
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk if ( (hostURL.getHost() == null) || (hostURL.getHost().trim().isEmpty()) ) {
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk writeToResponse(getLocalizedString("missing.host.name"));
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk returnVal = true;
89503929c8983c48e2049c77284b52e79ad37c32jeff.schenk } else if ( (hostURL.getPath() == null) || (hostURL.getPath().trim().isEmpty()) ||
89503929c8983c48e2049c77284b52e79ad37c32jeff.schenk (hostURL.getPath().trim().equalsIgnoreCase("/")) ) {
89503929c8983c48e2049c77284b52e79ad37c32jeff.schenk writeToResponse(getLocalizedString("primary.url.no.uri"));
89503929c8983c48e2049c77284b52e79ad37c32jeff.schenk returnVal = true;
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk } else {
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk getContext().setSessionAttribute(
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk SessionAttributeNames.LB_PRIMARY_URL, primaryURL);
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk writeToResponse("ok");
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } catch (MalformedURLException m) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster writeToResponse(getLocalizedString("primary.url.is.invalid"));
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk returnVal = true;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster setPath(null);
56ed5bbb263838f338eb8afc978091c01a4f2a2bjeff.schenk return returnVal;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster}