001/* 002 * The contents of this file are subject to the terms of the Common Development and 003 * Distribution License (the License). You may not use this file except in compliance with the 004 * License. 005 * 006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the 007 * specific language governing permission and limitations under the License. 008 * 009 * When distributing Covered Software, include this CDDL Header Notice in each file and include 010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL 011 * Header, with the fields enclosed by brackets [] replaced by your own identifying 012 * information: "Portions Copyright [year] [name of copyright owner]". 013 * 014 * Copyright 2006-2008 Sun Microsystems, Inc. 015 * Portions Copyright 2016 ForgeRock AS. 016 */ 017package org.opends.quicksetup.installer; 018 019import org.opends.server.types.HostPort; 020 021/** 022 * This class is used to provide a data model for the different parameters used 023 * to connect to a server that we want to replicate contents with. 024 * 025 * @see DataReplicationOptions 026 */ 027public class AuthenticationData 028{ 029 private HostPort hostPort = new HostPort(null, 0); 030 private String dn; 031 private String pwd; 032 private boolean useSecureConnection; 033 034 /** 035 * Sets the server LDAP port. 036 * @param port the server LDAP port. 037 */ 038 public void setPort(int port) 039 { 040 hostPort = new HostPort(hostPort.getHost(), port); 041 } 042 043 /** 044 * Returns the server LDAP port. 045 * @return the server LDAP port. 046 */ 047 public int getPort() 048 { 049 return getHostPort().getPort(); 050 } 051 052 /** 053 * Returns the Authentication DN. 054 * @return the Authentication DN. 055 */ 056 public String getDn() 057 { 058 return dn; 059 } 060 061 /** 062 * Sets the Authentication DN. 063 * @param dn the Authentication DN. 064 */ 065 public void setDn(String dn) 066 { 067 this.dn = dn; 068 } 069 070 /** 071 * Returns the authentication password. 072 * @return the authentication password. 073 */ 074 public String getPwd() 075 { 076 return pwd; 077 } 078 079 /** 080 * Sets the authentication password. 081 * @param pwd the authentication password. 082 */ 083 public void setPwd(String pwd) 084 { 085 this.pwd = pwd; 086 } 087 088 /** 089 * Returns the host name and port to connect to. 090 * @return the host name and port to connect to. 091 */ 092 public HostPort getHostPort() 093 { 094 return hostPort; 095 } 096 097 /** 098 * Sets the host name to connect to. 099 * @param hostport the host name and port to connect to. 100 */ 101 public void setHostPort(HostPort hostport) 102 { 103 this.hostPort = hostport; 104 } 105 106 /** 107 * Returns whether to use a secure connection or not. 108 * @return <CODE>true</CODE> if we must use a secure connection and 109 * <CODE>false</CODE> otherwise. 110 */ 111 public boolean useSecureConnection() 112 { 113 return useSecureConnection; 114 } 115 116 /** 117 * Tells to use a secure connection or not. 118 * @param useSecureConnection use a secure connection or not. 119 */ 120 public void setUseSecureConnection(boolean useSecureConnection) 121 { 122 this.useSecureConnection = useSecureConnection; 123 } 124 125 String getLdapUrl() 126 { 127 HostPort hostPort = getHostPort(); 128 String scheme = useSecureConnection() ? "ldaps" : "ldap"; 129 return scheme + "://" + hostPort.getHost() + ":" + hostPort.getPort(); 130 } 131}