Source Code Cross Referenced for AboutBundleData.java in  » IDE-Eclipse » ui-workbench » org » eclipse » ui » internal » about » 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 Eclipse » ui workbench » org.eclipse.ui.internal.about 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2004, 2007 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.ui.internal.about;
011:
012:        import java.io.IOException;
013:
014:        import org.eclipse.core.runtime.Platform;
015:        import org.eclipse.osgi.internal.provisional.verifier.CertificateVerifier;
016:        import org.eclipse.osgi.internal.provisional.verifier.CertificateVerifierFactory;
017:        import org.eclipse.ui.internal.WorkbenchMessages;
018:        import org.eclipse.ui.internal.WorkbenchPlugin;
019:        import org.osgi.framework.Bundle;
020:        import org.osgi.framework.BundleContext;
021:        import org.osgi.framework.Constants;
022:        import org.osgi.framework.ServiceReference;
023:
024:        /**
025:         * A small class to manage the about dialog information for a single bundle.
026:         * @since 3.0
027:         */
028:        public class AboutBundleData extends AboutData {
029:
030:            private Bundle bundle;
031:
032:            private boolean isSignedDetermined = false;
033:
034:            private boolean isSigned;
035:
036:            public AboutBundleData(Bundle bundle) {
037:                super (getResourceString(bundle, Constants.BUNDLE_VENDOR),
038:                        getResourceString(bundle, Constants.BUNDLE_NAME),
039:                        getResourceString(bundle, Constants.BUNDLE_VERSION),
040:                        bundle.getSymbolicName());
041:
042:                this .bundle = bundle;
043:
044:            }
045:
046:            public int getState() {
047:                return bundle.getState();
048:            }
049:
050:            /**
051:             * Return a string representation of the arugment state. Does not return
052:             * null.
053:             */
054:            public String getStateName() {
055:                switch (getState()) {
056:                case Bundle.INSTALLED:
057:                    return WorkbenchMessages.AboutPluginsDialog_state_installed;
058:                case Bundle.RESOLVED:
059:                    return WorkbenchMessages.AboutPluginsDialog_state_resolved;
060:                case Bundle.STARTING:
061:                    return WorkbenchMessages.AboutPluginsDialog_state_starting;
062:                case Bundle.STOPPING:
063:                    return WorkbenchMessages.AboutPluginsDialog_state_stopping;
064:                case Bundle.UNINSTALLED:
065:                    return WorkbenchMessages.AboutPluginsDialog_state_uninstalled;
066:                case Bundle.ACTIVE:
067:                    return WorkbenchMessages.AboutPluginsDialog_state_active;
068:                default:
069:                    return WorkbenchMessages.AboutPluginsDialog_state_unknown;
070:                }
071:            }
072:
073:            /**
074:             * A function to translate the resource tags that may be embedded in a
075:             * string associated with some bundle.
076:             * 
077:             * @param headerName
078:             *            the used to retrieve the correct string
079:             * @return the string or null if the string cannot be found
080:             */
081:            private static String getResourceString(Bundle bundle,
082:                    String headerName) {
083:                String value = (String) bundle.getHeaders().get(headerName);
084:                return value == null ? null : Platform.getResourceString(
085:                        bundle, value);
086:            }
087:
088:            public boolean isSignedDetermined() {
089:                return isSignedDetermined;
090:            }
091:
092:            public boolean isSigned() throws IllegalStateException {
093:
094:                if (isSignedDetermined)
095:                    return isSigned;
096:
097:                BundleContext bundleContext = WorkbenchPlugin.getDefault()
098:                        .getBundleContext();
099:                ServiceReference certRef = bundleContext
100:                        .getServiceReference(CertificateVerifierFactory.class
101:                                .getName());
102:                if (certRef == null)
103:                    throw new IllegalStateException();
104:                CertificateVerifierFactory certFactory = (CertificateVerifierFactory) bundleContext
105:                        .getService(certRef);
106:                try {
107:                    CertificateVerifier verifier = certFactory
108:                            .getVerifier(bundle);
109:                    isSigned = verifier.isSigned();
110:                    isSignedDetermined = true;
111:                    return isSigned;
112:                } catch (IOException e) {
113:                    throw (IllegalStateException) new IllegalStateException()
114:                            .initCause(e);
115:                } finally {
116:                    bundleContext.ungetService(certRef);
117:                }
118:            }
119:
120:            /**
121:             * @return
122:             */
123:            public Bundle getBundle() {
124:                return bundle;
125:            }
126:
127:            // private boolean isBundleSigned(Bundle bundle)
128:            //    {	
129:            //    	isSignedDetermined = true;
130:            //    	
131:            //    	boolean bRet = false;
132:            //    	if ( null != bundle.findEntries("META-INF", "*.SF", false) ) { //$NON-NLS-1$//$NON-NLS-2$
133:            //    		bRet = true;
134:            //    	}
135:            //    	return bRet;
136:            //    	
137:            //    	
138:            //    	/*
139:            //    	 * The below code features implementations that do more.
140:            //    	 */
141:            //   
142:            //    	
143:            //    /*	String loc = "";
144:            //    	
145:            //        StringTokenizer st = new StringTokenizer(this.location,"@");
146:            //       
147:            //        try
148:            //        {
149:            //        	st.nextToken();
150:            //        	loc = st.nextToken();
151:            //        }
152:            //        catch( NoSuchElementException e )
153:            //        {
154:            //        	return "Not a jar file";
155:            //        }
156:            //        if(! loc.endsWith(".jar"))
157:            //       	{
158:            //        	return "Not a jar file";
159:            //        }
160:            //        	
161:            //        try
162:            //        {
163:            //        	String fileLocation = Platform.getInstallLocation().getURL().getFile() + loc;
164:            //			JarFile jar = new JarFile( fileLocation );
165:            //				
166:            //			Enumeration e = jar.entries();
167:            //			/*ArrayList list = new ArrayList();
168:            //			byte[] buffer = new byte[8192];
169:            //			while( e.hasMoreElements())
170:            //			{
171:            //				JarEntry currentEntry = (JarEntry)e.nextElement();
172:            //				list.add(currentEntry);
173:            //				InputStream is = jar.getInputStream(currentEntry);
174:            //				while(( is.read(buffer, 0, buffer.length)) != -1 ){
175:            //					//can't get certificates until you read the whole dang thing.
176:            //				}
177:            //			if(is != null ) is.close();
178:            //			}
179:            //					
180:            //					
181:            //					int checked = 0;
182:            //					boolean signed =false;
183:            //					for( int index = 0; index < list.size(); index++ )
184:            //					{
185:            //						checked++;
186:            //						JarEntry je = (JarEntry)list.get(index);
187:            //						Certificate[] certs = je.getCertificates();
188:            //						if( certs != null )
189:            //						{
190:            //							//Something in this jar is signed by something!!
191:            //							signed = true;
192:            //							infoLine[5] = "Signed by "+certs[0].toString();
193:            //							break;
194:            //						}
195:            //						
196:            //					}
197:            //					if( !signed )
198:            //					{
199:            //						infoLine[5] = "Not signed";
200:            //					}
201:            //        		
202:            //			boolean isSigned = false;
203:            //        	while( e.hasMoreElements() )
204:            //        	{
205:            //        		JarEntry entry = (JarEntry)e.nextElement();
206:            //        		
207:            //        		if( entry.getName().matches("[mM][eE][tT][aA][-][iI][nN][fF]/.*[.][sS][fF]"))
208:            //        		{
209:            //        			isSigned = true;
210:            //        			break;
211:            //        		}
212:            //        		if( !entry.getName().matches("[mM][eE][tT][aA][-][iI][nN][fF].*"))
213:            //        		{
214:            //        			break;
215:            //        		}
216:            //        	}
217:            //        	return isSigned ? "Signed!" : "Not Signed.";
218:            //
219:            //		} catch (IOException e) {
220:            //			return "Couldn't open jar file: " + e.toString();
221:            //		} */
222:            //    }
223:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.