...
Code Block | ||||
---|---|---|---|---|
| ||||
public class SecureRolesServiceImpl implements SecureService {
@RolesAllowed({"role1", "role2"})
public void call() \{
// ...
}
}
|
Note
...
that
...
the
...
current
...
security
...
subject
...
can
...
be
...
injected
...
using
...
the
...
SCA
...
@Context
...
annotation
...
on
...
a
...
field
...
or
...
setter
...
method
...
that
...
takes
...
the
...
SCA
...
RequestContext
...
type.
...
Alternatively,
...
additional
...
Fabric3
...
APIs
...
can
...
be
...
accessed
...
by
...
using
...
the
...
org.fabric3.api.Fabric3RequestContext
...
type
...
in
...
place
...
of
...
the
...
SCA
...
RequestContext
...
type.
...
Simulating
...
Authentication
...
in
...
Integration
...
Tests
...
In
...
integration
...
test
...
environments,
...
it
...
is
...
often
...
required
...
to
...
simulate
...
authentication
...
credentials.
...
For
...
example,
...
a
...
test
...
client
...
may
...
need
...
to
...
supply
...
credentials
...
to
...
authenticate
...
with
...
the
...
secure
...
service
...
it
...
tests.
...
Fabric3
...
JUnit
...
test
...
components
...
can
...
be
...
configured
...
with
...
authentication
...
credentials,
...
and
...
those
...
credentials
...
propagated
...
over
...
a
...
remote
...
transport
...
such
...
as
...
Web
...
Services.
...
The
...
following
...
shows
...
how
...
to
...
simulate
...
username/password
...
credentials:
...
Code Block | ||||
---|---|---|---|---|
| ||||
<component name="SecurityTest"> <f3:junit class="..."> <configuration> <username>scott</username> <password>wombat</password> </configuration> </f3:junit> <reference name="service" target="SCASecureService"/> </component> |
...