alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Axis 2 example source code file (PolicyExtensionTemplate.xsl)

This example Axis 2 source code file (PolicyExtensionTemplate.xsl) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Axis 2 tags/keywords

apache, apache, asf, asf, foundation, license, license, passwordtext, sandesha2clientapipropertywsrmlastmessage, see, see, string, unrecognized, you

The Axis 2 PolicyExtensionTemplate.xsl source code


<!--
  ~ 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.
  -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:template match="module-codegen-policy-extensions">
        
        <xsl:if test="//createSequence">
        /**
         * Starts a reliabel message sequence
         */
        public void startSequence() {
            _getServiceClient().getOptions().setProperty("START_RM_SEQUENCE", "true");            
        }
        </xsl:if>
        
        <xsl:if test="//setLastMessage">
        /**
         * Marks the last message for the sequence
         */
         public void setLastMessage() {
             _getServiceClient().getOptions().setProperty("Sandesha2ClientAPIPropertyWSRMLastMessage", "true");
         }
        </xsl:if>
        
        <xsl:if test="//endSequence">
        /**
         * Terminates the reliabel message sequence
         */
        public void endSequence() {
            _getServiceClient().getOptions().setProperty("END_RM_SEQUENCE", "true");
        }
        </xsl:if>
        
        <xsl:variable name="optimized">
            <xsl:value-of select="//optimizeContent"/>
        </xsl:variable>
        
        
        <xsl:if test="//security-codegen-policy-extensions/usernametoken-action">
    // auto genenrated stub methods 
    
    public void setUsername(java.lang.String username) {
        _serviceClient.getOptions().setProperty(org.apache.ws.security.handler.WSHandlerConstants.USER, username);
    }

    public void setPassword(java.lang.String password) {
        _UTCallback pwCallback = new _UTCallback();
        pwCallback.setPassword(password);
    _serviceClient
                .getOptions()
                .setProperty(
                        org.apache.ws.security.handler.WSHandlerConstants.PASSWORD_TYPE,
                        "PasswordText");
        _serviceClient
                .getOptions()
                .setProperty(
                        org.apache.ws.security.handler.WSHandlerConstants.PW_CALLBACK_REF,
                        pwCallback);    }

    private class _UTCallback implements
            javax.security.auth.callback.CallbackHandler {

        private java.lang.String password;

        public _UTCallback() {
        }

        public void setPassword(java.lang.String password) {
            this.password = password;
        }

        public void handle(javax.security.auth.callback.Callback[] callbacks)

        throws java.io.IOException,
                javax.security.auth.callback.UnsupportedCallbackException {

            for (int i = 0; i < callbacks.length; i++) {

                if (callbacks[i] instanceof org.apache.ws.security.WSPasswordCallback) {

                    org.apache.ws.security.WSPasswordCallback pc = (org.apache.ws.security.WSPasswordCallback) callbacks[i];

                    if (pc.getIdentifer().equals(getUsername())) {
                        pc.setPassword(password);

                    } else {
                        pc.setPassword(password);
                    }

                } else {

                    throw new javax.security.auth.callback.UnsupportedCallbackException(
                            callbacks[i], "Unrecognized Callback");
                }
            }
        }

        private java.lang.String getUsername() {
            return (String) _serviceClient.getOptions().getProperty(
                    org.apache.ws.security.handler.WSHandlerConstants.USER);
        }
    }
        </xsl:if>
        

        <xsl:choose>
            <xsl:when test="$optimized">
            private void setOpNameArray(){
            opNameArray = new javax.xml.namespace.QName[] {
            <xsl:for-each select="optimizeContent/opName">
                <xsl:if test="position()>1">,
                </xsl:if>new javax.xml.namespace.QName("","")
            </xsl:for-each>
            };
           }
           </xsl:when>
            <xsl:otherwise>
            private void setOpNameArray(){
            opNameArray = null;
            }
           </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
</xsl:stylesheet>

Other Axis 2 examples (source code examples)

Here is a short list of links related to this Axis 2 PolicyExtensionTemplate.xsl source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.