Gets data encryption parameters.

@param samlObject the saml object
@param service    the service
@param adaptor    the adaptor
@return the data encryption parameters
960967
protected DataEncryptionParameters getDataEncryptionParameters(final Object samlObject,
                                                                   final SamlRegisteredService service,
                                                                   final SamlRegisteredServiceServiceProviderMetadataFacade adaptor) {
        val dataEncParams = new DataEncryptionParameters();
        dataEncParams.setAlgorithm(EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES128);
        return dataEncParams;
    }
542751
@SneakyThrows
    protected String constructServiceUrl(final HttpServletRequest request,
                                         final HttpServletResponse response,
                                         final Pair<? extends SignableSAMLObject, MessageContext> pair) throws SamlException {
        val authnRequest = (AuthnRequest) pair.getLeft();
        val messageContext = pair.getRight();

        try (val writer = SamlUtils.transformSamlObject(samlProfileHandlerConfigurationContext.getOpenSamlConfigBean(), authnRequest)) {
            val builder = new URLBuilder(samlProfileHandlerConfigurationContext.getCallbackService().getId());
            builder.getQueryParams().add(
                new net.shibboleth.utilities.java.support.collection.Pair<>(SamlProtocolConstants.PARAMETER_ENTITY_ID,
                    SamlIdPUtils.getIssuerFromSamlObject(authnRequest)));

            val samlRequest = EncodingUtils.encodeBase64(writer.toString().getBytes(StandardCharsets.UTF_8));
            builder.getQueryParams().add(
                new net.shibboleth.utilities.java.support.collection.Pair<>(SamlProtocolConstants.PARAMETER_SAML_REQUEST,
                    samlRequest));
            builder.getQueryParams().add(
                new net.shibboleth.utilities.java.support.collection.Pair<>(SamlProtocolConstants.PARAMETER_SAML_RELAY_STATE,
                    SAMLBindingSupport.getRelayState(messageContext)));
            val url = builder.buildURL();

            LOGGER.trace("Built service callback url [{}]", url);
            return CommonUtils.constructServiceUrl(request, response,
                url, samlProfileHandlerConfigurationContext.getCasProperties().getServer().getName(),
                CasProtocolConstants.PARAMETER_SERVICE,
                CasProtocolConstants.PARAMETER_TICKET, false);
        }
    }
92660
@Override
    public SecurityMetadata getSecurityMetadata() {
        SecurityMetadata sm = super.getSecurityMetadata();
        if (sm == null) {
            return getDefaultAdminSecurityMetadata();
        } else {
            return sm;
        }
    }
1118644
protected String constructSamlResponse(final GoogleAccountsService service,
                                           final Authentication authentication) {
        val currentDateTime = ZonedDateTime.now(ZoneOffset.UTC);
        val notBeforeIssueInstant = ZonedDateTime.parse("2003-04-17T00:46:02Z");
        val registeredService = servicesManager.findServiceBy(service);
        if (registeredService == null || !registeredService.getAccessStrategy().isServiceAccessAllowed()) {
            throw new UnauthorizedServiceException(UnauthorizedServiceException.CODE_UNAUTHZ_SERVICE);
        }

        val principal = authentication.getPrincipal();
        val userId = registeredService.getUsernameAttributeProvider()
            .resolveUsername(principal, service, registeredService);

        val response = this.samlObjectBuilder.newResponse(
            this.samlObjectBuilder.generateSecureRandomId(), currentDateTime, null, service);
        response.setStatus(this.samlObjectBuilder.newStatus(StatusCode.SUCCESS, null));

        val sessionIndex = '_' + String.valueOf(RandomUtils.nextLong());
        val authnStatement = this.samlObjectBuilder.newAuthnStatement(AuthnContext.PASSWORD_AUTHN_CTX, currentDateTime, sessionIndex);
        val assertion = this.samlObjectBuilder.newAssertion(authnStatement, casServerPrefix,
            notBeforeIssueInstant, this.samlObjectBuilder.generateSecureRandomId());

        val conditions = this.samlObjectBuilder.newConditions(notBeforeIssueInstant,
            currentDateTime.plusSeconds(this.skewAllowance), service.getId());
        assertion.setConditions(conditions);

        val subject = this.samlObjectBuilder.newSubject(NameID.EMAIL, userId,
            service.getId(), currentDateTime.plusSeconds(this.skewAllowance), service.getRequestId(), null);
        assertion.setSubject(subject);

        response.getAssertions().add(assertion);

        val result = SamlUtils.transformSamlObject(this.samlObjectBuilder.getOpenSamlConfigBean(), response, true).toString();
        LOGGER.debug("Generated Google SAML response: [{}]", result);
        return result;
    }
192000
public static sslcipher[] get(nitro_service service) throws Exception{
		sslcipher obj = new sslcipher();
		sslcipher[] response = (sslcipher[])obj.get_resources(service);
		return response;
	}
172131
protected InputStream getBase64DecodedMessage(HTTPInTransport transport) throws MessageDecodingException {
        log.debug("Getting Base64 encoded message from request");
        String encodedMessage = transport.getParameterValue("assertion");


        if (DatatypeHelper.isEmpty(encodedMessage)) {
            log.error("Request did not contain either a SAMLRequest or "
                          + "SAMLResponse paramter.  Invalid request for SAML 2 HTTP POST binding.");
            throw new MessageDecodingException("No SAML message present in request");
        }

        log.trace("Base64 decoding SAML message:\n{}", encodedMessage);
        byte[] decodedBytes = org.apache.commons.codec.binary.Base64.decodeBase64(encodedMessage.getBytes(StandardCharsets.UTF_8));
        if(decodedBytes == null){
            log.error("Unable to Base64 decode SAML message");
            throw new MessageDecodingException("Unable to Base64 decode SAML message");
        }

        log.trace("Decoded SAML message:\n{}", new String(decodedBytes));
        return new ByteArrayInputStream(decodedBytes);
    }
1231966
@SneakyThrows
    @SuppressFBWarnings("PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS")
    public static MetadataResolver getMetadataResolverForAllSamlServices(final ServicesManager servicesManager,
                                                                         final String entityID,
                                                                         final SamlRegisteredServiceCachingMetadataResolver resolver) {

        val registeredServices = servicesManager.findServiceBy(SamlRegisteredService.class::isInstance);
        val chainingMetadataResolver = new ChainingMetadataResolver();

        val resolvers = registeredServices.stream()
            .filter(SamlRegisteredService.class::isInstance)
            .map(SamlRegisteredService.class::cast)
            .map(s -> SamlRegisteredServiceServiceProviderMetadataFacade.get(resolver, s, entityID))
            .filter(Optional::isPresent)
            .map(Optional::get)
            .map(SamlRegisteredServiceServiceProviderMetadataFacade::getMetadataResolver)
            .collect(Collectors.toList());

        LOGGER.debug("Located [{}] metadata resolvers to match against [{}]", resolvers, entityID);

        chainingMetadataResolver.setResolvers(resolvers);
        chainingMetadataResolver.setId(entityID);
        chainingMetadataResolver.initialize();
        return chainingMetadataResolver;
    }
1230384
def make_secure_adaptor(service, mod, client_id, client_secret, tok_update_sec=None):
        
        if mod == 'TVM':
            return SecureServiceAdaptor(service, TVM(client_id, client_secret), tok_update_sec)

        return SecureServiceAdaptor(service, Promiscuous(), tok_update_sec)
1316898
@SuppressWarnings("unchecked")
    static <T extends SAMLObject> MessageContext<T> toSamlObject(
            AggregatedHttpMessage msg, String name,
            Map<String, SamlIdentityProviderConfig> idpConfigs,
            @Nullable SamlIdentityProviderConfig defaultIdpConfig) {
        requireNonNull(msg, "msg");
        requireNonNull(name, "name");
        requireNonNull(idpConfigs, "idpConfigs");

        final SamlParameters parameters = new SamlParameters(msg);
        final T message = (T) fromDeflatedBase64(parameters.getFirstValue(name));

        final MessageContext<T> messageContext = new MessageContext<>();
        messageContext.setMessage(message);

        final Issuer issuer;
        if (message instanceof RequestAbstractType) {
            issuer = ((RequestAbstractType) message).getIssuer();
        } else if (message instanceof StatusResponseType) {
            issuer = ((StatusResponseType) message).getIssuer();
        } else {
            throw new SamlException("invalid message type: " + message.getClass().getSimpleName());
        }

        // Use the default identity provider config if there's no issuer.
        final SamlIdentityProviderConfig config;
        if (issuer != null) {
            final String idpEntityId = issuer.getValue();
            config = idpConfigs.get(idpEntityId);
            if (config == null) {
                throw new SamlException("a message from unknown identity provider: " + idpEntityId);
            }
        } else {
            if (defaultIdpConfig == null) {
                throw new SamlException("failed to get an Issuer element");
            }
            config = defaultIdpConfig;
        }

        // If this message is sent via HTTP-redirect binding protocol, its signature parameter should
        // be validated.
        validateSignature(config.signingCredential(), parameters, name);

        final String relayState = parameters.getFirstValueOrNull(RELAY_STATE);
        if (relayState != null) {
            final SAMLBindingContext context = messageContext.getSubcontext(SAMLBindingContext.class, true);
            assert context != null;
            context.setRelayState(relayState);
        }

        return messageContext;
    }
1123236
public static void preparePeerEntitySamlEndpointContext(final RequestAbstractType request,
                                                            final MessageContext outboundContext,
                                                            final SamlRegisteredServiceServiceProviderMetadataFacade adaptor,
                                                            final String binding) throws SamlException {
        val entityId = adaptor.getEntityId();
        if (!adaptor.containsAssertionConsumerServices()) {
            throw new SamlException("No assertion consumer service could be found for entity " + entityId);
        }

        val peerEntityContext = outboundContext.getSubcontext(SAMLPeerEntityContext.class, true);
        if (peerEntityContext == null) {
            throw new SamlException("SAMLPeerEntityContext could not be defined for entity " + entityId);
        }
        peerEntityContext.setEntityId(entityId);

        val endpointContext = peerEntityContext.getSubcontext(SAMLEndpointContext.class, true);
        if (endpointContext == null) {
            throw new SamlException("SAMLEndpointContext could not be defined for entity " + entityId);
        }

        val endpoint = determineEndpointForRequest(request, adaptor, binding);
        LOGGER.debug("Configured peer entity endpoint to be [{}] with binding [{}]", endpoint.getLocation(), endpoint.getBinding());
        endpointContext.setEndpoint(endpoint);
    }
964460
public static sslcipher_sslciphersuite_binding[] get(nitro_service service, String ciphergroupname) throws Exception{
		sslcipher_sslciphersuite_binding obj = new sslcipher_sslciphersuite_binding();
		obj.set_ciphergroupname(ciphergroupname);
		sslcipher_sslciphersuite_binding response[] = (sslcipher_sslciphersuite_binding[]) obj.get_resources(service);
		return response;
	}
693093
protected MessageContext getEncoderMessageContext(final RequestAbstractType request, final T samlObject, final String relayState) {
        val ctx = new MessageContext<SAMLObject>();
        ctx.setMessage(samlObject);
        SAMLBindingSupport.setRelayState(ctx, relayState);
        SamlIdPUtils.preparePeerEntitySamlEndpointContext(request, ctx, adaptor, getBinding());
        val self = ctx.getSubcontext(SAMLSelfEntityContext.class, true);
        self.setEntityId(SamlIdPUtils.getIssuerFromSamlObject(samlObject));
        return ctx;
    }
1285409
protected void buildMetadataFilters(final SamlRegisteredService service, final AbstractMetadataResolver metadataProvider,
                                        final List<MetadataFilter> metadataFilterList) throws Exception {
        buildRequiredValidUntilFilterIfNeeded(service, metadataFilterList);
        buildSignatureValidationFilterIfNeeded(service, metadataFilterList);

        buildEntityRoleFilterIfNeeded(service, metadataFilterList);
        buildPredicateFilterIfNeeded(service, metadataFilterList);

        if (!metadataFilterList.isEmpty()) {
            addMetadataFiltersToMetadataResolver(metadataProvider, metadataFilterList);
        }
    }
1148773
@ReadOperation
    public Map<String, Object> getCachedMetadataObject(final String serviceId, @Nullable final String entityId) {
        try {
            val registeredService = findRegisteredService(serviceId);
            val issuer = StringUtils.defaultIfBlank(entityId, registeredService.getServiceId());
            val criteriaSet = new CriteriaSet();
            criteriaSet.add(new EntityIdCriterion(issuer));
            criteriaSet.add(new EntityRoleCriterion(SPSSODescriptor.DEFAULT_ELEMENT_NAME));
            val metadataResolver = cachingMetadataResolver.resolve(registeredService, criteriaSet);
            val iteration = metadataResolver.resolve(criteriaSet).spliterator();
            return StreamSupport.stream(iteration, false)
                .map(entity -> Pair.of(entity.getEntityID(), SamlUtils.transformSamlObject(openSamlConfigBean, entity).toString()))
                .collect(Collectors.toMap(Pair::getLeft, Pair::getRight));
        } catch (final Exception e) {
            LOGGER.error(e.getMessage(), e);
            return CollectionUtils.wrap("error", e.getMessage());
        }
    }
1239259
@GetMapping("/sp/metadata")
    public ResponseEntity<String> getFirstServiceProviderMetadata() {
        val saml2Client = builtClients.findClient(SAML2Client.class);
        if (saml2Client != null) {
            return getSaml2ClientServiceProviderMetadataResponseEntity(saml2Client);
        }
        return getNotAcceptableResponseEntity();
    }
274356
public static String getCipher(Map<String, Object> parameters) {
    return (String)parameters.get(ENCRYPTION_CIPHER_KEY);
  }
506228
static String toDeflatedBase64(SAMLObject message) {
        requireNonNull(message, "message");

        final String messageStr;
        try {
            messageStr = nodeToString(XMLObjectSupport.marshall(message));
        } catch (MarshallingException e) {
            throw new SamlException("failed to serialize a SAML message", e);
        }

        final ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
        try (DeflaterOutputStream deflaterStream =
                     new DeflaterOutputStream(Base64.getEncoder().wrap(bytesOut),
                                              new Deflater(Deflater.DEFLATED, true))) {
            deflaterStream.write(messageStr.getBytes(StandardCharsets.UTF_8));
        } catch (IOException e) {
            throw new SamlException("failed to deflate a SAML message", e);
        }
        return bytesOut.toString();
    }