Source Code Cross Referenced for AMDeploy.java in  » IDE-Netbeans » identity.kit » org » netbeans » modules » identity » ant » 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 » identity.kit » org.netbeans.modules.identity.ant 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:        package org.netbeans.modules.identity.ant;
042:
043:        import java.util.ArrayList;
044:        import java.util.Collection;
045:        import org.apache.tools.ant.BuildException;
046:        import org.apache.tools.ant.Task;
047:        import org.netbeans.modules.identity.profile.api.configurator.ConfiguratorException;
048:        import org.netbeans.modules.identity.profile.api.configurator.ProviderConfigurator.Configurable;
049:        import org.netbeans.modules.identity.profile.api.configurator.ProviderConfigurator;
050:        import org.netbeans.modules.identity.profile.api.configurator.ProviderConfigurator.Type;
051:        import org.netbeans.modules.identity.profile.api.configurator.Configurator.AccessMethod;
052:        import org.netbeans.modules.identity.profile.api.configurator.DiscoveryConfigurator;
053:        import org.netbeans.modules.identity.profile.api.configurator.ServerProperties;
054:        import org.netbeans.modules.identity.profile.api.configurator.SecurityMechanism;
055:        import org.netbeans.modules.identity.profile.api.configurator.TrustAuthorityConfigurator;
056:        import org.netbeans.modules.identity.server.manager.api.ServerInstance;
057:        import org.netbeans.modules.identity.server.manager.api.ServerManager;
058:
059:        /**
060:         * Ant task for deploying configuration data to the AM server.
061:         *
062:         * Created on June 26, 2006, 11:00 PM
063:         * 
064:         * @author ptliu
065:         */
066:        public class AMDeploy extends Task {
067:            private static final String PROP_AM_CONFIG_FILE = "AM_CONFIG_FILE"; //NOI18N
068:
069:            //    // This is temporarily until we have the appserver fix for FCS
070:            //    private static final String WSC = "wsc";    //NOI18N
071:
072:            private static final String LOCAL_DISCO = "LocalDisco"; //NOI18N
073:
074:            private String amConfigXmlDir;
075:            private String amAsUrl;
076:            private DiscoveryConfigurator discoveryConfig;
077:
078:            private static final Configurable[] wscConfigurables = {
079:                    Configurable.SECURITY_MECH, Configurable.SIGN_RESPONSE,
080:                    Configurable.USERNAME_PASSWORD_PAIRS,
081:                    Configurable.USE_DEFAULT_KEYSTORE,
082:                    Configurable.SERVICE_TYPE };
083:
084:            private static final Configurable[] wspConfigurables = { Configurable.SERVICE_TYPE };
085:
086:            private static final Configurable[] keystoreConfigurables = {
087:                    Configurable.KEYSTORE_LOCATION,
088:                    Configurable.KEYSTORE_PASSWORD, Configurable.KEY_ALIAS,
089:                    Configurable.KEY_PASSWORD };
090:
091:            /** Creates a new instance of AMDeploy */
092:            public AMDeploy() {
093:            }
094:
095:            public void setAmconfigxmldir(String amConfigXmlDir) {
096:                this .amConfigXmlDir = amConfigXmlDir;
097:                log("amConfigXmlDir: " + amConfigXmlDir); //NOI18N
098:            }
099:
100:            public void setAmasurl(String url) {
101:                this .amAsUrl = url;
102:                log("amAsUrl: " + amAsUrl); //NOI18N
103:            }
104:
105:            public void execute() throws BuildException {
106:                try {
107:                    ServerProperties.getInstance(amAsUrl);
108:                } catch (ConfiguratorException ex) {
109:                    log("skip am deploy");
110:                    return;
111:                }
112:
113:                try {
114:                    deployWSCProviders();
115:                    deployWSPProviders();
116:                } catch (ConfiguratorException ex) {
117:                    //ex.printStackTrace();
118:                    ex.getCause().printStackTrace();
119:                } catch (Exception ex) {
120:                    ex.printStackTrace();
121:                }
122:            }
123:
124:            private void deployWSCProviders() {
125:                Collection<ProviderConfigurator> fileConfigs = ProviderConfigurator
126:                        .getAllConfigurators(Type.WSC, AccessMethod.FILE,
127:                                amConfigXmlDir, amAsUrl);
128:
129:                for (ProviderConfigurator fileConfig : fileConfigs) {
130:                    log("Deploying wsc provider "
131:                            + fileConfig.getProviderName()); //NOI18N
132:
133:                    ServerInstance instance = ServerManager.getDefault()
134:                            .getServerInstance(amAsUrl);
135:                    ServerProperties properties = instance
136:                            .getServerProperties();
137:
138:                    log("ServerProperties: " + properties); //NOI18N
139:
140:                    ProviderConfigurator dynamicConfig = ProviderConfigurator
141:                            .getConfigurator(fileConfig.getProviderName(),
142:                                    fileConfig.getType(), AccessMethod.DYNAMIC,
143:                                    properties, amAsUrl);
144:
145:                    //
146:                    // This is temporary until we have the appserver fix for FCS.  For
147:                    // now we use "wsc" as the provider name.
148:                    //
149:                    //            ProviderConfigurator dynamicConfig =
150:                    //                    ProviderConfigurator.getConfigurator(WSC,
151:                    //                    fileConfig.getType(), AccessMethod.DYNAMIC,
152:                    //                    (ServerProperties) fileConfig.getValue(Configurable.SERVER_PROPERTIES));
153:
154:                    transferConfigurationData(fileConfig, dynamicConfig,
155:                            wscConfigurables);
156:
157:                    Boolean value = (Boolean) fileConfig
158:                            .getValue(Configurable.USE_DEFAULT_KEYSTORE);
159:                    if (value == Boolean.FALSE) {
160:                        transferConfigurationData(fileConfig, dynamicConfig,
161:                                keystoreConfigurables);
162:                    }
163:
164:                    if (isLiberty(fileConfig)) {
165:                        ArrayList list = new ArrayList();
166:                        list.add(getDiscoveryConfigurator(properties));
167:                        dynamicConfig.setValue(
168:                                Configurable.TRUST_AUTHORITY_CONFIG_LIST, list);
169:                    }
170:
171:                    dynamicConfig.save();
172:                }
173:
174:            }
175:
176:            private void deployWSPProviders() {
177:                Collection<ProviderConfigurator> fileConfigs = ProviderConfigurator
178:                        .getAllConfigurators(Type.WSP, AccessMethod.FILE,
179:                                amConfigXmlDir, amAsUrl);
180:
181:                for (ProviderConfigurator fileConfig : fileConfigs) {
182:                    log("Deploying wsp provider "
183:                            + fileConfig.getProviderName()); //NOI18N
184:
185:                    ServerInstance instance = ServerManager.getDefault()
186:                            .getServerInstance(amAsUrl);
187:                    ServerProperties properties = instance
188:                            .getServerProperties();
189:
190:                    log("ServerProperties: " + properties); //NOI18N
191:
192:                    SecurityMechanism secMech = (SecurityMechanism) fileConfig
193:                            .getValue(Configurable.SECURITY_MECH);
194:
195:                    ProviderConfigurator dynamicConfig = ProviderConfigurator
196:                            .getConfigurator(secMech.getName(), Type.WSP,
197:                                    AccessMethod.DYNAMIC, properties, amAsUrl);
198:
199:                    transferConfigurationData(fileConfig, dynamicConfig,
200:                            wspConfigurables);
201:
202:                    if (isLiberty(fileConfig)) {
203:                        //
204:                        // Need to reset the security mechanism for the preconfigured
205:                        // liberty providers which are invalid.
206:                        //
207:                        dynamicConfig.setValue(Configurable.SECURITY_MECH,
208:                                secMech);
209:
210:                        // wsp endpoint cannot be null and cannot be empty
211:                        dynamicConfig.setValue(Configurable.WSP_ENDPOINT,
212:                                "http://wsc.com"); //NOI18N
213:
214:                        dynamicConfig.save();
215:
216:                        DiscoveryConfigurator discoveryConfig = getDiscoveryConfigurator(properties);
217:
218:                        log("Registering provider with Discovery Service"); //NOI18N
219:                        discoveryConfig.unregisterProvider(dynamicConfig);
220:                        discoveryConfig.registerProvider(dynamicConfig);
221:                    } else {
222:                        dynamicConfig.save();
223:                    }
224:                }
225:            }
226:
227:            private void transferConfigurationData(
228:                    ProviderConfigurator fromConfig,
229:                    ProviderConfigurator toConfig, Configurable[] configurables) {
230:                for (Configurable configurable : configurables) {
231:                    log(configurable + ": " + fromConfig.getValue(configurable)); //NOI18N
232:                    toConfig.setValue(configurable, fromConfig
233:                            .getValue(configurable));
234:                }
235:            }
236:
237:            private boolean isLiberty(ProviderConfigurator config) {
238:                SecurityMechanism secMech = (SecurityMechanism) config
239:                        .getValue(Configurable.SECURITY_MECH);
240:
241:                return secMech.isLiberty();
242:            }
243:
244:            private DiscoveryConfigurator getDiscoveryConfigurator(
245:                    ServerProperties properties) {
246:                if (discoveryConfig == null) {
247:                    discoveryConfig = (DiscoveryConfigurator) TrustAuthorityConfigurator
248:                            .getConfigurator(LOCAL_DISCO,
249:                                    TrustAuthorityConfigurator.Type.DISCOVERY,
250:                                    AccessMethod.DYNAMIC, properties);
251:
252:                    discoveryConfig
253:                            .setValue(
254:                                    TrustAuthorityConfigurator.Configurable.ENDPOINT,
255:                                    properties
256:                                            .getProperty(ServerProperties.PROP_LIBERTY_DISCO_SERVICE_URL));
257:                    discoveryConfig.save();
258:                }
259:
260:                return discoveryConfig;
261:            }
262:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.