Source Code Cross Referenced for ProprietarySecurityPolicyModelHelper.java in  » IDE-Netbeans » web.core » org » netbeans » modules » websvc » wsitconf » wsdlmodelext » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » web.core » org.netbeans.modules.websvc.wsitconf.wsdlmodelext 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
0003:         *
0004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
0005:         *
0006:         * The contents of this file are subject to the terms of either the GNU
0007:         * General Public License Version 2 only ("GPL") or the Common
0008:         * Development and Distribution License("CDDL") (collectively, the
0009:         * "License"). You may not use this file except in compliance with the
0010:         * License. You can obtain a copy of the License at
0011:         * http://www.netbeans.org/cddl-gplv2.html
0012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
0013:         * specific language governing permissions and limitations under the
0014:         * License.  When distributing the software, include this License Header
0015:         * Notice in each file and include the License file at
0016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
0017:         * particular file as subject to the "Classpath" exception as provided
0018:         * by Sun in the GPL Version 2 section of the License file that
0019:         * accompanied this code. If applicable, add the following below the
0020:         * License Header, with the fields enclosed by brackets [] replaced by
0021:         * your own identifying information:
0022:         * "Portions Copyrighted [year] [name of copyright owner]"
0023:         *
0024:         * Contributor(s):
0025:         *
0026:         * The Original Software is NetBeans. The Initial Developer of the Original
0027:         * Software is Sun Microsystems, Inc. Portions Copyright 2006 Sun
0028:         * Microsystems, Inc. All Rights Reserved.
0029:         *
0030:         * If you wish your version of this file to be governed by only the CDDL
0031:         * or only the GPL Version 2, indicate your decision by adding
0032:         * "[Contributor] elects to include this software in this distribution
0033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
0034:         * single choice of license, a recipient has the option to distribute
0035:         * your version of this file under either the CDDL, the GPL Version 2 or
0036:         * to extend the choice of license to its licensees as provided above.
0037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
0038:         * Version 2 license, then the option applies only if the new code is
0039:         * made subject to such option by the copyright holder.
0040:         */
0041:
0042:        package org.netbeans.modules.websvc.wsitconf.wsdlmodelext;
0043:
0044:        import org.netbeans.modules.websvc.wsitconf.ui.security.listmodels.ServiceProviderElement;
0045:        import org.netbeans.modules.websvc.wsitmodelext.policy.All;
0046:        import org.netbeans.modules.websvc.wsitmodelext.policy.Policy;
0047:        import org.netbeans.modules.websvc.wsitmodelext.security.proprietary.ProprietaryPolicyQName;
0048:        import org.netbeans.modules.websvc.wsitmodelext.security.proprietary.Timestamp;
0049:        import org.netbeans.modules.websvc.wsitmodelext.security.proprietary.Validator;
0050:        import org.netbeans.modules.websvc.wsitmodelext.security.proprietary.ValidatorConfiguration;
0051:        import org.netbeans.modules.websvc.wsitmodelext.security.proprietary.service.CertAlias;
0052:        import org.netbeans.modules.websvc.wsitmodelext.security.proprietary.service.Contract;
0053:        import org.netbeans.modules.websvc.wsitmodelext.security.proprietary.service.Issuer;
0054:        import org.netbeans.modules.websvc.wsitmodelext.security.proprietary.service.KeyType;
0055:        import org.netbeans.modules.websvc.wsitmodelext.security.proprietary.service.ProprietarySCServiceQName;
0056:        import org.netbeans.modules.websvc.wsitmodelext.security.proprietary.service.ProprietarySecurityPolicyServiceQName;
0057:        import org.netbeans.modules.websvc.wsitmodelext.security.proprietary.service.ProprietaryTrustServiceQName;
0058:        import org.netbeans.modules.websvc.wsitmodelext.security.proprietary.service.SCConfiguration;
0059:        import org.netbeans.modules.websvc.wsitmodelext.security.proprietary.service.STSConfiguration;
0060:        import org.netbeans.modules.websvc.wsitmodelext.security.proprietary.service.ServiceProviders;
0061:        import org.netbeans.modules.websvc.wsitmodelext.security.proprietary.service.TokenType;
0062:        import org.netbeans.modules.websvc.wsitmodelext.security.proprietary.CallbackHandler;
0063:        import org.netbeans.modules.websvc.wsitmodelext.security.proprietary.CallbackHandlerConfiguration;
0064:        import org.netbeans.modules.websvc.wsitmodelext.security.proprietary.KeyStore;
0065:        import org.netbeans.modules.websvc.wsitmodelext.security.proprietary.LifeTime;
0066:        import org.netbeans.modules.websvc.wsitmodelext.security.proprietary.PreconfiguredSTS;
0067:        import org.netbeans.modules.websvc.wsitmodelext.security.proprietary.ProprietarySCClientQName;
0068:        import org.netbeans.modules.websvc.wsitmodelext.security.proprietary.ProprietarySecurityPolicyQName;
0069:        import org.netbeans.modules.websvc.wsitmodelext.security.proprietary.ProprietaryTrustClientQName;
0070:        import org.netbeans.modules.websvc.wsitmodelext.security.proprietary.SCClientConfiguration;
0071:        import org.netbeans.modules.websvc.wsitmodelext.security.proprietary.TrustStore;
0072:        import org.netbeans.modules.xml.wsdl.model.*;
0073:        import java.util.List;
0074:        import org.netbeans.modules.websvc.wsitconf.ui.ComboConstants;
0075:        import org.netbeans.modules.websvc.wsitmodelext.security.proprietary.service.DisableStreamingSecurity;
0076:        import org.netbeans.modules.websvc.wsitmodelext.security.proprietary.service.ServiceProvider;
0077:
0078:        /**
0079:         *
0080:         * @author Martin Grebac
0081:         */
0082:        public class ProprietarySecurityPolicyModelHelper {
0083:
0084:            public static final String DEFAULT_LIFETIME = "300000"; //NOI18N
0085:            public static final String DEFAULT_CONTRACT_CLASS = "com.sun.xml.ws.trust.impl.IssueSamlTokenContractImpl"; //NOI18N
0086:            public static final String DEFAULT_HANDLER_TIMESTAMP_TIMEOUT = "300"; //NOI18N
0087:            public static final String DEFAULT_MAXCLOCKSKEW = "300000"; //NOI18N
0088:            public static final String DEFAULT_TIMESTAMPFRESHNESS = "300000"; //NOI18N
0089:
0090:            /**
0091:             * Creates a new instance of ProprietarySecurityPolicyModelHelper
0092:             */
0093:            public ProprietarySecurityPolicyModelHelper() {
0094:            }
0095:
0096:            //    public static String getMaxNonceAge(Binding b, boolean client) {
0097:            //        WSDLModel model = b.getModel();
0098:            //        Policy p = PolicyModelHelper.getPolicyForElement(b);
0099:            //        ValidatorConfiguration vc = (ValidatorConfiguration) PolicyModelHelper.getTopLevelElement(p, ValidatorConfiguration.class);
0100:            //        if (vc != null) {
0101:            //            return vc.getMaxNonceAge();
0102:            //        }
0103:            //        return null;
0104:            //    }
0105:
0106:            public static String getSTSLifeTime(Binding b) {
0107:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0108:                WSDLComponent sc = getSTSConfiguration(p);
0109:                if (sc != null) {
0110:                    List<LifeTime> elems = sc
0111:                            .getExtensibilityElements(LifeTime.class);
0112:                    if ((elems != null) && (!elems.isEmpty())) {
0113:                        return elems.get(0).getLifeTime();
0114:                    }
0115:                }
0116:                return null;
0117:            }
0118:
0119:            public static String getSTSIssuer(Binding b) {
0120:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0121:                WSDLComponent sc = getSTSConfiguration(p);
0122:                if (sc != null) {
0123:                    List<Issuer> elems = sc
0124:                            .getExtensibilityElements(Issuer.class);
0125:                    if ((elems != null) && (!elems.isEmpty())) {
0126:                        return elems.get(0).getIssuer();
0127:                    }
0128:                }
0129:                return null;
0130:            }
0131:
0132:            public static STSConfiguration getSTSConfiguration(Binding b) {
0133:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0134:                return getSTSConfiguration(p);
0135:            }
0136:
0137:            public static String getSTSContractClass(Binding b) {
0138:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0139:                WSDLComponent sc = getSTSConfiguration(p);
0140:                if (sc != null) {
0141:                    List<Contract> elems = sc
0142:                            .getExtensibilityElements(Contract.class);
0143:                    if ((elems != null) && (!elems.isEmpty())) {
0144:                        return elems.get(0).getContract();
0145:                    }
0146:                }
0147:                return null;
0148:            }
0149:
0150:            public static boolean getSTSEncryptKey(Binding b) {
0151:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0152:                STSConfiguration sc = getSTSConfiguration(p);
0153:                if (sc != null) {
0154:                    return sc.isEncryptIssuedKey();
0155:                }
0156:                return false;
0157:            }
0158:
0159:            public static boolean getSTSEncryptToken(Binding b) {
0160:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0161:                STSConfiguration sc = getSTSConfiguration(p);
0162:                if (sc != null) {
0163:                    return sc.isEncryptIssuedToken();
0164:                }
0165:                return false;
0166:            }
0167:
0168:            public static String getSPCertAlias(ServiceProvider sp) {
0169:                if (sp != null) {
0170:                    List<CertAlias> elems = sp
0171:                            .getExtensibilityElements(CertAlias.class);
0172:                    if ((elems != null) && !(elems.isEmpty())) {
0173:                        return elems.get(0).getCertAlias();
0174:                    }
0175:                }
0176:                return null;
0177:            }
0178:
0179:            public static String getSPTokenType(ServiceProvider sp) {
0180:                if (sp != null) {
0181:                    List<TokenType> elems = sp
0182:                            .getExtensibilityElements(TokenType.class);
0183:                    if ((elems != null) && !(elems.isEmpty())) {
0184:                        String tType = elems.get(0).getTokenType();
0185:                        if (tType != null) {
0186:                            if (ComboConstants.ISSUED_TOKENTYPE_SAML10_POLICYSTR
0187:                                    .equals(tType)) {
0188:                                return ComboConstants.ISSUED_TOKENTYPE_SAML10;
0189:                            }
0190:                            if (ComboConstants.ISSUED_TOKENTYPE_SAML11_POLICYSTR
0191:                                    .equals(tType)) {
0192:                                return ComboConstants.ISSUED_TOKENTYPE_SAML11;
0193:                            }
0194:                            if (ComboConstants.ISSUED_TOKENTYPE_SAML20_POLICYSTR
0195:                                    .equals(tType)) {
0196:                                return ComboConstants.ISSUED_TOKENTYPE_SAML20;
0197:                            }
0198:                        }
0199:                    }
0200:                }
0201:                return null;
0202:            }
0203:
0204:            public static String getSPKeyType(ServiceProvider sp) {
0205:                if (sp != null) {
0206:                    List<KeyType> elems = sp
0207:                            .getExtensibilityElements(KeyType.class);
0208:                    if ((elems != null) && !(elems.isEmpty())) {
0209:                        String kType = elems.get(0).getKeyType();
0210:                        if (kType != null) {
0211:                            if (ComboConstants.ISSUED_KEYTYPE_PUBLIC_POLICYSTR
0212:                                    .equals(kType)) {
0213:                                return ComboConstants.ISSUED_KEYTYPE_PUBLIC;
0214:                            }
0215:                            if (ComboConstants.ISSUED_KEYTYPE_SYMMETRIC_POLICYSTR
0216:                                    .equals(kType)) {
0217:                                return ComboConstants.ISSUED_KEYTYPE_SYMMETRIC;
0218:                            }
0219:                        }
0220:                    }
0221:                }
0222:                return null;
0223:            }
0224:
0225:            public static List<ServiceProvider> getSTSServiceProviders(Binding b) {
0226:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0227:                WSDLComponent sc = getSTSConfiguration(p);
0228:                return getSTSServiceProviders((STSConfiguration) sc);
0229:            }
0230:
0231:            public static List<ServiceProvider> getSTSServiceProviders(
0232:                    STSConfiguration stsConfig) {
0233:                if (stsConfig != null) {
0234:                    List<ServiceProviders> elems = stsConfig
0235:                            .getExtensibilityElements(ServiceProviders.class);
0236:                    if ((elems != null) && (!elems.isEmpty())) {
0237:                        List<ServiceProvider> sps = elems
0238:                                .get(0)
0239:                                .getExtensibilityElements(ServiceProvider.class);
0240:                        return sps;
0241:                    }
0242:                }
0243:                return null;
0244:            }
0245:
0246:            public static String getLifeTime(Binding b, boolean client) {
0247:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0248:                WSDLComponent sc = null;
0249:                if (client) {
0250:                    sc = getSCClientConfiguration(p);
0251:                } else {
0252:                    sc = getSCConfiguration(p);
0253:                }
0254:                if (sc != null) {
0255:                    List<LifeTime> elems = sc
0256:                            .getExtensibilityElements(LifeTime.class);
0257:                    if ((elems != null) && (!elems.isEmpty())) {
0258:                        return elems.get(0).getLifeTime();
0259:                    }
0260:                }
0261:                return null;
0262:            }
0263:
0264:            public static String getTimestampTimeout(WSDLComponent b,
0265:                    boolean client) {
0266:                if (b == null)
0267:                    return null;
0268:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0269:                if (p == null)
0270:                    return null;
0271:                Timestamp t = PolicyModelHelper.getTopLevelElement(p,
0272:                        Timestamp.class);
0273:                return t == null ? null : t.getTimeout();
0274:            }
0275:
0276:            public static String getPreSTSEndpoint(Binding b) {
0277:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0278:                PreconfiguredSTS ps = getPreconfiguredSTS(p);
0279:                if (ps != null) {
0280:                    return ps.getEndpoint();
0281:                }
0282:                return null;
0283:            }
0284:
0285:            public static String getPreSTSMetadata(Binding b) {
0286:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0287:                PreconfiguredSTS ps = getPreconfiguredSTS(p);
0288:                if (ps != null) {
0289:                    return ps.getMetadata();
0290:                }
0291:                return null;
0292:            }
0293:
0294:            public static String getPreSTSNamespace(Binding b) {
0295:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0296:                PreconfiguredSTS ps = getPreconfiguredSTS(p);
0297:                if (ps != null) {
0298:                    return ps.getNamespace();
0299:                }
0300:                return null;
0301:            }
0302:
0303:            public static String getPreSTSPortName(Binding b) {
0304:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0305:                PreconfiguredSTS ps = getPreconfiguredSTS(p);
0306:                if (ps != null) {
0307:                    return ps.getPortName();
0308:                }
0309:                return null;
0310:            }
0311:
0312:            public static String getPreSTSServiceName(Binding b) {
0313:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0314:                PreconfiguredSTS ps = getPreconfiguredSTS(p);
0315:                if (ps != null) {
0316:                    return ps.getServiceName();
0317:                }
0318:                return null;
0319:            }
0320:
0321:            public static String getPreSTSWsdlLocation(Binding b) {
0322:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0323:                PreconfiguredSTS ps = getPreconfiguredSTS(p);
0324:                if (ps != null) {
0325:                    return ps.getWsdlLocation();
0326:                }
0327:                return null;
0328:            }
0329:
0330:            public static boolean isRenewExpired(Binding b) {
0331:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0332:                SCClientConfiguration sc = getSCClientConfiguration(p);
0333:                if (sc != null) {
0334:                    return sc.isRenewExpiredSCT();
0335:                }
0336:                return false;
0337:            }
0338:
0339:            public static boolean isRequireCancel(Binding b) {
0340:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0341:                SCClientConfiguration sc = getSCClientConfiguration(p);
0342:                if (sc != null) {
0343:                    return sc.isRequireCancelSCT();
0344:                }
0345:                return false;
0346:            }
0347:
0348:            public static boolean isRevocationEnabled(Binding b) {
0349:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0350:                ValidatorConfiguration vc = (ValidatorConfiguration) PolicyModelHelper
0351:                        .getTopLevelElement(p, ValidatorConfiguration.class);
0352:                if (vc != null) {
0353:                    return vc.isRevocationEnabled();
0354:                }
0355:                return false;
0356:            }
0357:
0358:            public static boolean isStreamingSecurity(Binding b) {
0359:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0360:                DisableStreamingSecurity streaming = PolicyModelHelper
0361:                        .getTopLevelElement(p, DisableStreamingSecurity.class);
0362:                return (streaming == null) ? true : false;
0363:            }
0364:
0365:            public static void setStreamingSecurity(Binding b, boolean enable) {
0366:                if (enable == isStreamingSecurity(b))
0367:                    return;
0368:                if (!enable) {
0369:                    All a = PolicyModelHelper.createPolicy(b, true);
0370:                    PolicyModelHelper
0371:                            .createElement(
0372:                                    a,
0373:                                    ProprietarySecurityPolicyServiceQName.DISABLESTREAMINGSECURITY
0374:                                            .getQName(),
0375:                                    DisableStreamingSecurity.class, false);
0376:                } else {
0377:                    Policy p = PolicyModelHelper.getPolicyForElement(b);
0378:                    DisableStreamingSecurity streaming = PolicyModelHelper
0379:                            .getTopLevelElement(p,
0380:                                    DisableStreamingSecurity.class);
0381:                    if (streaming != null) {
0382:                        PolicyModelHelper.removeElement(streaming.getParent(),
0383:                                DisableStreamingSecurity.class, false);
0384:                    }
0385:                    PolicyModelHelper.cleanPolicies(b);
0386:                }
0387:            }
0388:
0389:            public static String getMaxClockSkew(Binding b) {
0390:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0391:                ValidatorConfiguration vc = (ValidatorConfiguration) PolicyModelHelper
0392:                        .getTopLevelElement(p, ValidatorConfiguration.class);
0393:                if (vc != null) {
0394:                    return vc.getMaxClockSkew();
0395:                }
0396:                return null;
0397:            }
0398:
0399:            public static String getTimestampFreshness(Binding b) {
0400:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0401:                ValidatorConfiguration vc = (ValidatorConfiguration) PolicyModelHelper
0402:                        .getTopLevelElement(p, ValidatorConfiguration.class);
0403:                if (vc != null) {
0404:                    return vc.getTimestampFreshnessLimit();
0405:                }
0406:                return null;
0407:            }
0408:
0409:            public static WSDLComponent getStore(Policy p, boolean trust) {
0410:                if (trust) {
0411:                    return PolicyModelHelper.getTopLevelElement(p,
0412:                            TrustStore.class);
0413:                } else {
0414:                    return PolicyModelHelper.getTopLevelElement(p,
0415:                            KeyStore.class);
0416:                }
0417:            }
0418:
0419:            public static CallbackHandlerConfiguration getCBHConfiguration(
0420:                    Binding b) {
0421:                if (b == null)
0422:                    return null;
0423:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0424:                if (p == null)
0425:                    return null;
0426:                CallbackHandlerConfiguration chc = (CallbackHandlerConfiguration) PolicyModelHelper
0427:                        .getTopLevelElement(p,
0428:                                CallbackHandlerConfiguration.class);
0429:                return chc;
0430:            }
0431:
0432:            public static SCClientConfiguration getSCClientConfiguration(
0433:                    Policy p) {
0434:                return (SCClientConfiguration) PolicyModelHelper
0435:                        .getTopLevelElement(p, SCClientConfiguration.class);
0436:            }
0437:
0438:            public static PreconfiguredSTS getPreconfiguredSTS(Policy p) {
0439:                return (PreconfiguredSTS) PolicyModelHelper.getTopLevelElement(
0440:                        p, PreconfiguredSTS.class);
0441:            }
0442:
0443:            public static STSConfiguration getSTSConfiguration(Policy p) {
0444:                return (STSConfiguration) PolicyModelHelper.getTopLevelElement(
0445:                        p, STSConfiguration.class);
0446:            }
0447:
0448:            public static SCConfiguration getSCConfiguration(Policy p) {
0449:                return (SCConfiguration) PolicyModelHelper.getTopLevelElement(
0450:                        p, SCConfiguration.class);
0451:            }
0452:
0453:            /** Gets store location value for specified Binding or BindingOperation 
0454:             */
0455:            public static String getStoreLocation(WSDLComponent b, boolean trust) {
0456:                if (b == null)
0457:                    return null;
0458:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0459:                if (p == null)
0460:                    return null;
0461:                if (trust) {
0462:                    TrustStore ts = (TrustStore) getStore(p, true);
0463:                    return ts == null ? null : ts.getLocation();
0464:                } else {
0465:                    KeyStore ks = (KeyStore) getStore(p, false);
0466:                    return ks == null ? null : ks.getLocation();
0467:                }
0468:            }
0469:
0470:            public static String getStoreAlias(WSDLComponent b, boolean trust) {
0471:                if (b == null)
0472:                    return null;
0473:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0474:                if (p == null)
0475:                    return null;
0476:                if (trust) {
0477:                    TrustStore ts = (TrustStore) getStore(p, trust);
0478:                    return (ts != null) ? ts.getPeerAlias() : null;
0479:                } else {
0480:                    KeyStore ks = (KeyStore) getStore(p, trust);
0481:                    return (ks != null) ? ks.getAlias() : null;
0482:                }
0483:            }
0484:
0485:            public static String getStoreType(WSDLComponent b, boolean trust) {
0486:                if (b == null)
0487:                    return null;
0488:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0489:                if (p == null)
0490:                    return null;
0491:                if (trust) {
0492:                    TrustStore ts = (TrustStore) getStore(p, trust);
0493:                    return (ts != null) ? ts.getType() : null;
0494:                } else {
0495:                    KeyStore ks = (KeyStore) getStore(p, trust);
0496:                    return (ks != null) ? ks.getType() : null;
0497:                }
0498:            }
0499:
0500:            public static String getTrustSTSAlias(Binding b) {
0501:                if (b == null)
0502:                    return null;
0503:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0504:                if (p == null)
0505:                    return null;
0506:                TrustStore ks = (TrustStore) getStore(p, true);
0507:                return (ks != null) ? ks.getSTSAlias() : null;
0508:            }
0509:
0510:            public static String getTrustPeerAlias(WSDLComponent b) {
0511:                if (b == null)
0512:                    return null;
0513:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0514:                if (p == null)
0515:                    return null;
0516:                TrustStore ks = (TrustStore) getStore(p, true);
0517:                return (ks != null) ? ks.getPeerAlias() : null;
0518:            }
0519:
0520:            public static String getValidator(WSDLComponent c,
0521:                    String validatorType) {
0522:                if (c == null)
0523:                    return null;
0524:                Policy p = PolicyModelHelper.getPolicyForElement(c);
0525:                if (p == null)
0526:                    return null;
0527:                ValidatorConfiguration vc = (ValidatorConfiguration) PolicyModelHelper
0528:                        .getTopLevelElement(p, ValidatorConfiguration.class);
0529:                Validator v = getValidator(validatorType, vc);
0530:                if (v != null) {
0531:                    return v.getClassname();
0532:                }
0533:                return null;
0534:            }
0535:
0536:            private static Validator getValidator(String type,
0537:                    ValidatorConfiguration vc) {
0538:                if (vc == null)
0539:                    return null;
0540:                List<Validator> validators = vc
0541:                        .getExtensibilityElements(Validator.class);
0542:                for (Validator v : validators) {
0543:                    if (type.equals(v.getName())) {
0544:                        return v;
0545:                    }
0546:                }
0547:                return null;
0548:            }
0549:
0550:            private static LifeTime getLifeTime(WSDLComponent c) {
0551:                if (c != null) {
0552:                    List<LifeTime> attrs = c
0553:                            .getExtensibilityElements(LifeTime.class);
0554:                    if ((attrs != null) && !(attrs.isEmpty())) {
0555:                        return attrs.get(0);
0556:                    }
0557:                }
0558:                return null;
0559:            }
0560:
0561:            private static Issuer getIssuer(WSDLComponent c) {
0562:                if (c != null) {
0563:                    List<Issuer> attrs = c
0564:                            .getExtensibilityElements(Issuer.class);
0565:                    if ((attrs != null) && !(attrs.isEmpty())) {
0566:                        return attrs.get(0);
0567:                    }
0568:                }
0569:                return null;
0570:            }
0571:
0572:            private static Contract getContract(WSDLComponent c) {
0573:                if (c != null) {
0574:                    List<Contract> attrs = c
0575:                            .getExtensibilityElements(Contract.class);
0576:                    if ((attrs != null) && !(attrs.isEmpty())) {
0577:                        return attrs.get(0);
0578:                    }
0579:                }
0580:                return null;
0581:            }
0582:
0583:            public static String getDefaultUsername(Binding b) {
0584:                if (b == null)
0585:                    return null;
0586:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0587:                if (p == null)
0588:                    return null;
0589:                CallbackHandlerConfiguration chc = (CallbackHandlerConfiguration) PolicyModelHelper
0590:                        .getTopLevelElement(p,
0591:                                CallbackHandlerConfiguration.class);
0592:                CallbackHandler ch = getCallbackHandler(
0593:                        CallbackHandler.USERNAME_CBHANDLER, chc);
0594:                if (ch != null) {
0595:                    return ch.getDefault();
0596:                }
0597:                return null;
0598:            }
0599:
0600:            public static String getDefaultPassword(Binding b) {
0601:                if (b == null)
0602:                    return null;
0603:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0604:                if (p == null)
0605:                    return null;
0606:                CallbackHandlerConfiguration chc = (CallbackHandlerConfiguration) PolicyModelHelper
0607:                        .getTopLevelElement(p,
0608:                                CallbackHandlerConfiguration.class);
0609:                CallbackHandler ch = getCallbackHandler(
0610:                        CallbackHandler.PASSWORD_CBHANDLER, chc);
0611:                if (ch != null) {
0612:                    return ch.getDefault();
0613:                }
0614:                return null;
0615:            }
0616:
0617:            public static String getCallbackHandler(Binding b, String cbhType) {
0618:                if (b == null)
0619:                    return null;
0620:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0621:                if (p == null)
0622:                    return null;
0623:                CallbackHandlerConfiguration chc = (CallbackHandlerConfiguration) PolicyModelHelper
0624:                        .getTopLevelElement(p,
0625:                                CallbackHandlerConfiguration.class);
0626:                CallbackHandler ch = getCallbackHandler(cbhType, chc);
0627:                if (ch != null) {
0628:                    return ch.getClassname();
0629:                }
0630:                return null;
0631:            }
0632:
0633:            private static CallbackHandler getCallbackHandler(String type,
0634:                    CallbackHandlerConfiguration vc) {
0635:                if (vc == null)
0636:                    return null;
0637:                List<CallbackHandler> handlers = vc
0638:                        .getExtensibilityElements(CallbackHandler.class);
0639:                for (CallbackHandler h : handlers) {
0640:                    if (type.equals(h.getName())) {
0641:                        return h;
0642:                    }
0643:                }
0644:                return null;
0645:            }
0646:
0647:            public static String getKeyPassword(WSDLComponent b) {
0648:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0649:                if (p == null)
0650:                    return null;
0651:                KeyStore ks = (KeyStore) getStore(p, false);
0652:                return (ks == null) ? null : ks.getKeyPassword();
0653:            }
0654:
0655:            public static String getStorePassword(WSDLComponent b, boolean trust) {
0656:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0657:                if (p == null)
0658:                    return null;
0659:                if (trust) {
0660:                    TrustStore ts = (TrustStore) getStore(p, trust);
0661:                    return (ts == null) ? null : ts.getStorePassword();
0662:                } else {
0663:                    KeyStore ks = (KeyStore) getStore(p, trust);
0664:                    return (ks == null) ? null : ks.getStorePassword();
0665:                }
0666:            }
0667:
0668:            public static String getAliasSelector(WSDLComponent b) {
0669:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0670:                if (p == null)
0671:                    return null;
0672:                KeyStore ks = (KeyStore) getStore(p, false);
0673:                return (ks == null) ? null : ks.getAliasSelector();
0674:            }
0675:
0676:            public static String getCertSelector(WSDLComponent b) {
0677:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0678:                if (p == null)
0679:                    return null;
0680:                TrustStore ts = (TrustStore) getStore(p, true);
0681:                return (ts == null) ? null : ts.getCertSelector();
0682:            }
0683:
0684:            public static void disableSTS(Binding b) {
0685:                STSConfiguration stsConfig = getSTSConfiguration(b);
0686:                if (stsConfig != null) {
0687:                    PolicyModelHelper.removeElement(stsConfig);
0688:                }
0689:                PolicyModelHelper.cleanPolicies(b);
0690:            }
0691:
0692:            public static void enableSTS(Binding b) {
0693:                setSTSContractClass(b, DEFAULT_CONTRACT_CLASS);
0694:                setSTSLifeTime(b, DEFAULT_LIFETIME);
0695:            }
0696:
0697:            public static boolean isSTSEnabled(Binding b) {
0698:                STSConfiguration stsConfig = getSTSConfiguration(b);
0699:                return (stsConfig != null);
0700:            }
0701:
0702:            public static void setStoreLocation(WSDLComponent b, String value,
0703:                    boolean trust, boolean client) {
0704:                WSDLModel model = b.getModel();
0705:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0706:                boolean isTransaction = model.isIntransaction();
0707:                if (!isTransaction) {
0708:                    model.startTransaction();
0709:                }
0710:                try {
0711:                    if (trust) {
0712:                        TrustStore ks = (TrustStore) getStore(p, trust);
0713:                        if (value == null) {
0714:                            if (ks != null) {
0715:                                PolicyModelHelper.removeElement(ks);
0716:                            }
0717:                            return;
0718:                        }
0719:                        if ((p == null) || (ks == null)) {
0720:                            ks = (TrustStore) createStore(b, trust, client);
0721:                        }
0722:                        ks.setLocation(value);
0723:                    } else {
0724:                        KeyStore ks = (KeyStore) getStore(p, trust);
0725:                        if (value == null) {
0726:                            if (ks != null) {
0727:                                PolicyModelHelper.removeElement(ks);
0728:                            }
0729:                            return;
0730:                        }
0731:                        if ((p == null) || (ks == null)) {
0732:                            ks = (KeyStore) createStore(b, trust, client);
0733:                        }
0734:                        ks.setLocation(value);
0735:                    }
0736:                } finally {
0737:                    if (!isTransaction) {
0738:                        model.endTransaction();
0739:                    }
0740:                }
0741:            }
0742:
0743:            public static void setAliasSelector(WSDLComponent b, String value,
0744:                    boolean client) {
0745:                WSDLModel model = b.getModel();
0746:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0747:                boolean isTransaction = model.isIntransaction();
0748:                if (!isTransaction) {
0749:                    model.startTransaction();
0750:                }
0751:                try {
0752:                    KeyStore ks = (KeyStore) getStore(p, false);
0753:                    if ((p == null) || (ks == null)) {
0754:                        ks = (KeyStore) createStore(b, false, client);
0755:                    }
0756:                    ks.setAliasSelector(value);
0757:                } finally {
0758:                    if (!isTransaction) {
0759:                        model.endTransaction();
0760:                    }
0761:                }
0762:            }
0763:
0764:            public static void setCertSelector(WSDLComponent b, String value,
0765:                    boolean client) {
0766:                WSDLModel model = b.getModel();
0767:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0768:                boolean isTransaction = model.isIntransaction();
0769:                if (!isTransaction) {
0770:                    model.startTransaction();
0771:                }
0772:                try {
0773:                    TrustStore ts = (TrustStore) getStore(p, true);
0774:                    if ((p == null) || (ts == null)) {
0775:                        ts = (TrustStore) createStore(b, true, client);
0776:                    }
0777:                    ts.setCertSelector(value);
0778:                } finally {
0779:                    if (!isTransaction) {
0780:                        model.endTransaction();
0781:                    }
0782:                }
0783:            }
0784:
0785:            public static void setKeyStoreAlias(WSDLComponent b, String value,
0786:                    boolean client) {
0787:                WSDLModel model = b.getModel();
0788:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0789:                KeyStore ks = (KeyStore) getStore(p, false);
0790:                if ((p == null) || (ks == null)) {
0791:                    ks = (KeyStore) createStore(b, false, client);
0792:                }
0793:                boolean isTransaction = model.isIntransaction();
0794:                if (!isTransaction) {
0795:                    model.startTransaction();
0796:                }
0797:                try {
0798:                    ks.setAlias(value);
0799:                } finally {
0800:                    if (!isTransaction) {
0801:                        model.endTransaction();
0802:                    }
0803:                }
0804:            }
0805:
0806:            public static void setTrustPeerAlias(WSDLComponent b, String value,
0807:                    boolean client) {
0808:                WSDLModel model = b.getModel();
0809:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0810:                TrustStore ks = (TrustStore) getStore(p, true);
0811:                if ((p == null) || (ks == null)) {
0812:                    ks = (TrustStore) createStore(b, true, client);
0813:                }
0814:                boolean isTransaction = model.isIntransaction();
0815:                if (!isTransaction) {
0816:                    model.startTransaction();
0817:                }
0818:                try {
0819:                    ks.setPeerAlias(value);
0820:                } finally {
0821:                    if (!isTransaction) {
0822:                        model.endTransaction();
0823:                    }
0824:                }
0825:            }
0826:
0827:            public static void setValidator(WSDLComponent c, String type,
0828:                    String value, boolean client) {
0829:                WSDLModel model = c.getModel();
0830:                Policy p = PolicyModelHelper.getPolicyForElement(c);
0831:                ValidatorConfiguration vc = (ValidatorConfiguration) PolicyModelHelper
0832:                        .getTopLevelElement(p, ValidatorConfiguration.class);
0833:
0834:                if (value == null) {
0835:                    if (vc != null) {
0836:                        Validator v = getValidator(type, vc);
0837:                        if (v != null) {
0838:                            PolicyModelHelper.removeElement(v);
0839:                        }
0840:                    }
0841:                    return;
0842:                }
0843:
0844:                if ((p == null) || (vc == null)) {
0845:                    vc = createValidatorConfiguration(c, client);
0846:                }
0847:                Validator v = getValidator(type, vc);
0848:                if (v == null) {
0849:                    v = createValidator(vc, client);
0850:                }
0851:                boolean isTransaction = model.isIntransaction();
0852:                if (!isTransaction) {
0853:                    model.startTransaction();
0854:                }
0855:                try {
0856:                    v.setName(type);
0857:                    v.setClassname(value);
0858:                } finally {
0859:                    if (!isTransaction) {
0860:                        model.endTransaction();
0861:                    }
0862:                }
0863:            }
0864:
0865:            public static void setLifeTime(Binding b, String value,
0866:                    boolean client) {
0867:                WSDLModel model = b.getModel();
0868:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0869:                WSDLComponent c = client ? getSCClientConfiguration(p)
0870:                        : getSCConfiguration(p);
0871:
0872:                if (value == null) {
0873:                    if (c != null) {
0874:                        LifeTime lt = getLifeTime(c);
0875:                        if (lt != null) {
0876:                            PolicyModelHelper.removeElement(lt);
0877:                        }
0878:                    }
0879:                    return;
0880:                }
0881:
0882:                if ((p == null) || (c == null)) {
0883:                    c = createSCConfiguration(b, client);
0884:                }
0885:                LifeTime lt = getLifeTime(c);
0886:                if (lt == null) {
0887:                    lt = createLifeTime(c, client);
0888:                }
0889:                boolean isTransaction = model.isIntransaction();
0890:                if (!isTransaction) {
0891:                    model.startTransaction();
0892:                }
0893:                try {
0894:                    lt.setLifeTime(value);
0895:                } finally {
0896:                    if (!isTransaction) {
0897:                        model.endTransaction();
0898:                    }
0899:                }
0900:            }
0901:
0902:            public static String getHandlerTimestampTimeout(Binding b) {
0903:                CallbackHandlerConfiguration chc = getCBHConfiguration(b);
0904:                if (chc != null) {
0905:                    return chc.getTimestampTimeout();
0906:                }
0907:                return null;
0908:            }
0909:
0910:            public static void setHandlerTimestampTimeout(Binding b,
0911:                    String value, boolean client) {
0912:                WSDLModel model = b.getModel();
0913:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0914:                boolean isTransaction = model.isIntransaction();
0915:                if (!isTransaction) {
0916:                    model.startTransaction();
0917:                }
0918:                try {
0919:                    CallbackHandlerConfiguration chc = (CallbackHandlerConfiguration) PolicyModelHelper
0920:                            .getTopLevelElement(p,
0921:                                    CallbackHandlerConfiguration.class);
0922:                    if (((p == null) || (chc == null)) && value != null) {
0923:                        chc = createCallbackHandlerConfiguration(b, client);
0924:                    }
0925:                    if (chc != null) {
0926:                        chc.setTimestampTimeout(value);
0927:                    }
0928:                } finally {
0929:                    if (!isTransaction) {
0930:                        model.endTransaction();
0931:                    }
0932:                }
0933:            }
0934:
0935:            public static void setTimestampTimeout(Binding b, String value,
0936:                    boolean client) {
0937:                WSDLModel model = b.getModel();
0938:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0939:                WSDLComponent c = PolicyModelHelper.getTopLevelElement(p,
0940:                        Timestamp.class);
0941:                boolean isTransaction = model.isIntransaction();
0942:                if (!isTransaction) {
0943:                    model.startTransaction();
0944:                }
0945:                try {
0946:                    if ((value == null) && (c != null)) {
0947:                        PolicyModelHelper.removeElement(c);
0948:                    } else {
0949:                        if ((p == null) || (c == null)) {
0950:                            c = createTimestamp(b, client);
0951:                        }
0952:                        ((Timestamp) c).setTimeout(value);
0953:                    }
0954:                } finally {
0955:                    if (!isTransaction) {
0956:                        model.endTransaction();
0957:                    }
0958:                }
0959:            }
0960:
0961:            public static void setSTSLifeTime(Binding b, String value) {
0962:                WSDLModel model = b.getModel();
0963:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0964:                STSConfiguration c = getSTSConfiguration(p);
0965:                if ((p == null) || (c == null)) {
0966:                    c = createSTSConfiguration(b);
0967:                }
0968:                LifeTime lt = getLifeTime(c);
0969:                if (lt == null) {
0970:                    lt = createSTSLifeTime(c);
0971:                }
0972:                boolean isTransaction = model.isIntransaction();
0973:                if (!isTransaction) {
0974:                    model.startTransaction();
0975:                }
0976:                try {
0977:                    lt.setLifeTime(value);
0978:                } finally {
0979:                    if (!isTransaction) {
0980:                        model.endTransaction();
0981:                    }
0982:                }
0983:            }
0984:
0985:            public static void setSTSIssuer(Binding b, String value) {
0986:                WSDLModel model = b.getModel();
0987:                Policy p = PolicyModelHelper.getPolicyForElement(b);
0988:                STSConfiguration c = getSTSConfiguration(p);
0989:                if ((p == null) || (c == null)) {
0990:                    c = createSTSConfiguration(b);
0991:                }
0992:                Issuer i = getIssuer(c);
0993:                if (i == null) {
0994:                    i = createSTSIssuer(c);
0995:                }
0996:                boolean isTransaction = model.isIntransaction();
0997:                if (!isTransaction) {
0998:                    model.startTransaction();
0999:                }
1000:                try {
1001:                    i.setIssuer(value);
1002:                } finally {
1003:                    if (!isTransaction) {
1004:                        model.endTransaction();
1005:                    }
1006:                }
1007:            }
1008:
1009:            public static void addSTSServiceProvider(
1010:                    STSConfiguration stsConfig, ServiceProviderElement spe) {
1011:                if ((stsConfig == null) || (spe == null))
1012:                    return;
1013:                WSDLModel model = stsConfig.getModel();
1014:                boolean isTransaction = model.isIntransaction();
1015:                if (!isTransaction) {
1016:                    model.startTransaction();
1017:                }
1018:                try {
1019:                    WSDLComponentFactory wcf = model.getFactory();
1020:                    List<ServiceProviders> sProvidersList = stsConfig
1021:                            .getExtensibilityElements(ServiceProviders.class);
1022:                    ServiceProviders sProviders = null;
1023:                    if ((sProvidersList != null) && (!sProvidersList.isEmpty())) {
1024:                        sProviders = sProvidersList.get(0);
1025:                    }
1026:                    if (sProviders == null) {
1027:                        sProviders = (ServiceProviders) wcf.create(stsConfig,
1028:                                ProprietaryTrustServiceQName.SERVICEPROVIDERS
1029:                                        .getQName());
1030:                        stsConfig.addExtensibilityElement(sProviders);
1031:                    }
1032:                    ServiceProvider sp = (ServiceProvider) wcf.create(
1033:                            sProviders,
1034:                            ProprietaryTrustServiceQName.SERVICEPROVIDER
1035:                                    .getQName());
1036:                    sProviders.addExtensibilityElement(sp);
1037:                    sp.setEndpoint(spe.getEndpoint());
1038:                    CertAlias calias = (CertAlias) wcf.create(sp,
1039:                            ProprietaryTrustServiceQName.CERTALIAS.getQName());
1040:                    sp.addExtensibilityElement(calias);
1041:                    calias.setCertAlias(spe.getCertAlias());
1042:
1043:                    TokenType ttype = (TokenType) wcf.create(sp,
1044:                            ProprietaryTrustServiceQName.TOKENTYPE.getQName());
1045:                    sp.addExtensibilityElement(ttype);
1046:
1047:                    String tTypePolicyStr = ComboConstants.ISSUED_TOKENTYPE_SAML11_POLICYSTR;
1048:
1049:                    String tTypeShort = spe.getTokenType();
1050:                    if (ComboConstants.ISSUED_TOKENTYPE_SAML20
1051:                            .equals(tTypeShort)) {
1052:                        tTypePolicyStr = ComboConstants.ISSUED_TOKENTYPE_SAML20_POLICYSTR;
1053:                    }
1054:                    if (ComboConstants.ISSUED_TOKENTYPE_SAML10
1055:                            .equals(tTypeShort)) {
1056:                        tTypePolicyStr = ComboConstants.ISSUED_TOKENTYPE_SAML10_POLICYSTR;
1057:                    }
1058:                    ttype.setTokenType(tTypePolicyStr);
1059:
1060:                    KeyType ktype = (KeyType) wcf.create(sp,
1061:                            ProprietaryTrustServiceQName.KEYTYPE.getQName());
1062:                    sp.addExtensibilityElement(ktype);
1063:
1064:                    String kTypePolicyStr = ComboConstants.ISSUED_KEYTYPE_PUBLIC_POLICYSTR;
1065:
1066:                    String kTypeShort = spe.getKeyType();
1067:                    if (ComboConstants.ISSUED_KEYTYPE_SYMMETRIC
1068:                            .equals(kTypeShort)) {
1069:                        kTypePolicyStr = ComboConstants.ISSUED_KEYTYPE_SYMMETRIC_POLICYSTR;
1070:                    }
1071:                    ktype.setKeyType(kTypePolicyStr);
1072:
1073:                } finally {
1074:                    if (!isTransaction) {
1075:                        model.endTransaction();
1076:                    }
1077:                }
1078:            }
1079:
1080:            public static void removeSTSServiceProvider(
1081:                    STSConfiguration stsConfig, ServiceProviderElement spe) {
1082:                if ((spe == null) || (stsConfig == null))
1083:                    return;
1084:                WSDLModel model = stsConfig.getModel();
1085:                boolean isTransaction = model.isIntransaction();
1086:                if (!isTransaction) {
1087:                    model.startTransaction();
1088:                }
1089:                try {
1090:                    List<ServiceProvider> spList = getSTSServiceProviders(stsConfig);
1091:                    for (ServiceProvider sp : spList) {
1092:                        String ep = spe.getEndpoint();
1093:                        if (ep.equals(sp.getEndpoint())) {
1094:                            if (sp.isInDocumentModel()) {
1095:                                sp.getParent().removeExtensibilityElement(sp);
1096:                            }
1097:                            break;
1098:                        }
1099:                    }
1100:                } finally {
1101:                    if (!isTransaction) {
1102:                        model.endTransaction();
1103:                    }
1104:                }
1105:            }
1106:
1107:            public static void setSTSContractClass(Binding b, String value) {
1108:                WSDLModel model = b.getModel();
1109:                Policy p = PolicyModelHelper.getPolicyForElement(b);
1110:                STSConfiguration c = getSTSConfiguration(p);
1111:                if ((p == null) || (c == null)) {
1112:                    c = createSTSConfiguration(b);
1113:                }
1114:                Contract contract = getContract(c);
1115:                if (contract == null) {
1116:                    contract = createSTSContract(c);
1117:                }
1118:                boolean isTransaction = model.isIntransaction();
1119:                if (!isTransaction) {
1120:                    model.startTransaction();
1121:                }
1122:                try {
1123:                    contract.setContract(value);
1124:                } finally {
1125:                    if (!isTransaction) {
1126:                        model.endTransaction();
1127:                    }
1128:                }
1129:            }
1130:
1131:            public static void setSTSEncryptKey(Binding b, boolean enable) {
1132:                WSDLModel model = b.getModel();
1133:                Policy p = PolicyModelHelper.getPolicyForElement(b);
1134:                STSConfiguration sc = getSTSConfiguration(p);
1135:                if ((p == null) || (sc == null)) {
1136:                    sc = createSTSConfiguration(b);
1137:                }
1138:                boolean isTransaction = model.isIntransaction();
1139:                if (!isTransaction) {
1140:                    model.startTransaction();
1141:                }
1142:                try {
1143:                    sc.setEncryptIssuedKey(enable);
1144:                } finally {
1145:                    if (!isTransaction) {
1146:                        model.endTransaction();
1147:                    }
1148:                }
1149:            }
1150:
1151:            public static void setSTSEncryptToken(Binding b, boolean enable) {
1152:                WSDLModel model = b.getModel();
1153:                Policy p = PolicyModelHelper.getPolicyForElement(b);
1154:                STSConfiguration sc = getSTSConfiguration(p);
1155:                if ((p == null) || (sc == null)) {
1156:                    sc = createSTSConfiguration(b);
1157:                }
1158:                boolean isTransaction = model.isIntransaction();
1159:                if (!isTransaction) {
1160:                    model.startTransaction();
1161:                }
1162:                try {
1163:                    sc.setEncryptIssuedToken(enable);
1164:                } finally {
1165:                    if (!isTransaction) {
1166:                        model.endTransaction();
1167:                    }
1168:                }
1169:            }
1170:
1171:            public static void setRequireCancel(Binding b, boolean enable) {
1172:                WSDLModel model = b.getModel();
1173:                Policy p = PolicyModelHelper.getPolicyForElement(b);
1174:                SCClientConfiguration sc = getSCClientConfiguration(p);
1175:                if ((p == null) || (sc == null)) {
1176:                    sc = (SCClientConfiguration) createSCConfiguration(b, true);
1177:                }
1178:                boolean isTransaction = model.isIntransaction();
1179:                if (!isTransaction) {
1180:                    model.startTransaction();
1181:                }
1182:                try {
1183:                    sc.setRequireCancelSCT(enable);
1184:                } finally {
1185:                    if (!isTransaction) {
1186:                        model.endTransaction();
1187:                    }
1188:                }
1189:            }
1190:
1191:            public static void setRenewExpired(Binding b, boolean enable) {
1192:                WSDLModel model = b.getModel();
1193:                Policy p = PolicyModelHelper.getPolicyForElement(b);
1194:                SCClientConfiguration sc = getSCClientConfiguration(p);
1195:                if ((p == null) || (sc == null)) {
1196:                    sc = (SCClientConfiguration) createSCConfiguration(b, true);
1197:                }
1198:                boolean isTransaction = model.isIntransaction();
1199:                if (!isTransaction) {
1200:                    model.startTransaction();
1201:                }
1202:                try {
1203:                    sc.setRenewExpiredSCT(enable);
1204:                } finally {
1205:                    if (!isTransaction) {
1206:                        model.endTransaction();
1207:                    }
1208:                }
1209:            }
1210:
1211:            public static void removeCallbackHandlerConfiguration(Binding b) {
1212:                CallbackHandlerConfiguration cbh = getCBHConfiguration(b);
1213:                if (cbh != null) {
1214:                    WSDLModel model = cbh.getModel();
1215:                    boolean isTransaction = model.isIntransaction();
1216:                    if (!isTransaction) {
1217:                        model.startTransaction();
1218:                    }
1219:                    try {
1220:                        cbh.getParent().removeExtensibilityElement(cbh);
1221:                    } finally {
1222:                        if (!isTransaction) {
1223:                            model.endTransaction();
1224:                        }
1225:                    }
1226:                }
1227:            }
1228:
1229:            public static void setCallbackHandler(Binding b, String type,
1230:                    String value, String defaultVal, boolean client) {
1231:                WSDLModel model = b.getModel();
1232:                Policy p = PolicyModelHelper.getPolicyForElement(b);
1233:                boolean isTransaction = model.isIntransaction();
1234:                if (!isTransaction) {
1235:                    model.startTransaction();
1236:                }
1237:                try {
1238:                    CallbackHandlerConfiguration chc = (CallbackHandlerConfiguration) PolicyModelHelper
1239:                            .getTopLevelElement(p,
1240:                                    CallbackHandlerConfiguration.class);
1241:                    if ((p == null) || (chc == null)) {
1242:                        chc = createCallbackHandlerConfiguration(b, client);
1243:                    }
1244:                    CallbackHandler h = getCallbackHandler(type, chc);
1245:                    if (h == null) {
1246:                        h = createCallbackHandler(chc, client);
1247:                    }
1248:                    if ((defaultVal == null) && (value == null)) {
1249:                        chc.removeExtensibilityElement(h);
1250:                        if ((chc.getExtensibilityElements().size() == 0)
1251:                                && (chc.getTimestampTimeout() == null)) {
1252:                            chc.getParent().removeExtensibilityElement(chc);
1253:                        }
1254:                    } else {
1255:                        h.setDefault(defaultVal);
1256:                        h.setName(type);
1257:                        h.setClassname(value);
1258:                    }
1259:                } finally {
1260:                    if (!isTransaction) {
1261:                        model.endTransaction();
1262:                    }
1263:                }
1264:            }
1265:
1266:            public static void setStoreType(WSDLComponent b, String value,
1267:                    boolean trust, boolean client) {
1268:                WSDLModel model = b.getModel();
1269:                Policy p = PolicyModelHelper.getPolicyForElement(b);
1270:                boolean isTransaction = model.isIntransaction();
1271:                if (!isTransaction) {
1272:                    model.startTransaction();
1273:                }
1274:                try {
1275:                    if (trust) {
1276:                        TrustStore ks = (TrustStore) getStore(p, trust);
1277:                        if ((p == null) || (ks == null)) {
1278:                            ks = (TrustStore) createStore(b, trust, client);
1279:                        }
1280:                        ks.setType(value);
1281:                    } else {
1282:                        KeyStore ks = (KeyStore) getStore(p, trust);
1283:                        if ((p == null) || (ks == null)) {
1284:                            ks = (KeyStore) createStore(b, trust, client);
1285:                        }
1286:                        ks.setType(value);
1287:                    }
1288:                } finally {
1289:                    if (!isTransaction) {
1290:                        model.endTransaction();
1291:                    }
1292:                }
1293:            }
1294:
1295:            public static void setStorePassword(WSDLComponent b, String value,
1296:                    boolean trust, boolean client) {
1297:                WSDLModel model = b.getModel();
1298:                Policy p = PolicyModelHelper.getPolicyForElement(b);
1299:                boolean isTransaction = model.isIntransaction();
1300:                if (!isTransaction) {
1301:                    model.startTransaction();
1302:                }
1303:                try {
1304:                    if (trust) {
1305:                        TrustStore ks = (TrustStore) getStore(p, trust);
1306:                        if ((p == null) || (ks == null)) {
1307:                            ks = (TrustStore) createStore(b, trust, client);
1308:                        }
1309:                        ks.setStorePassword(value);
1310:                    } else {
1311:                        KeyStore ks = (KeyStore) getStore(p, trust);
1312:                        if ((p == null) || (ks == null)) {
1313:                            ks = (KeyStore) createStore(b, trust, client);
1314:                        }
1315:                        ks.setStorePassword(value);
1316:                    }
1317:                } finally {
1318:                    if (!isTransaction) {
1319:                        model.endTransaction();
1320:                    }
1321:                }
1322:            }
1323:
1324:            public static void setKeyPassword(WSDLComponent b, String value,
1325:                    boolean client) {
1326:                WSDLModel model = b.getModel();
1327:                Policy p = PolicyModelHelper.getPolicyForElement(b);
1328:                boolean isTransaction = model.isIntransaction();
1329:                if (!isTransaction) {
1330:                    model.startTransaction();
1331:                }
1332:                try {
1333:                    KeyStore ks = (KeyStore) getStore(p, false);
1334:                    if ((p == null) || (ks == null)) {
1335:                        ks = (KeyStore) createStore(b, false, client);
1336:                    }
1337:                    ks.setKeyPassword(value);
1338:                } finally {
1339:                    if (!isTransaction) {
1340:                        model.endTransaction();
1341:                    }
1342:                }
1343:            }
1344:
1345:            public static void setPreSTSEndpoint(Binding b, String value) {
1346:                WSDLModel model = b.getModel();
1347:                Policy p = PolicyModelHelper.getPolicyForElement(b);
1348:                PreconfiguredSTS ps = getPreconfiguredSTS(p);
1349:                if ((ps == null) || (p == null)) {
1350:                    ps = createPreconfiguredSTS(b);
1351:                }
1352:                boolean isTransaction = model.isIntransaction();
1353:                if (!isTransaction) {
1354:                    model.startTransaction();
1355:                }
1356:                try {
1357:                    ps.setEndpoint(value);
1358:                } finally {
1359:                    if (!isTransaction) {
1360:                        model.endTransaction();
1361:                    }
1362:                }
1363:            }
1364:
1365:            public static void setPreSTSMetadata(Binding b, String value) {
1366:                WSDLModel model = b.getModel();
1367:                Policy p = PolicyModelHelper.getPolicyForElement(b);
1368:                PreconfiguredSTS ps = getPreconfiguredSTS(p);
1369:                if ((ps == null) || (p == null)) {
1370:                    ps = createPreconfiguredSTS(b);
1371:                }
1372:                boolean isTransaction = model.isIntransaction();
1373:                if (!isTransaction) {
1374:                    model.startTransaction();
1375:                }
1376:                try {
1377:                    ps.setMetadata(value);
1378:                } finally {
1379:                    if (!isTransaction) {
1380:                        model.endTransaction();
1381:                    }
1382:                }
1383:            }
1384:
1385:            public static void setPreSTSNamespace(Binding b, String value) {
1386:                WSDLModel model = b.getModel();
1387:                Policy p = PolicyModelHelper.getPolicyForElement(b);
1388:                PreconfiguredSTS ps = getPreconfiguredSTS(p);
1389:                if ((ps == null) || (p == null)) {
1390:                    ps = createPreconfiguredSTS(b);
1391:                }
1392:                boolean isTransaction = model.isIntransaction();
1393:                if (!isTransaction) {
1394:                    model.startTransaction();
1395:                }
1396:                try {
1397:                    ps.setNamespace(value);
1398:                } finally {
1399:                    if (!isTransaction) {
1400:                        model.endTransaction();
1401:                    }
1402:                }
1403:            }
1404:
1405:            public static void setPreSTSServiceName(Binding b, String value) {
1406:                WSDLModel model = b.getModel();
1407:                Policy p = PolicyModelHelper.getPolicyForElement(b);
1408:                PreconfiguredSTS ps = getPreconfiguredSTS(p);
1409:                if ((ps == null) || (p == null)) {
1410:                    ps = createPreconfiguredSTS(b);
1411:                }
1412:                boolean isTransaction = model.isIntransaction();
1413:                if (!isTransaction) {
1414:                    model.startTransaction();
1415:                }
1416:                try {
1417:                    ps.setServiceName(value);
1418:                } finally {
1419:                    if (!isTransaction) {
1420:                        model.endTransaction();
1421:                    }
1422:                }
1423:            }
1424:
1425:            public static void setPreSTSPortName(Binding b, String value) {
1426:                WSDLModel model = b.getModel();
1427:                Policy p = PolicyModelHelper.getPolicyForElement(b);
1428:                PreconfiguredSTS ps = getPreconfiguredSTS(p);
1429:                if ((ps == null) || (p == null)) {
1430:                    ps = createPreconfiguredSTS(b);
1431:                }
1432:                boolean isTransaction = model.isIntransaction();
1433:                if (!isTransaction) {
1434:                    model.startTransaction();
1435:                }
1436:                try {
1437:                    ps.setPortName(value);
1438:                } finally {
1439:                    if (!isTransaction) {
1440:                        model.endTransaction();
1441:                    }
1442:                }
1443:            }
1444:
1445:            public static void setPreSTSWsdlLocation(Binding b, String value) {
1446:                WSDLModel model = b.getModel();
1447:                Policy p = PolicyModelHelper.getPolicyForElement(b);
1448:                PreconfiguredSTS ps = getPreconfiguredSTS(p);
1449:                if ((ps == null) || (p == null)) {
1450:                    ps = createPreconfiguredSTS(b);
1451:                }
1452:                boolean isTransaction = model.isIntransaction();
1453:                if (!isTransaction) {
1454:                    model.startTransaction();
1455:                }
1456:                try {
1457:                    ps.setWsdlLocation(value);
1458:                } finally {
1459:                    if (!isTransaction) {
1460:                        model.endTransaction();
1461:                    }
1462:                }
1463:            }
1464:
1465:            public static void setMaxClockSkew(Binding b, String value,
1466:                    boolean client) {
1467:                WSDLModel model = b.getModel();
1468:                Policy p = PolicyModelHelper.getPolicyForElement(b);
1469:                boolean isTransaction = model.isIntransaction();
1470:                if (!isTransaction) {
1471:                    model.startTransaction();
1472:                }
1473:                try {
1474:                    ValidatorConfiguration vc = (ValidatorConfiguration) PolicyModelHelper
1475:                            .getTopLevelElement(p, ValidatorConfiguration.class);
1476:                    if ((vc == null) || (p == null)) {
1477:                        vc = createValidatorConfiguration(b, client);
1478:                    }
1479:                    if (vc != null) {
1480:                        vc.setMaxClockSkew(value);
1481:                    }
1482:                } finally {
1483:                    if (!isTransaction) {
1484:                        model.endTransaction();
1485:                    }
1486:                }
1487:            }
1488:
1489:            public static void setRevocation(Binding b, boolean value,
1490:                    boolean client) {
1491:                WSDLModel model = b.getModel();
1492:                Policy p = PolicyModelHelper.getPolicyForElement(b);
1493:                boolean isTransaction = model.isIntransaction();
1494:                if (!isTransaction) {
1495:                    model.startTransaction();
1496:                }
1497:                try {
1498:                    ValidatorConfiguration vc = (ValidatorConfiguration) PolicyModelHelper
1499:                            .getTopLevelElement(p, ValidatorConfiguration.class);
1500:                    if (vc == null) {
1501:                        vc = createValidatorConfiguration(b, client);
1502:                    }
1503:                    if (vc != null) {
1504:                        vc.setRevocationEnabled(value);
1505:                    }
1506:                } finally {
1507:                    if (!isTransaction) {
1508:                        model.endTransaction();
1509:                    }
1510:                }
1511:            }
1512:
1513:            public static void setTimestampFreshness(Binding b, String value,
1514:                    boolean client) {
1515:                WSDLModel model = b.getModel();
1516:                Policy p = PolicyModelHelper.getPolicyForElement(b);
1517:                boolean isTransaction = model.isIntransaction();
1518:                if (!isTransaction) {
1519:                    model.startTransaction();
1520:                }
1521:                try {
1522:                    ValidatorConfiguration vc = (ValidatorConfiguration) PolicyModelHelper
1523:                            .getTopLevelElement(p, ValidatorConfiguration.class);
1524:                    if ((vc == null) || (p == null)) {
1525:                        vc = createValidatorConfiguration(b, client);
1526:                    }
1527:                    vc.setTimestampFreshnessLimit(value);
1528:                } finally {
1529:                    if (!isTransaction) {
1530:                        model.endTransaction();
1531:                    }
1532:                }
1533:            }
1534:
1535:            //    public static void setMaxNonceAge(Binding b, String value, boolean client) {
1536:            //        WSDLModel model = b.getModel();
1537:            //        Policy p = PolicyModelHelper.getPolicyForElement(b);
1538:            //        ValidatorConfiguration vc = (ValidatorConfiguration) PolicyModelHelper.getTopLevelElement(p, ValidatorConfiguration.class);
1539:            //        if ((vc == null) || (p == null)) {
1540:            //            vc = createValidatorConfiguration(b, client);
1541:            //        }
1542:            //        boolean isTransaction = model.isIntransaction();
1543:            //        if (!isTransaction) {
1544:            //            model.startTransaction();
1545:            //        }
1546:            //        try {
1547:            //            vc.setMaxNonceAge(value);
1548:            //        } finally {
1549:            //            if (!isTransaction) {
1550:            //                model.endTransaction();
1551:            //            }
1552:            //        }
1553:            //    }
1554:
1555:            public static WSDLComponent createStore(WSDLComponent b,
1556:                    boolean trust, boolean client) {
1557:                WSDLModel model = b.getModel();
1558:                Policy p = PolicyModelHelper.getPolicyForElement(b);
1559:                if (trust) {
1560:                    TrustStore ks = (TrustStore) getStore(p, trust);
1561:                    if (ks == null) {
1562:                        boolean isTransaction = model.isIntransaction();
1563:                        if (!isTransaction) {
1564:                            model.startTransaction();
1565:                        }
1566:                        try {
1567:                            WSDLComponentFactory wcf = model.getFactory();
1568:                            All all = PolicyModelHelper
1569:                                    .createPolicy(b, !client);
1570:                            if (client) {
1571:                                ks = (TrustStore) wcf
1572:                                        .create(
1573:                                                all,
1574:                                                ProprietarySecurityPolicyQName.TRUSTSTORE
1575:                                                        .getQName());
1576:                            } else {
1577:                                ks = (TrustStore) wcf
1578:                                        .create(
1579:                                                all,
1580:                                                ProprietarySecurityPolicyServiceQName.TRUSTSTORE
1581:                                                        .getQName());
1582:                            }
1583:                            all.addExtensibilityElement(ks);
1584:                            ks.setVisibility(ProprietaryPolicyQName.INVISIBLE);
1585:                        } finally {
1586:                            if (!isTransaction) {
1587:                                model.endTransaction();
1588:                            }
1589:                        }
1590:                        return ks;
1591:                    }
1592:                } else {
1593:                    KeyStore ks = (KeyStore) getStore(p, trust);
1594:                    if (ks == null) {
1595:                        boolean isTransaction = model.isIntransaction();
1596:                        if (!isTransaction) {
1597:                            model.startTransaction();
1598:                        }
1599:                        try {
1600:                            WSDLComponentFactory wcf = model.getFactory();
1601:                            All all = PolicyModelHelper
1602:                                    .createPolicy(b, !client);
1603:                            if (client) {
1604:                                ks = (KeyStore) wcf.create(all,
1605:                                        ProprietarySecurityPolicyQName.KEYSTORE
1606:                                                .getQName());
1607:                            } else {
1608:                                ks = (KeyStore) wcf
1609:                                        .create(
1610:                                                all,
1611:                                                ProprietarySecurityPolicyServiceQName.KEYSTORE
1612:                                                        .getQName());
1613:                            }
1614:                            all.addExtensibilityElement(ks);
1615:                            ks.setVisibility(ProprietaryPolicyQName.INVISIBLE);
1616:                        } finally {
1617:                            if (!isTransaction) {
1618:                                model.endTransaction();
1619:                            }
1620:                        }
1621:                        return ks;
1622:                    }
1623:                }
1624:                return null;
1625:            }
1626:
1627:            public static ValidatorConfiguration createValidatorConfiguration(
1628:                    WSDLComponent c, boolean client) {
1629:                WSDLModel model = c.getModel();
1630:                Policy p = PolicyModelHelper.getPolicyForElement(c);
1631:                ValidatorConfiguration vc = (ValidatorConfiguration) PolicyModelHelper
1632:                        .getTopLevelElement(p, ValidatorConfiguration.class);
1633:                if (vc == null) {
1634:                    boolean isTransaction = model.isIntransaction();
1635:                    if (!isTransaction) {
1636:                        model.startTransaction();
1637:                    }
1638:                    try {
1639:                        WSDLComponentFactory wcf = model.getFactory();
1640:                        All all = PolicyModelHelper.createPolicy(c, !client);
1641:                        if (client) {
1642:                            vc = (ValidatorConfiguration) wcf
1643:                                    .create(
1644:                                            all,
1645:                                            ProprietarySecurityPolicyQName.VALIDATORCONFIGURATION
1646:                                                    .getQName());
1647:                        } else {
1648:                            vc = (ValidatorConfiguration) wcf
1649:                                    .create(
1650:                                            all,
1651:                                            ProprietarySecurityPolicyServiceQName.VALIDATORCONFIGURATION
1652:                                                    .getQName());
1653:                        }
1654:                        all.addExtensibilityElement(vc);
1655:                        vc.setVisibility(ProprietaryPolicyQName.INVISIBLE);
1656:                    } finally {
1657:                        if (!isTransaction) {
1658:                            model.endTransaction();
1659:                        }
1660:                    }
1661:                }
1662:                return vc;
1663:            }
1664:
1665:            public static PreconfiguredSTS createPreconfiguredSTS(Binding b) {
1666:                WSDLModel model = b.getModel();
1667:                Policy p = PolicyModelHelper.getPolicyForElement(b);
1668:                PreconfiguredSTS ps = getPreconfiguredSTS(p);
1669:                if (ps == null) {
1670:                    boolean isTransaction = model.isIntransaction();
1671:                    if (!isTransaction) {
1672:                        model.startTransaction();
1673:                    }
1674:                    try {
1675:                        WSDLComponentFactory wcf = model.getFactory();
1676:                        All all = PolicyModelHelper.createPolicy(b, false);
1677:                        ps = (PreconfiguredSTS) wcf.create(all,
1678:                                ProprietaryTrustClientQName.PRECONFIGUREDSTS
1679:                                        .getQName());
1680:                        all.addExtensibilityElement(ps);
1681:                        ps.setVisibility(ProprietaryPolicyQName.INVISIBLE);
1682:                    } finally {
1683:                        if (!isTransaction) {
1684:                            model.endTransaction();
1685:                        }
1686:                    }
1687:                }
1688:                return ps;
1689:            }
1690:
1691:            public static STSConfiguration createSTSConfiguration(Binding b) {
1692:                WSDLModel model = b.getModel();
1693:                Policy p = PolicyModelHelper.getPolicyForElement(b);
1694:                STSConfiguration sts = getSTSConfiguration(p);
1695:                if (sts == null) {
1696:                    boolean isTransaction = model.isIntransaction();
1697:                    if (!isTransaction) {
1698:                        model.startTransaction();
1699:                    }
1700:                    try {
1701:                        WSDLComponentFactory wcf = model.getFactory();
1702:
1703:                        All all = PolicyModelHelper.createPolicy(b, true);
1704:                        sts = (STSConfiguration) wcf.create(all,
1705:                                ProprietaryTrustServiceQName.STSCONFIGURATION
1706:                                        .getQName());
1707:                        all.addExtensibilityElement(sts);
1708:                        sts.setVisibility(ProprietaryPolicyQName.INVISIBLE);
1709:                        sts.setEncryptIssuedKey(true);
1710:                        sts.setEncryptIssuedToken(false);
1711:                    } finally {
1712:                        if (!isTransaction) {
1713:                            model.endTransaction();
1714:                        }
1715:                    }
1716:                }
1717:                return sts;
1718:            }
1719:
1720:            public static WSDLComponent createSCConfiguration(Binding b,
1721:                    boolean client) {
1722:                WSDLModel model = b.getModel();
1723:                Policy p = PolicyModelHelper.getPolicyForElement(b);
1724:                WSDLComponent c = client ? getSCClientConfiguration(p)
1725:                        : getSCConfiguration(p);
1726:                if (c == null) {
1727:                    boolean isTransaction = model.isIntransaction();
1728:                    if (!isTransaction) {
1729:                        model.startTransaction();
1730:                    }
1731:                    try {
1732:                        WSDLComponentFactory wcf = model.getFactory();
1733:
1734:                        All all = PolicyModelHelper.createPolicy(b, !client);
1735:                        if (client) {
1736:                            c = (SCClientConfiguration) wcf
1737:                                    .create(
1738:                                            all,
1739:                                            ProprietarySCClientQName.SCCLIENTCONFIGURATION
1740:                                                    .getQName());
1741:                            all
1742:                                    .addExtensibilityElement((ExtensibilityElement) c);
1743:                            ((SCClientConfiguration) c)
1744:                                    .setVisibility(ProprietaryPolicyQName.INVISIBLE);
1745:                        } else {
1746:                            c = (SCConfiguration) wcf.create(all,
1747:                                    ProprietarySCServiceQName.SCCONFIGURATION
1748:                                            .getQName());
1749:                            all
1750:                                    .addExtensibilityElement((ExtensibilityElement) c);
1751:                            ((SCConfiguration) c)
1752:                                    .setVisibility(ProprietaryPolicyQName.INVISIBLE);
1753:                        }
1754:                    } finally {
1755:                        if (!isTransaction) {
1756:                            model.endTransaction();
1757:                        }
1758:                    }
1759:                }
1760:                return c;
1761:            }
1762:
1763:            public static WSDLComponent createTimestamp(Binding b,
1764:                    boolean client) {
1765:                WSDLModel model = b.getModel();
1766:                Policy p = PolicyModelHelper.getPolicyForElement(b);
1767:                WSDLComponent c = PolicyModelHelper.getTopLevelElement(p,
1768:                        Timestamp.class);
1769:                if (c == null) {
1770:                    boolean isTransaction = model.isIntransaction();
1771:                    if (!isTransaction) {
1772:                        model.startTransaction();
1773:                    }
1774:                    try {
1775:                        WSDLComponentFactory wcf = model.getFactory();
1776:                        All all = PolicyModelHelper.createPolicy(b, !client);
1777:                        if (client) {
1778:                            c = (Timestamp) wcf.create(all,
1779:                                    ProprietarySecurityPolicyQName.TIMESTAMP
1780:                                            .getQName());
1781:                        } else {
1782:                            c = (Timestamp) wcf
1783:                                    .create(
1784:                                            all,
1785:                                            ProprietarySecurityPolicyServiceQName.TIMESTAMP
1786:                                                    .getQName());
1787:                        }
1788:                        all.addExtensibilityElement((ExtensibilityElement) c);
1789:                        ((Timestamp) c)
1790:                                .setVisibility(ProprietaryPolicyQName.INVISIBLE);
1791:                    } finally {
1792:                        if (!isTransaction) {
1793:                            model.endTransaction();
1794:                        }
1795:                    }
1796:                }
1797:                return c;
1798:            }
1799:
1800:            public static Validator createValidator(ValidatorConfiguration vc,
1801:                    boolean client) {
1802:                Validator v = null;
1803:                if (vc != null) {
1804:                    WSDLModel model = vc.getModel();
1805:                    boolean isTransaction = model.isIntransaction();
1806:                    if (!isTransaction) {
1807:                        model.startTransaction();
1808:                    }
1809:                    try {
1810:                        WSDLComponentFactory wcf = model.getFactory();
1811:                        if (client) {
1812:                            v = (Validator) wcf.create(vc,
1813:                                    ProprietarySecurityPolicyQName.VALIDATOR
1814:                                            .getQName());
1815:                        } else {
1816:                            v = (Validator) wcf
1817:                                    .create(
1818:                                            vc,
1819:                                            ProprietarySecurityPolicyServiceQName.VALIDATOR
1820:                                                    .getQName());
1821:                        }
1822:                        vc.addExtensibilityElement(v);
1823:                    } finally {
1824:                        if (!isTransaction) {
1825:                            model.endTransaction();
1826:                        }
1827:                    }
1828:                }
1829:                return v;
1830:            }
1831:
1832:            public static LifeTime createLifeTime(WSDLComponent c,
1833:                    boolean client) {
1834:                LifeTime lt = null;
1835:                if (c != null) {
1836:                    WSDLModel model = c.getModel();
1837:                    boolean isTransaction = model.isIntransaction();
1838:                    if (!isTransaction) {
1839:                        model.startTransaction();
1840:                    }
1841:                    try {
1842:                        WSDLComponentFactory wcf = model.getFactory();
1843:                        if (client) {
1844:                            lt = (LifeTime) wcf.create(c,
1845:                                    ProprietarySCClientQName.LIFETIME
1846:                                            .getQName());
1847:                        } else {
1848:                            lt = (LifeTime) wcf.create(c,
1849:                                    ProprietarySCServiceQName.LIFETIME
1850:                                            .getQName());
1851:                        }
1852:                        c.addExtensibilityElement(lt);
1853:                    } finally {
1854:                        if (!isTransaction) {
1855:                            model.endTransaction();
1856:                        }
1857:                    }
1858:                }
1859:                return lt;
1860:            }
1861:
1862:            public static LifeTime createSTSLifeTime(WSDLComponent c) {
1863:                LifeTime lt = null;
1864:                if (c != null) {
1865:                    WSDLModel model = c.getModel();
1866:                    boolean isTransaction = model.isIntransaction();
1867:                    if (!isTransaction) {
1868:                        model.startTransaction();
1869:                    }
1870:                    try {
1871:                        WSDLComponentFactory wcf = model.getFactory();
1872:                        lt = (LifeTime) wcf.create(c,
1873:                                ProprietaryTrustServiceQName.LIFETIME
1874:                                        .getQName());
1875:                        c.addExtensibilityElement(lt);
1876:                    } finally {
1877:                        if (!isTransaction) {
1878:                            model.endTransaction();
1879:                        }
1880:                    }
1881:                }
1882:                return lt;
1883:            }
1884:
1885:            public static Issuer createSTSIssuer(WSDLComponent c) {
1886:                Issuer i = null;
1887:                if (c != null) {
1888:                    WSDLModel model = c.getModel();
1889:                    boolean isTransaction = model.isIntransaction();
1890:                    if (!isTransaction) {
1891:                        model.startTransaction();
1892:                    }
1893:                    try {
1894:                        WSDLComponentFactory wcf = model.getFactory();
1895:                        i = (Issuer) wcf.create(c,
1896:                                ProprietaryTrustServiceQName.ISSUER.getQName());
1897:                        c.addExtensibilityElement(i);
1898:                    } finally {
1899:                        if (!isTransaction) {
1900:                            model.endTransaction();
1901:                        }
1902:                    }
1903:                }
1904:                return i;
1905:            }
1906:
1907:            public static Contract createSTSContract(WSDLComponent c) {
1908:                Contract contract = null;
1909:                if (c != null) {
1910:                    WSDLModel model = c.getModel();
1911:                    boolean isTransaction = model.isIntransaction();
1912:                    if (!isTransaction) {
1913:                        model.startTransaction();
1914:                    }
1915:                    try {
1916:                        WSDLComponentFactory wcf = model.getFactory();
1917:                        contract = (Contract) wcf.create(c,
1918:                                ProprietaryTrustServiceQName.CONTRACT
1919:                                        .getQName());
1920:                        c.addExtensibilityElement(contract);
1921:                    } finally {
1922:                        if (!isTransaction) {
1923:                            model.endTransaction();
1924:                        }
1925:                    }
1926:                }
1927:                return contract;
1928:            }
1929:
1930:            public static CallbackHandlerConfiguration createCallbackHandlerConfiguration(
1931:                    Binding b, boolean client) {
1932:                WSDLModel model = b.getModel();
1933:                Policy p = PolicyModelHelper.getPolicyForElement(b);
1934:                CallbackHandlerConfiguration chc = (CallbackHandlerConfiguration) PolicyModelHelper
1935:                        .getTopLevelElement(p,
1936:                                CallbackHandlerConfiguration.class);
1937:                if (chc == null) {
1938:                    boolean isTransaction = model.isIntransaction();
1939:                    if (!isTransaction) {
1940:                        model.startTransaction();
1941:                    }
1942:                    try {
1943:                        WSDLComponentFactory wcf = model.getFactory();
1944:
1945:                        All all = PolicyModelHelper.createPolicy(b, !client);
1946:                        if (client) {
1947:                            chc = (CallbackHandlerConfiguration) wcf
1948:                                    .create(
1949:                                            all,
1950:                                            ProprietarySecurityPolicyQName.CALLBACKHANDLERCONFIGURATION
1951:                                                    .getQName());
1952:                        } else {
1953:                            chc = (CallbackHandlerConfiguration) wcf
1954:                                    .create(
1955:                                            all,
1956:                                            ProprietarySecurityPolicyServiceQName.CALLBACKHANDLERCONFIGURATION
1957:                                                    .getQName());
1958:                        }
1959:                        all.addExtensibilityElement(chc);
1960:                        chc.setVisibility(ProprietaryPolicyQName.INVISIBLE);
1961:                    } finally {
1962:                        if (!isTransaction) {
1963:                            model.endTransaction();
1964:                        }
1965:                    }
1966:                }
1967:                return chc;
1968:            }
1969:
1970:            public static CallbackHandler createCallbackHandler(
1971:                    CallbackHandlerConfiguration chc, boolean client) {
1972:                CallbackHandler h = null;
1973:                if (chc != null) {
1974:                    WSDLModel model = chc.getModel();
1975:                    boolean isTransaction = model.isIntransaction();
1976:                    if (!isTransaction) {
1977:                        model.startTransaction();
1978:                    }
1979:                    try {
1980:                        WSDLComponentFactory wcf = model.getFactory();
1981:                        if (client) {
1982:                            h = (CallbackHandler) wcf
1983:                                    .create(
1984:                                            chc,
1985:                                            ProprietarySecurityPolicyQName.CALLBACKHANDLER
1986:                                                    .getQName());
1987:                        } else {
1988:                            h = (CallbackHandler) wcf
1989:                                    .create(
1990:                                            chc,
1991:                                            ProprietarySecurityPolicyServiceQName.CALLBACKHANDLER
1992:                                                    .getQName());
1993:                        }
1994:                        chc.addExtensibilityElement(h);
1995:                    } finally {
1996:                        if (!isTransaction) {
1997:                            model.endTransaction();
1998:                        }
1999:                    }
2000:                }
2001:                return h;
2002:            }
2003:
2004:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.