FileDocCategorySizeDatePackage
SampleAMSTSAuthorizationProvider.javaAPI DocExample4410Tue May 29 16:58:06 BST 2007common

SampleAMSTSAuthorizationProvider

public class SampleAMSTSAuthorizationProvider extends Object implements com.sun.xml.ws.api.security.trust.STSAuthorizationProvider

Fields Summary
private static com.iplanet.am.util.Debug
debug
Constructors Summary
Methods Summary
private static com.iplanet.sso.SSOTokengetSSOToken(javax.security.auth.Subject subject)


        
    
        Set pc = //subject.getPublicCredentials();
       // if (pc == null){
                SubjectAccessor.getRequesterSubject().getPublicCredentials();
        //}
        
        if (pc == null)
            System.out.println("No pc in the subject");
        
        if (pc != null){
            if (pc == null){
                pc = SubjectAccessor.getRequesterSubject().getPublicCredentials();
            }
            Iterator ite = pc.iterator();
            while (ite.hasNext()){
                Object obj = ite.next();
                if (obj instanceof com.iplanet.sso.SSOToken){
                    return (SSOToken)obj;
                }
            }
        }
        return null;
    
public booleanisAuthorized(javax.security.auth.Subject subject, java.lang.String appliesTo, java.lang.String tokenType, java.lang.String keyType)

        String serviceName = "iPlanetAMWebAgentService";
        String action = "POST";
        SSOToken token = getSSOToken(subject);

        try
        {
            debug.message("Authorizing access - SSOToken is "+token);
            debug.message("Checking policy for "+action+" on URL "+appliesTo);
            PolicyEvaluator pe = new PolicyEvaluator(serviceName);
            debug.message("Got PolicyEvaluator for "+serviceName);
            boolean isAllowed = pe.isAllowed(token, appliesTo, action);
            debug.message("Access " + (isAllowed ? "is" : "is not" ) + " allowed");
            return isAllowed;
        }
        catch ( PolicyException pe )
        {
            debug.error("Exception evaluating policy", pe);
        }
        catch ( SSOException ssoe )
        {
            debug.error("Exception evaluating policy", ssoe);
        }

        return false;