OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [classpath/] [gnu/] [javax/] [crypto/] [key/] [KeyAgreementFactory.java] - Blame information for rev 769

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 769 jeremybenn
/* KeyAgreementFactory.java --
2
   Copyright (C) 2003, 2006 Free Software Foundation, Inc.
3
 
4
This file is a part of GNU Classpath.
5
 
6
GNU Classpath is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2 of the License, or (at
9
your option) any later version.
10
 
11
GNU Classpath is distributed in the hope that it will be useful, but
12
WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
General Public License for more details.
15
 
16
You should have received a copy of the GNU General Public License
17
along with GNU Classpath; if not, write to the Free Software
18
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
19
USA
20
 
21
Linking this library statically or dynamically with other modules is
22
making a combined work based on this library.  Thus, the terms and
23
conditions of the GNU General Public License cover the whole
24
combination.
25
 
26
As a special exception, the copyright holders of this library give you
27
permission to link this library with independent modules to produce an
28
executable, regardless of the license terms of these independent
29
modules, and to copy and distribute the resulting executable under
30
terms of your choice, provided that you also meet, for each linked
31
independent module, the terms and conditions of the license of that
32
module.  An independent module is a module which is not derived from
33
or based on this library.  If you modify this library, you may extend
34
this exception to your version of the library, but you are not
35
obligated to do so.  If you do not wish to do so, delete this
36
exception statement from your version.  */
37
 
38
 
39
package gnu.javax.crypto.key;
40
 
41
import gnu.java.security.Registry;
42
 
43
import gnu.javax.crypto.key.dh.DiffieHellmanSender;
44
import gnu.javax.crypto.key.dh.DiffieHellmanReceiver;
45
import gnu.javax.crypto.key.dh.ElGamalSender;
46
import gnu.javax.crypto.key.dh.ElGamalReceiver;
47
import gnu.javax.crypto.key.srp6.SRP6Host;
48
import gnu.javax.crypto.key.srp6.SRP6User;
49
import gnu.javax.crypto.key.srp6.SRP6SaslClient;
50
import gnu.javax.crypto.key.srp6.SRP6SaslServer;
51
import gnu.javax.crypto.key.srp6.SRP6TLSClient;
52
import gnu.javax.crypto.key.srp6.SRP6TLSServer;
53
 
54
import java.util.Collections;
55
import java.util.HashSet;
56
import java.util.Set;
57
 
58
/**
59
 * A <i>Factory</i> class to generate key agreement protocol handlers.
60
 */
61
public class KeyAgreementFactory
62
{
63
  /** Trivial constructor to enforce <i>Singleton</i> pattern. */
64
  private KeyAgreementFactory()
65
  {
66
    super();
67
  }
68
 
69
  /**
70
   * Returns an instance of a key agreeent protocol handler, for party
71
   * <code>A</code> in a two-party <code>A..B</code> exchange, given the
72
   * canonical name of this protocol. Party <code>A</code> is usually the
73
   * initiator of the exchange.
74
   *
75
   * @param name the case-insensitive key agreement protocol name.
76
   * @return an instance of the key agreement protocol handler for party
77
   *         <code>A</code>, or <code>null</code> if none found.
78
   */
79
  public static IKeyAgreementParty getPartyAInstance(String name)
80
  {
81
    if (name == null)
82
      return null;
83
    name = name.trim();
84
    IKeyAgreementParty result = null;
85
    if (name.equalsIgnoreCase(Registry.DH_KA))
86
      result = new DiffieHellmanSender();
87
    else if (name.equalsIgnoreCase(Registry.ELGAMAL_KA))
88
      result = new ElGamalSender();
89
    else if (name.equalsIgnoreCase(Registry.SRP6_KA))
90
      result = new SRP6User();
91
    else if (name.equalsIgnoreCase(Registry.SRP_SASL_KA))
92
      result = new SRP6SaslClient();
93
    else if (name.equalsIgnoreCase(Registry.SRP_TLS_KA))
94
      result = new SRP6TLSClient();
95
    return result;
96
  }
97
 
98
  /**
99
   * Returns an instance of a key agreeent protocol handler, for party
100
   * <code>B</code> in a two-party <code>A..B</code> exchange, given the
101
   * canonical name of this protocol.
102
   *
103
   * @param name the case-insensitive key agreement protocol name.
104
   * @return an instance of the key agreement protocol handler for party
105
   *         <code>B</code>, or <code>null</code> if none found.
106
   */
107
  public static IKeyAgreementParty getPartyBInstance(String name)
108
  {
109
    if (name == null)
110
      return null;
111
    name = name.trim();
112
    IKeyAgreementParty result = null;
113
    if (name.equalsIgnoreCase(Registry.DH_KA))
114
      result = new DiffieHellmanReceiver();
115
    else if (name.equalsIgnoreCase(Registry.ELGAMAL_KA))
116
      result = new ElGamalReceiver();
117
    else if (name.equalsIgnoreCase(Registry.SRP6_KA))
118
      result = new SRP6Host();
119
    else if (name.equalsIgnoreCase(Registry.SRP_SASL_KA))
120
      result = new SRP6SaslServer();
121
    else if (name.equalsIgnoreCase(Registry.SRP_TLS_KA))
122
      result = new SRP6TLSServer();
123
    return result;
124
  }
125
 
126
  /**
127
   * Returns a {@link Set} of key agreement protocol names supported by this
128
   * <i>Factory</i>.
129
   *
130
   * @return a {@link Set} of key agreement protocol names (Strings).
131
   */
132
  public static final Set getNames()
133
  {
134
    HashSet hs = new HashSet();
135
    hs.add(Registry.DH_KA);
136
    hs.add(Registry.ELGAMAL_KA);
137
    hs.add(Registry.SRP6_KA);
138
    hs.add(Registry.SRP_SASL_KA);
139
    hs.add(Registry.SRP_TLS_KA);
140
 
141
    return Collections.unmodifiableSet(hs);
142
  }
143
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.