[aerogear-dev] aerogear security and android

Bruno Oliveira bruno at abstractj.org
Tue Mar 18 09:31:46 EDT 2014


Good morning Marcelo, sorry if I didn’t get back to you sooner. As I told you, you don’t need AG Security. Thinking about it, I wrote a PoC with Apache Shiro to be tested against AeroGear Android, please take a look: https://github.com/abstractj/example-jaxrs-shiro

Passos already tested it with AG Android Cookbook. 

I hope it helps.


--  
abstractj

On March 12, 2014 at 1:47:46 PM, marceloheck (marceloheck at gmail.com) wrote:
> hi bruno thank you!
>  
> In android I used the example of the cookbook and it worked
>  
> the server try to use the example of jaxrs and I could not
>  
> try using aerogear-security-shiro and could not,
>  
> have an equal jaxrs example but using shiro?
>  
> infos:
> i use android native in client and jboss7.1(ejb jpa resteasy jdk6 jee6) in
> server
> database of users and profile and data, I seek a REST/JSON in a tomcat 5
> (legacy system)
>  
>  
> sample sequence:
>  
> >>>>>>>>>>android native send aerogear login <<<<<<<<
> private AuthenticationModule authModule;
> private String baseURL =
> "http://localhost:8080/servicos/service/auth";
>  
> private TextView status;
> private Button login;
> private Button logout;
> private static final String LOG_TAG = login.class.getName();
>  
> @Override
> protected void onCreate(Bundle savedInstanceState) {
> super.onCreate(savedInstanceState);
> setContentView(R.layout.activity_main);
>  
> Authenticator authenticator = new Authenticator(baseURL);
> AuthenticationConfig authenticationConfig = new
> AuthenticationConfig();
>  
> authenticationConfig.setLoginEndpoint("/login");
> authenticationConfig.setLogoutEndpoint("/logout");
> authModule = authenticator.auth("login",
> authenticationConfig);
>  
> status = (TextView) findViewById(R.id.editText1);
> login = (Button) findViewById(R.id.button1);
> logout = (Button) findViewById(R.id.Button01);
>  
> button = (Button) findViewById(R.id.button1);
>  
> login.setOnClickListener(new View.OnClickListener() {
> @Override
> public void onClick(View view) {
> authModule.login("jhon", "123", new
> AbstractActivityCallback() {
> }
>  
>  
>  
>  
> >>>>>>>>>server receive <<<<<<<<<<<
> (is my problem ) (wanted an example here )(queria um exemplo disso aqui no
> shiro )
>  
> @Path("/auth")
> public class LoginEndpoint {
>  
> private static final Logger LOGGER =
> Logger.getLogger(LoginEndpoint.class.getSimpleName());
>  
> // @Inject
> private AuthenticationManager authenticationManager;
>  
> @POST
> @Path("/login")
> @Produces(MediaType.APPLICATION_JSON)
> @Consumes(MediaType.APPLICATION_JSON)
> public Response login(User simpleUser) {
> User user = new User(simpleUser.getUsername(),
> simpleUser.getPassword());
> authenticationManager.login(user, simpleUser.getPassword());
> //return simpleUser;
> return Response.status(Status.OK).entity(user).build();
> }
>  
>  
> >>>>>>>>>>>>>>> android receive <<<<<<<<<<<<<<<<<<
>  
>  
> @Override
> public void onSuccess(HeaderAndBody data) {
> Log.d(LOG_TAG, "Received ID: " + data.toString() );
> logged(true);
>  
> Toast.makeText(getActivity(), "logado",
> Toast.LENGTH_SHORT).show();
> }
> ---------(as the android saves login, as he knows that this logged? need
> sample) -------
>  
>  
>  
> >>>>>>>>>>>>>>>> android send next requisition <<<<<<<<<<
>  
> URL BASE_URL = new URL("http://localhost:8080/servicos/service/");
>  
> PageConfig pageConfig = new PageConfig();
> pageConfig.setLimitValue(5);
>  
> pageConfig.setMetadataLocation(PageConfig.MetadataLocations.WEB_LINKING);  
> PipeConfig pipeConfig = new PipeConfig(BASE_URL,
> AbrigoVO.class);
> pipeConfig.setEndpoint("pessoa");
> pipeConfig.setPageConfig(pageConfig);
> pipeline = new Pipeline(BASE_URL);
> pipeline.pipe(pessoaVO.class, pipeConfig);
>  
> LoaderPipe pipes =
> pipeline.get("pessoavo", mContext);
> pipes.read(readCallback);
> return null;
> } catch (Exception e) {
> // TODO Need error handling
> Log.e(LOG_TAG, e.getLocalizedMessage(), e);
> Log.e(LOG_TAG, "sem serviço", e);
> e.printStackTrace();
> return null;
> }
> ---------next pipe in login? how call security rest? necessary is send login
> again? -------
>  
>  
> >>>>>>>>>>>>>>>server received and response<<<<<<<<<<
>  
>  
> @GET
> @Produces(MediaType.APPLICATION_JSON)
> public Response listar();
>  
> --------how use @secure("admin)? -------- is necessary a sample -----
>  
> >>>>>>>>>>>>>>>>the end<<<<<<<<<<<<<<<<<<
>  
>  
>  
>  
> --
> View this message in context: http://aerogear-dev.1069024.n5.nabble.com/aerogear-security-and-android-tp6703p6762.html  
> Sent from the aerogear-dev mailing list archive at Nabble.com.
>  
> _______________________________________________
> aerogear-dev mailing list
> aerogear-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/aerogear-dev




More information about the aerogear-dev mailing list