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.authorization;
 
 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 ROLES = "roles";
 
     public QName getArtifactType() {
         return .;
     }
 
     public AuthorizationPolicyProcessor(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);
         }        
     }    
 
         AuthorizationPolicy policy = new AuthorizationPolicy();
         int event = reader.getEventType();
         QName start = reader.getName();
         while (true) {
             switch (event) {
                 case :
                     String ac = reader.getName().getLocalPart();
                     if ("allow".equals(ac)) {
                         policy.setAccessControl(..);
                         String roleNames = reader.getAttributeValue(null);
                         if (roleNames == null) {
                             error(context.getMonitor(), "RequiredAttributeRolesMissing"reader);
                             //throw new IllegalArgumentException("Required attribute 'roles' is missing.");
                         } else {
                             StringTokenizer st = new StringTokenizer(roleNames);
                             while (st.hasMoreTokens()) {
                                 policy.getRoleNames().add(st.nextToken());
                             }
                         }
                     } else if ("permitAll".equals(ac)) {
                         policy.setAccessControl(..);
                     } else if ("denyAll".endsWith(ac)) {
                         policy.setAccessControl(..);
                     }
                     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(AuthorizationPolicy policyXMLStreamWriter writerProcessorContext contextthrows ContributionWriteException,
        XMLStreamException {
        writer.writeStartElement(policy.getAccessControl().name());
        if (policy.getAccessControl() == ..) {
            StringBuffer sb = new StringBuffer();
            for (String role : policy.getRoleNames()) {
                sb.append(role);
            }
            if (sb.length() > 0) {
                writer.writeAttribute(sb.toString());
            }
        }
        writer.writeEndElement();
        writer.writeEndElement();
    }
        return AuthorizationPolicy.class;
    }
    public void resolve(AuthorizationPolicy policyModelResolver resolverProcessorContext contextthrows ContributionResolveException {
        
        if ((policy.getAccessControl() == ..) &&
            (policy.getRoleNames().isEmpty())){
            // role names are required so leave policy unresolved
            return;
        }
        //right now nothing to resolve
        policy.setUnresolved(false);
    }
New to GrepCode? Check out our FAQ X