bugId 17329

Added PlugletSecurityContext class.
Set ProxyJNI security context to PlugletSecurityContext
(see 15902)


git-svn-id: svn://10.0.0.236/trunk@51969 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
idk%eng.sun.com
1999-10-27 09:33:06 +00:00
parent a036d65c5c
commit 3b03dc263a
5 changed files with 106 additions and 1 deletions

View File

@@ -18,6 +18,7 @@
#include "nsIServiceManager.h"
#include "prenv.h"
#include "PlugletManager.h"
#include "ProxyJNI.h"
static NS_DEFINE_IID(kIPluginIID,NS_IPLUGIN_IID);
static NS_DEFINE_CID(kPluginCID,NS_PLUGIN_CID);
@@ -41,6 +42,7 @@ PRInt32 PlugletEngine::lockCount = 0;
PlugletEngine * PlugletEngine::engine = NULL;
nsIPluginManager *PlugletEngine::pluginManager = NULL;
jobject PlugletEngine::plugletManager = NULL;
PlugletSecurityContext *PlugletEngine::securityContext = NULL;
NS_IMPL_ISUPPORTS(PlugletEngine,kIPluginIID);
NS_METHOD PlugletEngine::Initialize(void) {
@@ -169,6 +171,11 @@ JNIEnv * PlugletEngine::GetJNIEnv(void) {
return NULL;
}
jvmManager->CreateProxyJNI(NULL,&res);
if (!securityContext) {
securityContext = new PlugletSecurityContext();
}
::SetSecurityContext(res,securityContext);
//nb error handling
//#endif
#if 0

View File

@@ -20,6 +20,7 @@
#include "nsJVMManager.h"
#include "nsIPluginManager.h"
#include "PlugletsDir.h"
#include "PlugletSecurityContext.h"
class PlugletEngine : public nsIPlugin {
public:
@@ -49,6 +50,7 @@ class PlugletEngine : public nsIPlugin {
static nsJVMManager * jvmManager;
static nsIPluginManager *pluginManager;
static jobject plugletManager;
static PlugletSecurityContext * securityContext;
};
#endif /* __PlugletEngine_h__ */

View File

@@ -0,0 +1,54 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Initial Developer of the Original Code is Sun Microsystems,
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
* Inc. All Rights Reserved.
*/
#include "PlugletSecurityContext.h"
static NS_DEFINE_IID(kISecurityContextIID, NS_ISECURITYCONTEXT_IID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
NS_IMPL_ADDREF(PlugletSecurityContext);
NS_IMPL_RELEASE(PlugletSecurityContext);
PlugletSecurityContext::PlugletSecurityContext() {
NS_INIT_REFCNT();
}
PlugletSecurityContext::~PlugletSecurityContext() {
}
NS_METHOD
PlugletSecurityContext::QueryInterface(const nsIID& aIID, void** aInstancePtr)
{
if (NULL == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
}
*aInstancePtr = NULL;
if (aIID.Equals(kISecurityContextIID) ||
aIID.Equals(kISupportsIID)) {
*aInstancePtr = (nsISecurityContext*) this;
AddRef();
return NS_OK;
}
return NS_NOINTERFACE;
}
NS_METHOD
PlugletSecurityContext::Implies(const char* target, const char* action, PRBool *bAllowedAccess)
{
*bAllowedAccess = PR_TRUE;
return NS_OK;
}

View File

@@ -0,0 +1,41 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Initial Developer of the Original Code is Sun Microsystems,
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
* Inc. All Rights Reserved.
*/
#include "nsISecurityContext.h"
class PlugletSecurityContext : public nsISecurityContext {
public:
////////////////////////////////////////////////////////////////////////////
// from nsISupports
NS_DECL_ISUPPORTS
////////////////////////////////////////////////////////////////////////////
// from nsISecurityContext:
/**
* Get the security context to be used in LiveConnect.
* This is used for JavaScript <--> Java.
*
* @param target -- Possible target.
* @param action -- Possible action on the target.
* @return -- NS_OK if the target and action is permitted on the security context.
* -- NS_FALSE otherwise.
*/
NS_IMETHOD Implies(const char* target, const char* action, PRBool *bAllowedAccess);
PlugletSecurityContext();
virtual ~PlugletSecurityContext();
};

View File

@@ -58,6 +58,7 @@ OBJS = \
.\$(OBJDIR)\PlugletManager.obj \
.\$(OBJDIR)\PlugletInputStream.obj \
.\$(OBJDIR)\PlugletInstanceView.obj \
.\$(OBJDIR)\PlugletSecurityContext.obj \
.\$(OBJDIR)\Registry.obj
MAKE_OBJ_TYPE = DLL
@@ -82,7 +83,7 @@ DLL = .\$(OBJDIR)\$(DLLNAME).dll
#// (ie. LCFLAGS, LLFLAGS, LLIBS, LINCS)
#//
#//------------------------------------------------------------------------
LLIBS=$(LLIBS) $(LIBNSPR) $(DIST)\lib\xpcom.lib $(DIST)\lib\oji.lib $(JDKHOME)\lib\jvm.lib
LLIBS=$(LLIBS) $(LIBNSPR) $(DIST)\lib\xpcom.lib $(DIST)\lib\oji.lib
#//------------------------------------------------------------------------
#//
#// Include the common makefile rules