Examples of KeyGenerator


Examples of com.alvazan.orm.api.base.spi.KeyGenerator

    Method idMethod = getIdMethod(field);
   
    NoSqlId idAnno = field.getAnnotation(NoSqlId.class);
    MetaIdField<T> metaField = idMetaProvider.get();
    KeyGenerator gen = null;
    if(idAnno.usegenerator()) {
      Class<? extends KeyGenerator> generation = idAnno.generation();
      gen = ReflectionUtil.create(generation);
    }
   
View Full Code Here

Examples of com.google.gwt.i18n.rebind.keygen.KeyGenerator

            CtClass stringClass = classPool.get(String.class.getName());
            CtClass localeClass = classPool.get(Locale.class.getName());
            CtClass impl = classPool.makeClass(ifaceName+"Impl_"+locale.toString());
            impl.addInterface(iface);
           
            KeyGenerator keyGenerator = new MethodNameKeyGenerator();
            for(Object ann : iface.getAnnotations()) {
                if(ann instanceof GenerateKeys) {
                    String keyGeneratorClassName = ((GenerateKeys)ann).value();
                    Class<KeyGenerator> keyGeneratorClass;
                    try {
                        keyGeneratorClass = (Class<KeyGenerator>) Class.forName(keyGeneratorClassName);
                    } catch(ClassNotFoundException cnfe) {
                        keyGeneratorClass = (Class<KeyGenerator>) Class.forName(KeyGenerator.class.getName()+"."+keyGeneratorClassName);
                    }
                    keyGenerator = keyGeneratorClass.newInstance();
                }
            }
           
            ResourceBundle resBundle = ResourceBundle.getBundle(ifaceName, locale);
            CtConstructor ctorMethod = new CtConstructor(new CtClass[] {localeClass}, impl);
            impl.addConstructor(ctorMethod);
            ctorMethod.setModifiers(Modifier.PUBLIC);
            ctorMethod.setBody("super();");
            CtField localeField = new CtField(localeClass, "_locale", impl);
            impl.addField(localeField, CtField.Initializer.byParameter(0));
            TreeMap<String,String> keys = new TreeMap<String,String>();
            for(CtMethod method : iface.getMethods()) {
                // Only abstract methods
                if((method.getModifiers() & Modifier.ABSTRACT) == 0)
                    continue;
                CtMethod methodImpl = new CtMethod(method, impl, null);
                String methodKey = null;
                String meaning = null;
                String defaultValue = null;
                for(Object ann : method.getAnnotations()) {
                    if(ann instanceof Key) {
                        methodKey = ((Key)ann).value();
                    } else if(ann instanceof Meaning) {
                        meaning = ((Meaning)ann).value();
                    } else if(ann instanceof DefaultStringValue) {
                        defaultValue = ((DefaultStringValue)ann).value();
                    } else if(ann instanceof DefaultBooleanValue) {
                        defaultValue = String.valueOf(((DefaultBooleanValue)ann).value());
                    } else if(ann instanceof DefaultDoubleValue) {
                        defaultValue = String.valueOf(((DefaultDoubleValue)ann).value());
                    } else if(ann instanceof DefaultMessage) {
                        defaultValue = ((DefaultMessage)ann).value();
                    }
                }
                if(methodKey == null) {
                    methodKey = keyGenerator.generateKey(ifaceName, method.getName(), defaultValue, meaning);
                }
                String value;
                try {
                    value = resBundle.getString(methodKey);
                } catch (java.util.MissingResourceException mre) {
View Full Code Here

Examples of com.google.gwt.i18n.server.KeyGenerator

   *           annotations
   */
  public AnnotationsResource(TreeLogger logger, JClassType clazz,
      GwtLocale locale, boolean isConstants) throws AnnotationsError {
    super(locale);
    KeyGenerator keyGenerator = getKeyGenerator(clazz);
    map = new HashMap<String, MethodEntry>();
    setPath(clazz.getQualifiedSourceName());
    String defLocaleValue = null;
   
    // If the class has an embedded locale in it, use that for the default
    String className = clazz.getSimpleSourceName();
    int underscore = className.indexOf('_');
    if (underscore >= 0) {
      defLocaleValue = className.substring(underscore + 1);
    }
   
    // If there is an annotation declaring the default locale, use that
    DefaultLocale defLocaleAnnot = getClassAnnotation(clazz,
        DefaultLocale.class);
    if (defLocaleAnnot != null) {
      defLocaleValue = defLocaleAnnot.value();
    }
    GwtLocale defLocale = LocaleUtils.getLocaleFactory().fromString(
        defLocaleValue);
    if (!locale.isDefault() && !locale.equals(defLocale)) {
      logger.log(TreeLogger.WARN, "Default locale " + defLocale + " on "
          + clazz.getQualifiedSourceName() + " doesn't match " + locale);
      return;
    }
    matchLocale = defLocale;
    for (JMethod method : clazz.getMethods()) {
      String meaningString = null;
      Meaning meaning = method.getAnnotation(Meaning.class);
      if (meaning != null) {
        meaningString = meaning.value();
      }
      String textString = getTextString(method, map, isConstants);
      if (textString == null) {
        // ignore ones without some value annotation
        continue;
      }
      String key = null;
      Key keyAnnot = method.getAnnotation(Key.class);
      if (keyAnnot != null) {
        key = keyAnnot.value();
      } else {
        Message msg = new KeyGenMessage(method);
        key = keyGenerator.generateKey(msg);
        if (key == null) {
          throw new AnnotationsError("Could not compute key for "
              + method.getEnclosingType().getQualifiedSourceName() + "."
              + method.getName() + " using " + keyGenerator);
        }
View Full Code Here

Examples of fr.jayasoft.crypto.keys.KeyGenerator

    }
   
    public void doTestAlgo(String algo) {
      System.out.println("Testing: " + algo);
        Crypto c = CryptoFactory.get(algo);
        KeyGenerator kg = c.getKeyGenerator();
        Encoder e = c.newEncoder(kg.getEncodingKey());
        Decoder d = c.newDecoder(kg.getDecodingKey());
       
        encodeDecodeProperties(e,d);
    }
View Full Code Here

Examples of javax.crypto.KeyGenerator

  private static final Key generateBlowfishKey()
  {
    Key key = null;
    try {
      KeyGenerator keyGenerator = KeyGenerator.getInstance("Blowfish");
      keyGenerator.init(128);
      key = keyGenerator.generateKey();
    } catch (Exception e) {
      logger.error("[generateBlowfishKey] Exception thrown.", e);
    }
    return key;
  } //end of generateBlowfishKey method
View Full Code Here

Examples of javax.crypto.KeyGenerator

    if ( transport.supportsStorage()){
     
      try{
        spoof_cipher = Cipher.getInstance("DESede/ECB/PKCS5Padding");
     
        KeyGenerator keyGen = KeyGenerator.getInstance("DESede");
     
        spoof_key = keyGen.generateKey();
 
      }catch( Throwable e ){
       
        Debug.printStackTrace( e );
       
View Full Code Here

Examples of javax.crypto.KeyGenerator

    RSAPublicKey  public_key )
 
    throws IOException
  {
    try{
      KeyGenerator secret_key_gen = KeyGenerator.getInstance("DESede");
   
      session_key = secret_key_gen.generateKey();
       
      byte[] secret_bytes = session_key.getEncoded();
     
      try{
        Cipher  rsa_cipher = Cipher.getInstance( "RSA" );
View Full Code Here

Examples of javax.crypto.KeyGenerator

     *
     * @return a non null instance
     * @throws NoSuchAlgorithmException
     */
    protected SecretKey getEncryptionKey() throws NoSuchAlgorithmException {
        KeyGenerator keyGen = KeyGenerator.getInstance("DESede");
        keyGen.init(RANDOM);
        return keyGen.generateKey();
    }
View Full Code Here

Examples of javax.crypto.KeyGenerator

     */
    @PostConstruct
    public final DES3CiphererDecipherer init() throws Exception {
        Security.addProvider(new BouncyCastleProvider());
        cipherer = Cipher.getInstance("DESede/ECB/PKCS5Padding", "BC");
        KeyGenerator keyGen = KeyGenerator.getInstance("DESede");
        keyGen.init(168);
        SecretKey key = keyGen.generateKey();
        cipherer.init(Cipher.ENCRYPT_MODE, key);
        decipherer = Cipher.getInstance("DESede/ECB/PKCS5Padding", "BC");
        decipherer.init(Cipher.DECRYPT_MODE, key);
        if (log.isDebugEnabled()) log.debug("Cryptography loaded with [DESede/ECB/PKCS5Padding] algorityhms and initialized");
        return this;
View Full Code Here

Examples of javax.crypto.KeyGenerator

    protected static SecretKey generateMacKey(String algorithm, int keySize)
    {
        try
        {
            KeyGenerator keyGen = KeyGenerator.getInstance(algorithm);

            keyGen.init(keySize);

            return keyGen.generateKey();
        }
        catch (NoSuchAlgorithmException e)
        {
            _log.error("Unsupported algorithm: " + algorithm + ", size: " + keySize, e);
            return null;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.