buildframework/helium/tools/preparation/password.ant.xml
author srilekhas <srilekhas@symbian.org>
Wed, 18 Aug 2010 11:18:38 +0100
changeset 627 cb3264f4c6e6
parent 217 0f5e3a7fb6af
child 628 7c4a911dc066
permissions -rw-r--r--
Merge : re-applies missing part of fix for Bug 2901,Add export for s60ibymacros.pm

<?xml version="1.0" encoding="UTF-8"?>
<!-- 
============================================================================ 
Name        : password.ant.xml 
Part of     : Helium 

Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
All rights reserved.
This component and the accompanying materials are made available
under the terms of the License "Eclipse Public License v1.0"
which accompanies this distribution, and is available
at the URL "http://www.eclipse.org/legal/epl-v10.html".

Initial Contributors:
Nokia Corporation - initial contribution.

Contributors:

Description:

============================================================================
-->
<!--* @package preparation -->
<project name="password" xmlns:hlm="http://www.nokia.com/helium">
    <description>
    Password retrieval targets
    </description>

    <!-- Retrieve the ATS password from the .netrc file and store it into ats.password property. -->
    <target name="ats-password">
        <hlm:netrcPasswordMacro output-prop="ats.password" result-prop="ats.password.available" type="ats"/>
        <hlm:logreplace regexp="ats.password"/>
    </target>
    
    <!-- Retrieve the ATS username from the .netrc file and store it into ats.username property. -->
    <target name="ats-username">
        <hlm:netrcUsernameMacro output-prop="ats.username" result-prop="ats.username.available" type="ats"/>
    </target>

    <!-- Retrieve the unix password from the .netrc file and store it into unix.password property. -->
    <target name="unix-password">
        <hlm:netrcPasswordMacro output-prop="unix.password" result-prop="unix.password.available" type="synergy"/>
        <hlm:logreplace regexp="${unix.password}"/>
    </target>
    
    <!-- Retrieve the unix username from the .netrc file and store it into unix.username property. -->
    <target name="unix-username">
        <hlm:netrcUsernameMacro output-prop="unix.username" result-prop="unix.username.available" type="synergy"/>
    </target>
    
    <!-- Ask for unix login using UI. -->
    <target name="get-unix-password" depends="unix-username,unix-password">
        <hlm:filterRecordStartMacro pattern="${unix.password}" category="unix"/>
        <if>
            <not>
                <equals arg1="${unix.password.available}" arg2="0"/>
            </not>
            <then>
                <!-- Unix username.
                @type string
                @scope private
                -->
                <property name="unix.username" value="${env.USERNAME}"/>
                <antform title="User login information">
                    <textProperty label="UNIX login:" property="unix.username"/>
                    <textProperty label="UNIX password:" property="unix.password" password="true"/>
                </antform>
                <!-- Equal 0 if the unix password if available
                @type string
                @scope private
                -->
                <property name="unix.password.available" value="1"/>
            </then>
        </if>
        <hlm:filterRecordStopMacro/>
    </target>
    
    <!-- Retrieve the GRACE password from the .netrc file and store it into release.grace.password property. -->
    <target name="grace-password" if="release.grace">
        <hlm:netrcPasswordMacro output-prop="release.grace.password" result-prop="grace.password.available" type="grace"/>
        <hlm:logreplace regexp="${release.grace.password}"/>
    </target>
    
    <!-- Retrieve the NOE password from the .netrc file and store it into noe.password property. -->
    <target name="noe-password">
        <hlm:netrcPasswordMacro output-prop="noe.password" result-prop="noe.password.available" type="noe"/>
        <hlm:logreplace regexp="${noe.password}"/>
        <if>
            <not>
                <isset property="noe.password"/>
            </not>
            <then>
                <antform title="NOE login information">
                    <label>Unable to read NOE password from h:\.netrc file.</label>
                    <textProperty label="NOE password:" property="noe.password" password="true"/>
                </antform>
            </then>
        </if>
    </target>
    
    <!-- Retrieve the notes password from the .netrc file and store it into notes.password property. -->    
    <target name="notes-password">
        <hlm:netrcPasswordMacro output-prop="release.notes.password" result-prop="notes.password.available" type="notes"/>
        <hlm:logreplace regexp="${release.notes.password}" />
    </target>

    <!-- Retrieve the ccm password from the .netrc file and store it into ccm.password property. 
    Requires ccm.enabled tobe set to 'true' to work.-->
    <target name="ccm-password" if="run.ccm">
        <hlm:netrcPasswordMacro output-prop="ccm.password.rc" result-prop="ccm.password.available" type="synergy"/>
    </target>
    
    <!-- Retrieve the ccm username from the .netrc file and store it into ccm.username property.
    Requires ccm.enabled tobe set to 'true' to work. -->
    <target name="ccm-username" if="run.ccm">
        <hlm:netrcUsernameMacro output-prop="ccm.login.rc" result-prop="ccm.username.available" type="synergy"/>
    </target>
    
    <!--
        This target retreive user's login and password and tries to
        open a synergy session. if it fails it leaves ant
        it sets the following properties:
         - ccm.user.login
         - ccm.user.password
        it requires ccm.database to be set to the wanted database and ccm.enabled to set to 'true'.
    -->
    <target name="get-ccm-password" depends="ccm-password,ccm-username" unless="ccm.user.password">
        <if>
            <isset property="run.ccm"/>
            <then>
                <hlm:filterRecordStartMacro pattern="${ccm.password.rc}" category="ccm"/>
                <if>
                    <not>
                        <and>
                            <isset property="ccm.login.rc"/>
                            <isset property="ccm.password.rc"/>
                        </and>
                    </not>
                    <then>
                        <if>              
                            <isset property="ccm.login.popup.disable"/> 
                            <then>
                                <echo>Error: Unable to read synergy username and password from .netrc file.</echo>
                                <property name="skip.password.validation" value="true"/>
                            </then> 
                            <else>
                                <!-- Contains the user name for CCM by reading the information from .netrc file.
                                @type string
                                @scope private
                                -->
                                <property name="ccm.user.login" value="${env.USERNAME}"/>
                                <antform title="Synergy login information">
                                    <label>Unable to read synergy username and password from h:\.netrc file.</label>
                                    <textProperty label="ccm login:" property="ccm.user.login"/>
                                    <textProperty label="ccm password:" property="ccm.user.password" password="true"/>
                                </antform>
                                <property name="ccm.password.available" value="1"/>
                                <!-- Unix username.
                                @type string
                                @scope private
                                -->
                                <property name="unix.username" value="${env.USERNAME}"/>
                                <!-- Unix password
                                @type string
                                @scope private
                                -->
                                <property name="unix.password" value="${ccm.user.password}"/>
                                <!-- Equal 0 if the unix password if available
                                @type string
                                @scope private
                                -->
                                <property name="unix.password.available" value="1"/>
                            </else> 
                        </if>
                    </then>
                    <else>
                        <!-- Contains the user name for CCM by reading the information from .netrc file.
                        @type string
                        @scope private
                        -->
                        <property name="ccm.user.login" value="${ccm.login.rc}"/>
                        <!-- Contains the password for CCM user name by reading the information from .netrc file.
                        @type string
                        @scope private
                        -->
                        <property name="ccm.user.password" value="${ccm.password.rc}"/>
                    </else>
                </if>
                <antcall target="ccm-check"/>
                <hlm:filterRecordStopMacro/>
            </then>
            <!--echo> ccm not enabled so not get password</echo-->
        </if>
    </target>
    
    <!-- check synergy is available needs ccm.enabled to be set to 'true' as well.-->
    <target name="ccm-check" unless="skip.password.validation">
        <if>
            <isset property="run.ccm"/>
            <then>
                <hlm:ccmAvailableMacro resultproperty="ccm.session.created"/>
                <echo>ccm.session.created = ${ccm.session.created}</echo>
                <if>
                    <equals arg1="${ccm.session.created}" arg2="-1"/>
                    <then>
                        <fail message="Unable to create CCM session."/>
                    </then>
                </if>
                <if>
                    <equals arg1="${ccm.session.created}" arg2="-2"/>
                    <then>
                        <fail message="Access Denied for user."/>
                    </then>
                </if>
            </then>
        </if>
    </target>
    
</project>