FileDocCategorySizeDatePackage
JMXSubjectDomainCombiner.javaAPI DocJava SE 6 API3315Tue Jun 10 00:22:04 BST 2008com.sun.jmx.remote.security

JMXSubjectDomainCombiner

public class JMXSubjectDomainCombiner extends SubjectDomainCombiner

This class represents an extension to the {@link SubjectDomainCombiner} and is used to add a new {@link ProtectionDomain}, comprised of a null codesource/signers and an empty permission set, to the access control context with which this combiner is combined.

When the {@link #combine} method is called the {@link ProtectionDomain} is augmented with the permissions granted to the set of principals present in the supplied {@link Subject}.

Fields Summary
private static final CodeSource
nullCodeSource
A null CodeSource.
private static final ProtectionDomain
pdNoPerms
A ProtectionDomain with a null CodeSource and an empty permission set.
Constructors Summary
public JMXSubjectDomainCombiner(Subject s)

        super(s);
    
Methods Summary
public java.security.ProtectionDomain[]combine(java.security.ProtectionDomain[] current, java.security.ProtectionDomain[] assigned)

        // Add a new ProtectionDomain with the null codesource/signers, and
        // the empty permission set, to the end of the array containing the
	// 'current' protections domains, i.e. the ones that will be augmented
	// with the permissions granted to the set of principals present in
	// the supplied subject.
	//
        ProtectionDomain[] newCurrent;
        if (current == null || current.length == 0) {
            newCurrent = new ProtectionDomain[1];
            newCurrent[0] = pdNoPerms;
        } else {
            newCurrent = new ProtectionDomain[current.length + 1];
            for (int i = 0; i < current.length; i++) {
                newCurrent[i] = current[i];
            }
            newCurrent[current.length] = pdNoPerms;          
        }
        return super.combine(newCurrent, assigned);
    
public static java.security.AccessControlContextgetContext(javax.security.auth.Subject subject)
Get the current AccessControlContext combined with the supplied subject.


                  
         
        return new AccessControlContext(AccessController.getContext(),
                                        new JMXSubjectDomainCombiner(subject));
    
public static java.security.AccessControlContextgetDomainCombinerContext(javax.security.auth.Subject subject)
Get the AccessControlContext of the domain combiner created with the supplied subject, i.e. an AccessControlContext with the domain combiner created with the supplied subject and where the caller's context has been removed.

        return new AccessControlContext(
            new AccessControlContext(new ProtectionDomain[0]),
            new JMXSubjectDomainCombiner(subject));