security/nss/lib/jar/jarnav.c

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/nss/lib/jar/jarnav.c	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,62 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +/*
     1.9 + *  JARNAV.C
    1.10 + *
    1.11 + *  JAR stuff needed for client only.
    1.12 + *
    1.13 + */
    1.14 +
    1.15 +#include "jar.h"
    1.16 +#include "jarint.h"
    1.17 +
    1.18 +/* from proto.h */
    1.19 +extern MWContext *FE_GetInitContext(void);
    1.20 +
    1.21 +/* To return an MWContext for Java */
    1.22 +static MWContext *(*jar_fn_FindSomeContext) (void) = NULL;
    1.23 +
    1.24 +/* To fabricate an MWContext for FE_GetPassword */
    1.25 +static MWContext *(*jar_fn_GetInitContext) (void) = NULL;
    1.26 +
    1.27 +/*
    1.28 + *  J A R _ i n i t
    1.29 + *
    1.30 + *  Initialize the JAR functions.
    1.31 + *
    1.32 + */
    1.33 +
    1.34 +void JAR_init (void)
    1.35 +{
    1.36 +    JAR_init_callbacks (XP_GetString, NULL, NULL);
    1.37 +}
    1.38 +
    1.39 +/*
    1.40 + *  J A R _ s e t _ c o n t e x t
    1.41 + *
    1.42 + *  Set the jar window context for use by PKCS11, since
    1.43 + *  it may be needed to prompt the user for a password.
    1.44 + *
    1.45 + */
    1.46 +int 
    1.47 +JAR_set_context(JAR *jar, MWContext *mw)
    1.48 +{
    1.49 +    if (mw) {
    1.50 +	jar->mw = mw;
    1.51 +    } else {
    1.52 +	/* jar->mw = XP_FindSomeContext(); */
    1.53 +	jar->mw = NULL;
    1.54 +	/*
    1.55 +	 * We can't find a context because we're in startup state and none
    1.56 +	 * exist yet. go get an FE_InitContext that only works at 
    1.57 +	 * initialization time.
    1.58 +	 */
    1.59 +	/* Turn on the mac when we get the FE_ function */
    1.60 +	if (jar->mw == NULL) {
    1.61 +	    jar->mw = jar_fn_GetInitContext();
    1.62 +	}
    1.63 +    }
    1.64 +    return 0;
    1.65 +}

mercurial