Java Security secretKey(final String key)

Here you can find the source of secretKey(final String key)

Description

secret Key

License

Apache License

Declaration

public static SecretKey secretKey(final String key) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import javax.crypto.SecretKey;
import javax.security.auth.DestroyFailedException;

public class Main {
    private static final String ALGO = "AES";

    public static SecretKey secretKey(final String key) {
        return new SecretKey() {
            private static final long serialVersionUID = -829558999158937420L;

            public String getAlgorithm() {
                return ALGO;
            }//from  www .  j av a 2s.co m

            public byte[] getEncoded() {
                return key.getBytes();
            }

            public String getFormat() {
                return "RAW";
            }

            @Override
            public void destroy() throws DestroyFailedException {
                // TODO Auto-generated method stub

            }

            @Override
            public boolean isDestroyed() {
                // TODO Auto-generated method stub
                return false;
            }
        };
    }
}

Related

  1. jaasConfig(String loginContextName, String key)
  2. jaasConfigOption(Configuration jaasConfig, String loginContextName, String key, String loginModuleName)
  3. kinit(String username, char[] password)
  4. logout()
  5. parseDirectives(byte[] buf)
  6. serializeKerberosTicket(KerberosTicket tgt)
  7. stringToByte_8859_1(String str, boolean useUTF8)
  8. ticketToCreds(KerberosTicket kerbTicket)
  9. tryDestroy(Object destroyable)