Step4.java revision 532e14cdd83d81cef3bb65d5c2c3748fb61914f7
/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2007 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: Step4.java,v 1.20 2009/10/27 05:31:45 hengming Exp $
*
* Portions Copyrighted 2011-2014 ForgeRock AS.
*/
/**
* Step 4 is the input of the remote user data store properties.
*/
public class Step4 extends ProtectedPage {
public ActionLink validateUMHostLink =
public ActionLink validateUMDomainNameLink =
new ActionLink("validateUMDomainName", this,
"validateUMDomainName");
public ActionLink setSSLLink =
public ActionLink setUMEmbedded =
public ActionLink resetUMEmbedded =
public ActionLink setHostLink =
public ActionLink setDomainNameLink =
public ActionLink setPortLink =
public ActionLink setRootSuffixLink =
public ActionLink setLoginIDLink =
public ActionLink setPasswordLink =
public ActionLink setStoreTypeLink =
public Step4() {
}
public void onInit() {
super.onInit();
== null) {
val);
val);
val);
}
"true");
"LDAPv3ForODSEE");
}
"embedded");
} else {
}
} else {
}
val);
} else {
}
} else {
}
}
public boolean setAll() {
return false;
}
public boolean setSSL() {
} else {
}
return false;
}
public boolean setDomainName() {
} else {
responseString = "missing.domain.name";
}
return false;
}
public boolean setHost() {
} else {
responseString = "missing.host.name";
}
return false;
}
public boolean setUMEmbedded() {
"false");
return false;
}
public boolean resetUMEmbedded() {
"true");
return false;
}
public boolean setPort() {
} else {
responseString = "invalid.port.number";
}
} else {
responseString = "missing.host.port";
}
return false;
}
public boolean setLoginID() {
} else {
responseString = "missing.login.id";
}
return false;
}
public boolean setPassword() {
} else {
responseString = "missing.password";
}
return false;
}
public boolean setRootSuffix() {
} else {
responseString = "invalid.dn";
}
} else {
responseString = "missing.root.suffix";
}
return false;
}
public boolean setStoreType() {
}
return false;
}
public boolean validateUMHost() {
try {
new LDAPConnection();
//String filter = "cn=" + "\"" + rootSuffix + "\""; // NOT SURE Why "cn" is specified. would never work.
attrs, false);
writeToResponse("ok");
} catch (LDAPException lex) {
switch (lex.getLDAPResultCode()) {
case LDAPException.CONNECT_ERROR:
break;
case LDAPException.SERVER_DOWN:
break;
break;
case LDAPException.NO_SUCH_OBJECT:
break;
getLocalizedString("ldap.invalid.credentials"));
break;
break;
break;
break;
default:
getLocalizedString("cannot.connect.to.SM.datastore"));
}
} catch (Exception e) {
getLocalizedString("cannot.connect.to.SM.datastore"));
} finally {
try {
ld.disconnect();
} catch (LDAPException ex) {
//ignore
}
}
}
return false;
}
public boolean validateUMDomainName() {
try {
} catch (NamingException nex) {
getLocalizedString("cannot.connect.to.UM.datastore"));
return false;
} catch (IOException ioex) {
getLocalizedString("cannot.connect.to.UM.datastore"));
return false;
}
try {
new LDAPConnection();
//String filter = "cn=" + "\"" + rootSuffix + "\"";
attrs, false);
writeToResponse("ok");
} catch (LDAPException lex) {
switch (lex.getLDAPResultCode()) {
case LDAPException.CONNECT_ERROR:
"ldap.connect.error"));
break;
case LDAPException.SERVER_DOWN:
"ldap.server.down"));
break;
"ldap.invalid.dn"));
break;
case LDAPException.NO_SUCH_OBJECT:
"ldap.nosuch.object"));
break;
"ldap.invalid.credentials"));
break;
"ldap.unwilling"));
break;
"ldap.inappropriate"));
break;
"ldap.constraint"));
break;
default:
"cannot.connect.to.UM.datastore"));
}
} catch (Exception e) {
"cannot.connect.to.UM.datastore"));
} finally {
try {
ld.disconnect();
} catch (LDAPException ex) {
//ignore
}
}
}
return false;
}
// Method to get hostname and port number with the
// provided Domain Name for Active Directory user data store.
throws NamingException, IOException {
domainName+='.';
}
// Check if domain name is a valid one.
// The resource record type A is defined in RFC 1035.
try {
"com.sun.jndi.dns.DnsContextFactory");
throw new NamingException();
}
} catch (NamingException e) {
// Failed to resolve domainName to A record.
// throw exception.
throw e;
}
// then look for the LDAP server
try {
// Attempting to resolve ldapServer to SRV record.
// This is a mechanism defined in MSDN, querying
// SRV records for _ldap._tcp.DOMAINNAME.
// and get host and port from domain.
throw new NamingException();
}
if ((serverHostName != null) &&
}
} catch (NamingException e) {
// Failed to resolve ldapServer to SRV record.
// throw exception.
throw e;
}
// try to connect to LDAP port to make sure this machine
// has LDAP service
}
try {
} catch (IOException e) {
throw e;
}
return hostAndPort;
}
// Method to convert the domain name to the root suffix.
// eg., Domain Name amqa.test.com is converted to root suffix
// DC=amqa,DC=test,DC=com
}
}
}