WSO2-WSF-Perl
view release on metacpan or search on metacpan
WSO2-WSF/lib/WSO2/WSF/WSPolicy.pm view on Meta::CPAN
}
}
my $algos = (defined $options->{algorithmSuite}) ?
$options->{algorithmSuite} : undef;
if ( defined $algos ) {
WSO2::WSF::C::neethi_options_set_algorithmsuite($neethi_options, $env, $algos);
}
my $sign = (defined $options->{sign}) ?
$options->{sign} : undef;
if ( defined $sign ) {
if ( $sign =~ /true/i ) {
WSO2::WSF::C::neethi_options_set_sign_body($neethi_options, $env, $WSO2::WSF::C::AXIS2_TRUE);
} else {
WSO2::WSF::C::neethi_options_set_sign_body($neethi_options, $env, $sign);
}
}
my $str = (defined $options->{securityTokenReference}) ?
$options->{securityTokenReference} : undef;
if ( defined $str ) {
my $token_ref = get_rampart_token_value($str);
WSO2::WSF::C::neethi_options_set_keyidentifier($neethi_options, $env, $token_ref) if defined $token_ref;
}
$op = (defined $options->{encryptSignature}) ?
$options->{encryptSignature} : undef;
if ( (defined $op) and ($op eq 'TRUE') ) {
WSO2::WSF::C::neethi_options_set_signature_protection($neethi_options, $env, $WSO2::WSF::C::AXIS2_TRUE);
}
my $po = (defined $options->{protectionOrder}) ?
$options->{protectionOrder} : undef;
if ( defined $po ) {
if ( $po eq "EncryptBeforeSigning" ) {
WSO2::WSF::C::neethi_options_set_encrypt_before_sign($neethi_options, $env, $WSO2::WSF::C::AXIS2_TRUE);
} elsif ( $po eq "SignBeforeEncrypt" ) {
WSO2::WSF::C::neethi_options_set_encrypt_before_sign($neethi_options, $env, $WSO2::WSF::C::AXIS2_FALSE);
}
}
return WSO2::WSF::C::neethi_options_get_root_node($neethi_options, $env);
}
return undef;
}
sub get_rampart_token_value {
my $op = shift;
if ( $op eq "IssuerSerial" ) {
return $WSO2::WSF::C::RP_REQUIRE_ISSUER_SERIAL_REFERENCE;
} elsif ( $op eq "KeyIdentifier" ) {
return $WSO2::WSF::C::RP_REQUIRE_KEY_IDENTIFIRE_REFERENCE;
} elsif ( $op eq "EmbeddedToken" ) {
return $WSO2::WSF::C::RP_REQUIRE_EMBEDDED_TOKEN_REFERENCE;
} elsif ( $op eq "Thumbprint" ) {
return $WSO2::WSF::C::RP_REQUIRE_THUMBPRINT_REFERENCE;
} else {
return undef;
}
}
sub create_policy_from_string {
my $this = shift;
my $env = shift;
return undef if not defined $this->{security};
return WSO2::WSF::C::wsf_str_to_axiom_node($env, $this->{security}, length($this->{security}));
}
1;
__END__
=head1 NAME
WSO2::WSF::WSPolicy - Create a WSPolicy object
=head1 SYNOPSYS
my $policy = new WSO2::WSF::WSPolicy( { WSPOLICY_OPTIONS } );
=head1 DESCRIPTION
=head1 SEC_TOKEN_OPTIONS
=over 4
=item user
Holds the username.
=item certificate
User's certificate to be used for signing. Load the entire certificate
into a string and give that as a value. You can use the usual slurp
mode to do this.
my CERT, "< my_certificate.cert";
undef $/;
my $cert = <CERT>;
=item password
User's password used for UsernameToken
=item passwordType
Password type used in UsernameToken. Valid vaules are 'PlainText' and
'Digest'.
=item privateKey
( run in 1.059 second using v1.01-cache-2.11-cpan-2c0d6866c4f )