Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Licensed to the Apache Software Foundation (ASF) under one
   * or more contributor license agreements.  See the NOTICE file
   * distributed with this work for additional information
   * regarding copyright ownership.  The ASF licenses this file
   * to you under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
  * 
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.    
  */
 package org.apache.tuscany.sca.policy.identity;
 
 import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
 import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
 
 

Version:
$Rev: 825773 $ $Date: 2009-10-16 08:42:26 +0300 (Fri, 16 Oct 2009) $
 
     private static final String ROLE = "role";
 
     public QName getArtifactType() {
         return .;
     }
 
     public SecurityIdentityPolicyProcessor(FactoryExtensionPoint modelFactories) {
     }

    
Report a error.

Parameters:
problems
message
model
 
     private void error(Monitor monitorString messageObject modelObject... messageParameters) {
         if (monitor != null) {
             Problem problem = monitor.createProblem(this.getClass().getName(), "policy-security-validation-messages".modelmessage, (Object[])messageParameters);
             monitor.problem(problem);
         }        
     }    
 
         SecurityIdentityPolicy policy = new SecurityIdentityPolicy();
         int event = reader.getEventType();
         QName start = reader.getName();
         while (true) {
             switch (event) {
                 case :
                     String ac = reader.getName().getLocalPart();
                     if ("runAs".equals(ac)) {
                         String roleName = reader.getAttributeValue(null);
                         if (roleName == null) {
                             error(context.getMonitor(), "RequiredAttributeRolesMissing"reader);
                             //throw new IllegalArgumentException("Required attribute 'roles' is missing.");
                         } else {
                             policy.setRunAsRole(roleName);
                         }
                     } else if ("useCallerIdentity".equals(ac)) {
                         policy.setUseCallerIdentity(true);
                     }
                     break;
                 case :
                     if (start.equals(reader.getName())) {
                         if (reader.hasNext()) {
                             reader.next();
                         }
                         return policy;
                     }
 
             }
             if (reader.hasNext()) {
                 event = reader.next();
             } else {
                return policy;
            }
        }
    }
    public void write(SecurityIdentityPolicy policyXMLStreamWriter writerProcessorContext contextthrows ContributionWriteException,
        String child = policy.isUseCallerIdentity() ? "useCallerIdentity" : "runAs";
        writer.writeStartElement(child);
        if (!policy.isUseCallerIdentity()) {
            writer.writeAttribute(policy.getRunAsRole());
        }
        writer.writeEndElement();
        writer.writeEndElement();
    }
        return SecurityIdentityPolicy.class;
    }
    public void resolve(SecurityIdentityPolicy policyModelResolver resolverProcessorContext contextthrows ContributionResolveException {
        
    	if (policy.getRunAsRole() != null)
    	    //right now nothing to resolve
            policy.setUnresolved(false);
    }
New to GrepCode? Check out our FAQ X