Examples of TechnicalException


Examples of org.pac4j.core.exception.TechnicalException

            return CommonHelper.class.getResourceAsStream(path);
        } else {
            try {
                return new FileInputStream(name);
            } catch (FileNotFoundException e) {
                throw new TechnicalException(e);
            }
        }
    }
View Full Code Here

Examples of org.pac4j.core.exception.TechnicalException

    private final int green;
    private final int blue;
   
    public Color(final int red, final int green, final int blue) {
        if (red < 0 || red > 255 || green < 0 || green > 255 || blue < 0 || blue > 255)
            throw new TechnicalException("Color's red, green or blue values must be between 0 and 255.");
        this.red = red;
        this.green = green;
        this.blue = blue;
    }
View Full Code Here

Examples of org.pac4j.core.exception.TechnicalException

                    "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
            velocityEngine.setProperty(VelocityEngine.RUNTIME_LOG_LOGSYSTEM, new JdkLogChute());
            velocityEngine.init();
            return velocityEngine;
        } catch (Exception e) {
            throw new TechnicalException("Error configuring velocity", e);
        }

    }
View Full Code Here

Examples of org.pac4j.core.exception.TechnicalException

        CommonHelper.assertTrue(
                CommonHelper.isNotBlank(this.idpMetadata) || CommonHelper.isNotBlank(this.idpMetadataPath),
                "Either idpMetadata or idpMetadataPath must be provided");
        CommonHelper.assertNotBlank("callbackUrl", this.callbackUrl);
        if (!this.callbackUrl.startsWith("http")) {
            throw new TechnicalException("SAML callbackUrl must be absolute");
        }

        if (CommonHelper.isNotBlank(this.keystorePath) || CommonHelper.isNotBlank(this.keystorePassword)
                || CommonHelper.isNotBlank(this.privateKeyPassword)) {
            CommonHelper.assertNotBlank("keystorePath", this.keystorePath);
            CommonHelper.assertNotBlank("keystorePassword", this.keystorePassword);
            CommonHelper.assertNotBlank("privateKeyPassword", this.privateKeyPassword);

            // load private key from the keystore and provide it as OpenSAML credentials
            this.credentialProvider = new CredentialProvider(this.keystorePath, this.keystorePassword,
                    this.privateKeyPassword);
            this.decrypter = new EncryptionProvider(this.credentialProvider).buildDecrypter();
        }

        // Bootstrap OpenSAML
        try {
            DefaultBootstrap.bootstrap();
            NamedKeyInfoGeneratorManager manager = Configuration.getGlobalSecurityConfiguration()
                    .getKeyInfoGeneratorManager();
            X509KeyInfoGeneratorFactory generator = new X509KeyInfoGeneratorFactory();
            generator.setEmitEntityCertificate(true);
            generator.setEmitEntityCertificateChain(true);
            manager.registerFactory(Saml2Client.SAML_METADATA_KEY_INFO_GENERATOR, generator);
        } catch (ConfigurationException e) {
            throw new SamlException("Error bootstrapping OpenSAML", e);
        }

        // required parserPool for XML processing
        final StaticBasicParserPool parserPool = newStaticBasicParserPool();
        final AbstractMetadataProvider idpMetadataProvider = idpMetadataProvider(parserPool);

        final XMLObject md;
        try {
            md = idpMetadataProvider.getMetadata();
        } catch (MetadataProviderException e) {
            throw new SamlException("Error initializing idpMetadataProvider", e);
        }

        // If no idpEntityId declared, select first EntityDescriptor entityId as our IDP entityId
        if (this.idpEntityId == null) {
            this.idpEntityId = getIdpEntityId(md);
        }

        // Generate our Service Provider metadata
        Saml2MetadataGenerator metadataGenerator = new Saml2MetadataGenerator();
        if (this.credentialProvider != null) {
            metadataGenerator.setCredentialProvider(this.credentialProvider);
            metadataGenerator.setAuthnRequestSigned(true);
        }
        // If the spEntityId is blank, use the callback url
        if (CommonHelper.isBlank(this.spEntityId)) {
            this.spEntityId = getCallbackUrl();
        }
        metadataGenerator.setEntityId(this.spEntityId);
        // Assertion consumer service url is the callback url
        metadataGenerator.setAssertionConsumerServiceUrl(getCallbackUrl());
        // for now same for logout url
        metadataGenerator.setSingleLogoutServiceUrl(getCallbackUrl());
        AbstractMetadataProvider spMetadataProvider = metadataGenerator.buildMetadataProvider();

        // Initialize metadata provider for our SP and get the XML as a String
        try {
            spMetadataProvider.initialize();
            this.spMetadata = metadataGenerator.printMetadata();
        } catch (MetadataProviderException e) {
            throw new TechnicalException("Error initializing spMetadataProvider", e);
        } catch (MarshallingException e) {
            logger.warn("Unable to print SP metadata", e);
        }

        // Put IDP and SP metadata together
        ChainingMetadataProvider metadataManager = new ChainingMetadataProvider();
        try {
            metadataManager.addMetadataProvider(idpMetadataProvider);
            metadataManager.addMetadataProvider(spMetadataProvider);
        } catch (MetadataProviderException e) {
            throw new TechnicalException("Error adding idp or sp metadatas to manager", e);
        }

        // Build the contextProvider
        this.contextProvider = new Saml2ContextProvider(metadataManager, this.idpEntityId, this.spEntityId);
View Full Code Here

Examples of org.pac4j.core.exception.TechnicalException

            idpMetadataProvider.setParserPool(parserPool);
            idpMetadataProvider.initialize();
        } catch (MetadataProviderException e) {
            throw new SamlException("Error initializing idpMetadataProvider", e);
        } catch (XMLParserException e) {
            throw new TechnicalException("Error parsing idp Metadata", e);
        } catch (ResourceException e) {
            throw new TechnicalException("Error getting idp Metadata resource", e);
        }
        return idpMetadataProvider;
    }
View Full Code Here

Examples of org.pac4j.core.exception.TechnicalException

    @Override
    protected RedirectAction retrieveRedirectAction(final WebContext context) {
        try {
            return RedirectAction.redirect(retrieveAuthorizationUrl(context));
        } catch (final OAuthException e) {
            throw new TechnicalException(e);
        }
    }
View Full Code Here

Examples of org.pac4j.core.exception.TechnicalException

                throw oauthCredentialsException;
            } else {
                return getOAuthCredentials(context);
            }
        } catch (final OAuthException e) {
            throw new TechnicalException(e);
        }
    }
View Full Code Here

Examples of org.pac4j.core.exception.TechnicalException

    protected U retrieveUserProfile(final OAuthCredentials credentials, final WebContext context) {
        try {
            final Token token = getAccessToken(credentials);
            return retrieveUserProfileFromToken(token);
        } catch (final OAuthException e) {
            throw new TechnicalException(e);
        }
    }
View Full Code Here

Examples of org.pac4j.core.exception.TechnicalException

        init();
        try {
            final Token token = new Token(accessToken, "");
            return retrieveUserProfileFromToken(token);
        } catch (final OAuthException e) {
            throw new TechnicalException(e);
        }
    }
View Full Code Here

Examples of org.pac4j.core.exception.TechnicalException

      @Override
      public void execute(Throwable ex) throws Exception {
        if (ex instanceof RequiresHttpAction) {
          webContext.sendResponse((RequiresHttpAction) ex);
        } else {
          throw new TechnicalException("Failed to redirect", ex);
        }
      }
    }).then(new Action<Void>() {
      @Override
      public void execute(Void ignored) throws Exception {
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.