Examples of HmacSHA1


Examples of ca.coolman.auth.oauth1.HmacSha1

  }

  private LinkedInServiceProvider(String id) {
    super((id == null) ? "twitter" : id, BASEURL
        + "requestToken", BASEURL + "accessToken",
        BASEURL + "authenticate", BASEURL + "authorize", new HmacSha1());
  }
View Full Code Here

Examples of ca.coolman.auth.oauth1.HmacSha1

  }

  private TwitterServiceProvider(String id, String protocol) {
    super((id == null) ? "twitter" : id, protocol + BASEURL
        + "request_token", protocol + BASEURL + "access_token",
        protocol + BASEURL + "authenticate", protocol + BASEURL + "authenticate", new HmacSha1());
  }
View Full Code Here

Examples of com.sun.xml.ws.security.opt.crypto.dsig.internal.HmacSHA1

            reqsalt[i] = salt[i];
        }
        keyof160bits = generate160BitKey(password, iteration, reqsalt);
        keySpec = new SecretKeySpec(keyof160bits, "AES");

        HmacSHA1 mac = new HmacSHA1();
        mac.init((Key) keySpec, keylength);
        mac.update(data);

        byte[] signature = mac.sign();

        return signature;

    }
View Full Code Here

Examples of com.sun.xml.ws.security.opt.crypto.dsig.internal.HmacSHA1

       
        receivedsalt[0]=01;
        byte[] keyof160bits = generate160BitKey(password, iterate, receivedsalt);
        SecretKey keySpec = new SecretKeySpec(keyof160bits, "AES");

        HmacSHA1 mac = new HmacSHA1();
        mac.init(keySpec, keylength);
        mac.update(data);

        byte[] signature = mac.sign();
        return MessageDigest.isEqual(receivedSignature,signature);

    }
View Full Code Here

Examples of com.sun.xml.ws.security.opt.crypto.dsig.internal.HmacSHA1

    public byte []  performHMACSign(Key key,SignedInfo signedInfo, int outputLength) throws InvalidKeyException{
       
        if (key == null || signedInfo == null) {
            throw new NullPointerException();
        }
        HmacSHA1 hmac = new HmacSHA1();
        hmac.init(key, outputLength);
       
        MacOutputStream macOutputStream = new MacOutputStream(hmac);
        Marshaller marshaller;
        try {
            marshaller = getMarshaller();
            _exc14nCanonicalizer.reset();
            setNamespaceAndPrefixList();
            _exc14nCanonicalizer.setStream(macOutputStream);
            marshaller.marshal(signedInfo,_exc14nCanonicalizer);
            if(logger.isLoggable(Level.FINEST)){
                marshaller = getMarshaller();
                _exc14nCanonicalizer.reset();
                setNamespaceAndPrefixList();
                ByteArrayOutputStream bos = new ByteArrayOutputStream();
                _exc14nCanonicalizer.setStream(bos);
                marshaller.marshal(signedInfo,_exc14nCanonicalizer);
                logger.log(Level.FINEST, LogStringsMessages.WSS_1756_CANONICALIZED_SIGNEDINFO_VALUE(bos.toString()));
            }
        } catch (JAXBException ex) {
            throw new XWSSecurityRuntimeException(ex);
        }
        try {
            return hmac.sign();
           
        } catch (SignatureException se) {
            // should never occur!
            throw new RuntimeException(se.getMessage());
        }
View Full Code Here

Examples of com.sun.xml.ws.security.opt.crypto.dsig.internal.HmacSHA1

    public boolean verifyHMACSignature(Key key,SignedInfo si,byte [] signatureValue,
            int outputLength) throws InvalidKeyException, SignatureException{
        if (key == null || si == null || signatureValue == null) {
            throw new NullPointerException("key, signedinfo or signature data can't be null");
        }
        HmacSHA1 hmac = new HmacSHA1();
        hmac.init(key, outputLength);
       
        MacOutputStream mos = new MacOutputStream(hmac);
        if(si.getSignedInfo() != null){
            XMLStreamReaderEx signedInfo = (XMLStreamReaderEx) si.getSignedInfo();
            if(_exc14nSBCanonicalizer == null){
                _exc14nSBCanonicalizer = new EXC14nStAXReaderBasedCanonicalizer();
            }
            NamespaceContextEx nsContext = signedInfo.getNamespaceContext();
            Iterator<NamespaceContextEx.Binding>  itr = nsContext.iterator();
            ArrayList list = new ArrayList();
            while(itr.hasNext()){
                NamespaceContextEx.Binding binding = itr.next();
                AttributeNS ans = new AttributeNS();
                ans.setPrefix( binding.getPrefix());
                ans.setUri(binding.getNamespaceURI());
                list.add(ans);
            }
           
            _exc14nSBCanonicalizer.addParentNamespaces(list);
            _exc14nSBCanonicalizer.addParentNamespaces(list);
           
            try {
                _exc14nSBCanonicalizer.canonicalize(signedInfo,mos,null);
            } catch (XMLStreamException ex) {
                logger.log(Level.SEVERE, LogStringsMessages.WSS_1724_SIGTYPE_VERIFICATION_FAILED("HMAC_SHA1"));
                throw new SignatureException(LogStringsMessages.WSS_1724_SIGTYPE_VERIFICATION_FAILED("HMAC_SHA1"),ex);
            } catch (IOException ex) {
                logger.log(Level.SEVERE, LogStringsMessages.WSS_1724_SIGTYPE_VERIFICATION_FAILED("HMAC_SHA1"));
                throw new SignatureException(LogStringsMessages.WSS_1724_SIGTYPE_VERIFICATION_FAILED("HMAC_SHA1"),ex);
            }
        }else{
            mos.write(si.getCanonicalizedSI());
        }
        return  hmac.verify(signatureValue);
    }
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.