Step5.java revision 8af80418ba1ec431c8027fa9668e5678658d3611
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 *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster/*
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Portions Copyrighted 2011-2012 ForgeRock AS
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpackage com.sun.identity.config.wizard;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.config.SessionAttributeNames;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.config.util.AjaxPage;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.setup.SetupConstants;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport org.apache.click.control.ActionLink;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.net.URL;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.net.MalformedURLException;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpublic class Step5 extends AjaxPage {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public ActionLink clearLink = new ActionLink(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster "clear", this, "clear");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public ActionLink validateLink = new ActionLink(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster "validateURL",this,"validateURL");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public ActionLink validateSiteLink = new ActionLink(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster "validateSite",this,"validateSite");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public Step5() {}
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void onInit() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String host = (String)getContext().getSessionAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SessionAttributeNames.LB_SITE_NAME);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String port = (String)getContext().getSessionAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SessionAttributeNames.LB_PRIMARY_URL);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (host != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster addModel("host", host);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (port != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster addModel("port", port);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster super.onInit();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public boolean clear() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster getContext().removeSessionAttribute(SetupConstants.LB_SITE_NAME);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster getContext().removeSessionAttribute(SetupConstants.LB_PRIMARY_URL);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster setPath(null);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return false;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * host= site config name
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * port = primary loadURL
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public boolean validateURL() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String primaryURL = toString("port");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (primaryURL == null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster writeToResponse(getLocalizedString("missing.primary.url"));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } else {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster try {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster URL hostURL = new URL(primaryURL);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster getContext().setSessionAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SessionAttributeNames.LB_PRIMARY_URL, primaryURL);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster writeToResponse("ok");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } catch (MalformedURLException m) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster writeToResponse(getLocalizedString("primary.url.is.invalid"));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster setPath(null);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return false;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public boolean validateSite() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster boolean returnVal = true;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String siteName = toString("host");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (siteName == null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster writeInvalid(getLocalizedString("missing.site.name"));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster returnVal = false;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } else {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster getContext().setSessionAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SessionAttributeNames.LB_SITE_NAME, siteName);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster writeValid("ok.label");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster setPath(null);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return returnVal;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster}