本文整理匯總了Java中org.jboss.security.RunAs類的典型用法代碼示例。如果您正苦於以下問題:Java RunAs類的具體用法?Java RunAs怎麽用?Java RunAs使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
RunAs類屬於org.jboss.security包,在下文中一共展示了RunAs類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: remove
import org.jboss.security.RunAs; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public <T> T remove(String key)
{
if(key == null)
throw PicketBoxMessages.MESSAGES.invalidNullArgument("key");
Map<String,Object> contextMap = securityContext.getData();
if(RUNAS_IDENTITY_IDENTIFIER.equals(key))
{
RunAs runAs = securityContext.getOutgoingRunAs();
//Move the caller RAI to current RAI
securityContext.setOutgoingRunAs((RunAs) contextMap.get(CALLER_RAI_IDENTIFIER));
//Clear the Caller RAI
contextMap.remove(CALLER_RAI_IDENTIFIER);
return (T) runAs;
}
return (T) contextMap.remove(key);
}
示例2: authorize
import org.jboss.security.RunAs; //導入依賴的package包/類
/**
* @see AuthorizationModuleDelegate#authorize(org.jboss.security.authorization.Resource, javax.security.auth.Subject, org.jboss.security.identity.RoleGroup)
*/
public int authorize(Resource resource, Subject callerSubject, RoleGroup role)
{
if(resource instanceof EJBResource == false)
throw PicketBoxMessages.MESSAGES.invalidType(EJBResource.class.getName());
EJBResource ejbResource = (EJBResource) resource;
//Get the context map
Map<String,Object> map = resource.getMap();
if(map == null)
throw PicketBoxMessages.MESSAGES.invalidNullProperty("resourceMap");
this.policyRegistration = (PolicyRegistration) map.get(ResourceKeys.POLICY_REGISTRATION);
this.ejbCS = ejbResource.getCodeSource();
this.ejbMethod = ejbResource.getEjbMethod();
this.ejbName = ejbResource.getEjbName();
this.methodInterface = ejbResource.getEjbMethodInterface();
RunAs runAs = ejbResource.getCallerRunAsIdentity();
if (runAs instanceof RunAsIdentity)
this.callerRunAs = RunAsIdentity.class.cast(runAs);
//isCallerInRole checks
this.roleName = (String)map.get(ResourceKeys.ROLENAME);
this.roleRefCheck = (Boolean)map.get(ResourceKeys.ROLEREF_PERM_CHECK);
if(this.roleRefCheck == Boolean.TRUE)
return checkRoleRef(callerSubject, role);
else
return process(callerSubject, role);
}
示例3: isTrusted
import org.jboss.security.RunAs; //導入依賴的package包/類
@Override
public TrustDecision isTrusted() throws IdentityTrustException
{
RunAs runAs = this.securityContext.getIncomingRunAs();
if(runAs instanceof RunAsIdentity )
{
RunAsIdentity runAsIdentity = (RunAsIdentity)runAs;
if(SecurityConstants.JAVAEE.equals(runAsIdentity.getProof()))
return TrustDecision.Permit;
}
return TrustDecision.NotApplicable;
}
示例4: getIncomingRunAs
import org.jboss.security.RunAs; //導入依賴的package包/類
static RunAs getIncomingRunAs(final SecurityContext sc)
{
return AccessController.doPrivileged(new PrivilegedAction<RunAs>()
{
public RunAs run()
{
return sc.getIncomingRunAs();
}
});
}
示例5: setRunAsIdentity
import org.jboss.security.RunAs; //導入依賴的package包/類
private void setRunAsIdentity(RunAsIdentity rai)
{
Map<String,Object> contextMap = securityContext.getData();
//Move the current RAI on the sc into the caller rai
RunAs currentRA = securityContext.getOutgoingRunAs();
contextMap.put(CALLER_RAI_IDENTIFIER, currentRA);
securityContext.setOutgoingRunAs(rai);
}
示例6: setIncomingRunAs
import org.jboss.security.RunAs; //導入依賴的package包/類
/**
* @see SecurityContext#setOutgoingRunAs(RunAs)
*
* @throws SecurityException Under a security manager, caller does not have
* RuntimePermission("org.jboss.security.plugins.JBossSecurityContext.setRunAsPermission")
*
*/
public void setIncomingRunAs(RunAs runAs)
{
SecurityManager sm = System.getSecurityManager();
if (sm != null)
sm.checkPermission(setRunAsPermission);
this.incomingRunAs = runAs;
}
示例7: setOutgoingRunAs
import org.jboss.security.RunAs; //導入依賴的package包/類
/**
* @see SecurityContext#setOutgoingRunAs(RunAs)
*
* @throws SecurityException Under a security manager, caller does not have
* RuntimePermission("org.jboss.security.plugins.JBossSecurityContext.setRunAsPermission")
*/
public void setOutgoingRunAs(RunAs runAs)
{
SecurityManager sm = System.getSecurityManager();
if (sm != null)
sm.checkPermission(setRunAsPermission);
this.outgoingRunAs = runAs;
}
示例8: testJavaEERunAsIdentity
import org.jboss.security.RunAs; //導入依賴的package包/類
@SuppressWarnings("unchecked")
public void testJavaEERunAsIdentity() throws Exception
{
JBossSecurityContext sc = new JBossSecurityContext("conf-javaee");
sc.setIncomingRunAs(new RunAsIdentity("theduke", "jduke"));
assertNotNull("SecurityContext is not null", sc);
IdentityTrustManager itm = sc.getIdentityTrustManager();
assertNotNull("IdentityTrustManager is not null", itm);
assertEquals("Is Trusted", TrustDecision.Permit, itm.isTrusted(sc));
sc.setIncomingRunAs(new RunAs()
{
public <T> T getIdentity()
{
return (T) "BAD";
}
public <T> T getProof()
{
return (T) "BAD";
}
public String getName()
{
return "BAD";
}
});
assertEquals("Is Trusted is false", TrustDecision.NotApplicable, itm.isTrusted(sc));
}
示例9: JBossContainerContext
import org.jboss.security.RunAs; //導入依賴的package包/類
private JBossContainerContext(org.jboss.security.SecurityContext securityContext, RoleGroup roleGroup, RunAs runAs) {
this._securityContext = securityContext;
this._roleGroup = roleGroup;
this._runAs = runAs;
}
示例10: run
import org.jboss.security.RunAs; //導入依賴的package包/類
public RunAs run()
{
return SecurityContextAssociation.peekRunAsIdentity();
}
示例11: peek
import org.jboss.security.RunAs; //導入依賴的package包/類
public RunAs peek()
{
return SecurityContextAssociation.peekRunAsIdentity();
}
示例12: getCallerRunAsIdentity
import org.jboss.security.RunAs; //導入依賴的package包/類
/**
* Get the Caller RunAsIdentity
* @return
*/
public RunAs getCallerRunAsIdentity()
{
return callerRunAsIdentity;
}
示例13: setCallerRunAsIdentity
import org.jboss.security.RunAs; //導入依賴的package包/類
/**
* Set the Caller RunAsIdentity
* @param callerRunAsIdentity
*/
public void setCallerRunAsIdentity(RunAs callerRunAsIdentity)
{
this.callerRunAsIdentity = callerRunAsIdentity;
}
示例14: getIncomingRunAs
import org.jboss.security.RunAs; //導入依賴的package包/類
/**
* @see SecurityContext#getOutgoingRunAs()
*/
public RunAs getIncomingRunAs()
{
return this.incomingRunAs;
}
示例15: getOutgoingRunAs
import org.jboss.security.RunAs; //導入依賴的package包/類
/**
* @see SecurityContext#getOutgoingRunAs()
*/
public RunAs getOutgoingRunAs()
{
return this.outgoingRunAs;
}