Package org.opensaml.xml.security.credential

Examples of org.opensaml.xml.security.credential.BasicCredential


        if (key == null) {
            log.debug("Key supplied was null, could not build credential");
            return null;
        }

        BasicCredential basicCred = new BasicCredential();

        basicCred.getKeyNames().addAll(keyNames);

        if (key instanceof PublicKey) {
            basicCred.setPublicKey((PublicKey) key);
        } else if (key instanceof SecretKey) {
            basicCred.setSecretKey((SecretKey) key);
        } else if (key instanceof PrivateKey) {
            // This would be unusual for most KeyInfo use cases,
            // but go ahead and try and handle it
            PrivateKey privateKey = (PrivateKey) key;
            try {
                PublicKey publicKey = SecurityHelper.derivePublicKey(privateKey);
                if (publicKey != null) {
                    basicCred.setPublicKey(publicKey);
                    basicCred.setPrivateKey(privateKey);
                } else {
                    log.error("Failed to derive public key from private key");
                    return null;
                }
            } catch (KeyException e) {
View Full Code Here


     */
    public static BasicCredential getSimpleCredential(SecretKey secretKey) {
        if (secretKey == null) {
            throw new IllegalArgumentException("A secret key is required");
        }
        BasicCredential cred = new BasicCredential();
        cred.setSecretKey(secretKey);
        return cred;
    }
View Full Code Here

     */
    public static BasicCredential getSimpleCredential(PublicKey publicKey, PrivateKey privateKey) {
        if (publicKey == null) {
            throw new IllegalArgumentException("A public key is required");
        }
        BasicCredential cred = new BasicCredential();
        cred.setPublicKey(publicKey);
        cred.setPrivateKey(privateKey);
        return cred;
    }
View Full Code Here

     * @throws NoSuchProviderException provider not found
     */
    public static Credential generateKeyAndCredential(String algorithmURI)
            throws NoSuchAlgorithmException, NoSuchProviderException {
        SecretKey key = generateKeyFromURI(algorithmURI);
        BasicCredential credential = new BasicCredential();
        credential.setSecretKey(key);
        return credential;
    }
View Full Code Here

     * @throws NoSuchProviderException provider not found
     */
    public static Credential generateKeyPairAndCredential(String algorithmURI, int keyLength, boolean includePrivate)
            throws NoSuchAlgorithmException, NoSuchProviderException {
        KeyPair keyPair = generateKeyPairFromURI(algorithmURI, keyLength);
        BasicCredential credential = new BasicCredential();
        credential.setPublicKey(keyPair.getPublic());
        if (includePrivate) {
            credential.setPrivateKey(keyPair.getPrivate());
        }
        return credential;
    }
View Full Code Here

                        if(credentials == null){
                            continue;
                        }
                        for (Credential cred : creds) {
                            if (cred instanceof BasicCredential) {
                                BasicCredential basicCred = (BasicCredential) cred;
                                basicCred.setEntityId(entityID);
                                basicCred.setUsageType(mdUsage);
                                basicCred.getCredentalContextSet().add(new SAMLMDCredentialContext(keyDescriptor));
                            }
                            credentials.add(cred);
                        }
                    }
                }
View Full Code Here

                        if(credentials == null){
                            continue;
                        }
                        for (Credential cred : creds) {
                            if (cred instanceof BasicCredential) {
                                BasicCredential basicCred = (BasicCredential) cred;
                                basicCred.setEntityId(entityID);
                                basicCred.setUsageType(mdUsage);
                                basicCred.getCredentalContextSet().add(new SAMLMDCredentialContext(keyDescriptor));
                            }
                            credentials.add(cred);
                        }
                    }
                }
View Full Code Here

        if (key == null) {
            log.debug("Key supplied was null, could not build credential");
            return null;
        }

        BasicCredential basicCred = new BasicCredential();

        basicCred.getKeyNames().addAll(keyNames);

        if (key instanceof PublicKey) {
            basicCred.setPublicKey((PublicKey) key);
        } else if (key instanceof SecretKey) {
            basicCred.setSecretKey((SecretKey) key);
        } else if (key instanceof PrivateKey) {
            // This would be unusual for most KeyInfo use cases,
            // but go ahead and try and handle it
            PrivateKey privateKey = (PrivateKey) key;
            try {
                PublicKey publicKey = SecurityHelper.derivePublicKey(privateKey);
                if (publicKey != null) {
                    basicCred.setPublicKey(publicKey);
                    basicCred.setPrivateKey(privateKey);
                } else {
                    log.error("Failed to derive public key from private key");
                    return null;
                }
            } catch (KeyException e) {
View Full Code Here

            log.debug("Criteria specified key algorithm {}, actually {}, skipping",
                    algorithmCriteria.getKeyAlgorithm(), pubKey.getAlgorithm());
            return null;
        }

        BasicCredential cred = new BasicCredential();
        cred.setPublicKey(pubKey);
        if (kiContext != null) {
            cred.getKeyNames().addAll(kiContext.getKeyNames());
        }
       
        CredentialContext credContext = buildCredentialContext(kiContext);
        if (credContext != null) {
            cred.getCredentalContextSet().add(credContext);
        }

        log.debug("Credential successfully extracted from DEREncodedKeyValue");
        LazySet<Credential> credentialSet = new LazySet<Credential>();
        credentialSet.add(cred);
View Full Code Here

            pubKey = KeyInfoHelper.getRSAKey(keyValue);
        } catch (KeyException e) {
            log.error("Error extracting RSA key value", e);
            throw new SecurityException("Error extracting RSA key value", e);
        }
        BasicCredential cred = new BasicCredential();
        cred.setPublicKey(pubKey);
        if (kiContext != null) {
            cred.getKeyNames().addAll(kiContext.getKeyNames());
        }

        CredentialContext credContext = buildCredentialContext(kiContext);
        if (credContext != null) {
            cred.getCredentalContextSet().add(credContext);
        }

        log.debug("Credential successfully extracted from RSAKeyValue");
        LazySet<Credential> credentialSet = new LazySet<Credential>();
        credentialSet.add(cred);
View Full Code Here

TOP

Related Classes of org.opensaml.xml.security.credential.BasicCredential

Copyright © 2018 www.massapicom. 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.