/* Copyright (c) 2000, 2001 Oracle Corporation. All Rights Reserved. */
package oracle.portal.sample.v2.devguide.oid;

import oracle.portal.log.LogManager;

import oracle.portal.provider.v2.oid.OidInfo;
import oracle.portal.provider.v2.ProviderContext;

/**
 * This is a sample implementation of OidInfo.
 *
 * This method is simple but not <b>safe</b>, hence its name.
 * It is not safe  because
 * the OID connection details are stored in the 
 * deployment properties file and are not encrypted.
 */
public class UnsafeOidInfo extends OidInfo
{
    // These are the property names that appear in the 
    // <servicename>.properties eg
    // oidHost=machine.uk.company.com
    // oidPort=3021
    // oidUser=webProvider
    // oidPasswd=welcome1
    private final String OID_HOST_PROPERTY = "oidHost";
    private final String OID_PORT_PROPERTY = "oidPort";
    private final String OID_USER_PROPERTY = "oidUser";
    private final String OID_PASSWD_PROPERTY = "oidPasswd";

    public void init(ProviderContext pc)
    {

        // This class gets its data from the deployment config file
        // deployments/oid.properties
        // 
        // The data has already been extracted and is accessible via
        // ProviderContext.  

        setLDAPHost( (String)pc.getAttribute(OID_HOST_PROPERTY) );
        setLDAPPort( (String)pc.getAttribute(OID_PORT_PROPERTY) );
        setLDAPUser( (String)"cn=" + pc.getAttribute(OID_USER_PROPERTY) );
        setLDAPPasswd( (String)pc.getAttribute(OID_PASSWD_PROPERTY) );
    }

}
