Search Results

Search found 7145 results on 286 pages for 'spring json'.

Page 12/286 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • How to use role-hierarchy in Spring Security 3 with Spring EL?

    - by Aleksey
    I want to use @PreAuthorize annotation on service methods with Spring Security. One of requirements is to use role-hierarchy. But by default it is not enabled. I found that in SecurityExpressionRoot class ("the base class for expression root objects") there is a property roleHierarchy. The class actually does use this property for methods like hasRole() and hasAnyRole(). I suppose that if I supply it with my own RoleHierarchy bean I will be able to use @PreAuthorize annotations with hierarchical roles. How can I inject my hierarchy bean into SecurityExpressionRoot?

    Read the article

  • Spring AOP: how to get the annotations of the adviced method

    - by hubertg
    I'd like to implement declarative security with Spring/AOP and annotations. As you see in the next code sample I have the Restricted Annotations with the paramter "allowedRoles" for defining who is allowed to execute an adviced method. @Restricted(allowedRoles="jira-administrators") public void setPassword(...) throws UserMgmtException { // set password code ... } Now, the problem is that in my Advice I have no access to the defined Annotations: public Object checkPermission(ProceedingJoinPoint pjp) throws Throwable { Signature signature = pjp.getSignature(); System.out.println("Allowed:" + rolesAllowedForJoinPoint(pjp)); ... } private Restricted rolesAllowedForJoinPoint(ProceedingJoinPoint thisJoinPoint) { MethodSignature methodSignature = (MethodSignature) thisJoinPoint.getSignature(); Method targetMethod = methodSignature.getMethod(); return targetMethod.getAnnotation(Restricted.class); } The method above always returns null (there are no annotations found at all). Is there a simple solution to this? I read something about using the AspectJ agent but I would prefer not to use this agent.

    Read the article

  • Jersey, Spring, Tomcat and Security Annotations

    - by jr
    I need to secure a simple jersey RESTful API in a Tomcat 6.0.24 container. I'd like to keep the authentication with Basic Authentication using the tomcat-users.xml file to define the users and roles (this is for now, like I said its small). Now, for authorization I'd like to be able to use the JSR 250 annotations like @RolesAllowed, @PermitAll, @DenyAll, etc. I cannot for the life of me figure out how to wire this all up together. I really don't want to go spring-security route, since I need something very simple at the current time. Can someone point me in the right direction.

    Read the article

  • ajax upload cannot process JSON response or gives download popup

    - by Jorre
    I'm using the AJAX plugin from Andris Valums: AJAX Upload ( http://valums.com/ajax-upload/ ) Copyright (c) Andris Valums It works great, except for the fact that I cannot send proper JSON as a response. I'm setting the headers to 'Content-Type', 'application/json' before sending the JSON-encoded response, and in the plugin I'm saying that I'm expecting JSON: responseType: "json", This gives me a download popup asking to download the JSON/REPONSE file. The strange thing is, when I don't ass the correct "Content-Type" to my response, it works. Of course I want to pass the correct response type, because all my jQuery 1.4 calls are depending on correct JSON. Does anyone else have had this same problem or is there anyone out there willing to try this out ? I'd love to use this plugin but only when I can return proper JSON with the correct content-type Thanks for all your help!

    Read the article

  • Spring Security Issue: Controller, Anonymous Requests...

    - by Srirangan
    Hey guys, I have an app that uses Spring security and BlazeDS. Flex 3.2 is used for the client app. Generally client app makes service calls using RemoteObjects. However, for certain cases client app is sending a request to a URL. We're using Annotated Controllers for URL mapping. Here's where the "Access is denied" exception comes up: 2010-04-12 11:43:23,486 [qtp5138683-16] ERROR fr.plasticomnium.gpoc.utils.ServiceExceptionInterceptor - Unexpected RuntimeException : Access is denied org.springframework.security.access.AccessDeniedException: Access is denied at org.springframework.security.access.vote.AffirmativeBased.decide(AffirmativeBased.java:71) at org.springframework.security.access.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:203) at org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:64) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at fr.plasticomnium.gpoc.utils.ServiceExceptionInterceptor.invoke(ServiceExceptionInterceptor.java:15) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) ... ...

    Read the article

  • JSON Post To Rails From Android

    - by Stealthnh
    I'm currently working on an android app that interfaces with a Ruby on Rails app through XML and JSON. I can currently pull all my posts from my website through XML but I can't seem to post via JSON. My app currently builds a JSON object from a form that looks a little something like this: { "post": { "other_param": "1", "post_content": "Blah blah blah" } } On my server I believe the Create method in my Posts Controller is set up correctly: def create @post = current_user.posts.build(params[:post]) respond_to do |format| if @post.save format.html { redirect_to @post, notice: 'Post was successfully created.' } format.json { render json: @post, status: :created, location: @post } format.xml { render xml: @post, status: :created, location: @post } else format.html { render action: "new" } format.json { render json: @post.errors, status: :unprocessable_entity } format.xml { render xml: @post.errors, status: :unprocessable_entity } end end end And in my android app I have a method that takes that JSON Object I posted earlier as a parameter along with the username and password for being authenticated (Authentication is working I've tested it, and yes Simple HTTP authentication is probably not the best choice but its a quick and dirty fix) and it then sends the JSON Object through HTTP POST to the rails server. This is that method: public static void sendPost(JSONObject post, String email, String password) { DefaultHttpClient client = new DefaultHttpClient(); client.getCredentialsProvider().setCredentials(new AuthScope(null,-1), new UsernamePasswordCredentials(email,password)); HttpPost httpPost = new HttpPost("http://mysite.com/posts"); JSONObject holder = new JSONObject(); try { holder.put("post", post); StringEntity se = new StringEntity(holder.toString()); Log.d("SendPostHTTP", holder.toString()); httpPost.setEntity(se); httpPost.setHeader("Content-Type","application/json"); } catch (UnsupportedEncodingException e) { Log.e("Error",""+e); e.printStackTrace(); } catch (JSONException js) { js.printStackTrace(); } HttpResponse response = null; try { response = client.execute(httpPost); } catch (ClientProtocolException e) { e.printStackTrace(); Log.e("ClientProtocol",""+e); } catch (IOException e) { e.printStackTrace(); Log.e("IO",""+e); } HttpEntity entity = response.getEntity(); if (entity != null) { try { entity.consumeContent(); } catch (IOException e) { Log.e("IO E",""+e); e.printStackTrace(); } } } Currently when I call this method and pass it the correct JSON Object it doesn't do anything and I have no clue why or how to figure out what is going wrong. Is my JSON still formatted wrong, does there really need to be that holder around the other data? Or do I need to use something other than HTTP POST? Or is this just something on the Rails end? A route or controller that isn't right? I'd be really grateful if someone could point me in the right direction, because I don't know where to go from here.

    Read the article

  • Spring security access with multiple roles

    - by Evgeny Makarov
    I want to define access for some pages for user who has one of following roles (ROLE1 or ROLE2) I'm trying to configure this in my spring security xml file as following: <security:http entry-point-ref="restAuthenticationEntryPoint" access-decision-manager-ref="accessDecisionManager" xmlns="http://www.springframework.org/schema/security" use-expressions="true"> <!-- skipped configuration --> <security:intercept-url pattern="/rest/api/myUrl*" access="hasRole('ROLE1') or hasRole('ROLE2')" /> <!-- skipped configuration --> </security:http> I've tried various ways like: access="hasRole('ROLE1, ROLE2')" access="hasRole('ROLE1', 'ROLE2')" access="hasAnyRole('[ROLE1', 'ROLE2]')" etc but nothing seems to be working. I'm keep getting exception java.lang.IllegalArgumentException: Unsupported configuration attributes: or java.lang.IllegalArgumentException: Failed to parse expression 'hasAnyRole(['ROLE1', 'ROLE2'])' how should it be configured? Thanks

    Read the article

  • spring add default value to form:select

    - by Mike
    I'm developing a spring application, now I've added a dropdownlist to one of my jsp pages using: <form:select multiple="single" path="users[y.count-1].X" items="${Y}" itemValue="id" itemLabel="name"/> Now I'd like to add the default value "Nothing selected", however I can't seem to find how to do this. I've tried: <form:select multiple="single" path="users[y.count-1].X" items="${Y}" itemValue="id" itemLabel="name"> <form:option value="Nothing selected" /> </form:select> But "Nothing selected" isn't displayed in my dropdownlist.

    Read the article

  • Is it possible to inject a bean into a spring form bean

    - by Mike
    I tried to do it 2 different ways, but neither way worked. @Component public class EmailForm{ ... private QuestionDAO questionDAO; ... @Autowired public void setQuestionDAO(QuestionDAO questionDAO) { this.questionDAO = questionDAO; } ... Another way: @Component public class EmailForm implements ApplicationContextAware { ... public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.questionDAO = (QuestionDAO)applicationContext.getBean("questionDAO"); } ... Neither way results in questionDAO being injected Form bean is populated by spring: @RequestMapping(method = RequestMethod.POST) public String submit(@Valid final EmailForm emailForm, BindingResult result, final Model model) {

    Read the article

  • Bind multiple request parameters to one object in Spring 3

    - by Max
    Hi, I can't figure out a way to bind several arguments and headers to one request parameter using annotations in Spring 3. For example, let's say I'm getting this request: Headers: Content-type: text/plain; POST Body: Name: Max Now I want it all to mysteriously bind to this object: class NameInfo { String name; } Using some code like this: String getName() { if ("text/plain".equals(headers.get("content-type"))) { return body.get("name"); } else if ("xml".equals(headers.get("content-type")) { return parseXml(body).get("name"); } else ... } So that in the end I would be able to use: @RequestMapping(method = RequestMethod.POST) void processName(@RequestAttribute NameInfo name) { ... } Is there a way to achieve something similar to what I need? Thanks in advance.

    Read the article

  • Spring Data MongoDB Date between two Dates

    - by sics
    i'm using Spring Data for MongoDB and got the following classes class A { List<B> b; } class B { Date startDate; Date endDate; } when i save an object of A it gets persisted like { "_id" : "DQDVDE000VFP8E39", "b" : [ { "startDate" : ISODate("2009-10-05T22:00:00Z"), "endDate" : ISODate("2009-10-29T23:00:00Z") }, { "startDate" : ISODate("2009-11-01T23:00:00Z"), "endDate" : ISODate("2009-12-30T23:00:00Z") } ] } Now i want to query the db for documents matching entries in b where a given date is between startDate and endDate. Query query = new Query(Criteria.where("a").elemMatch( Criteria.where("startDate").gte(date) .and("endDate").lte(date) ); Which results in the following mongo query: { "margins": { "$elemMatch": { "startDate" : { "$gte" : { "$date" : "2009-11-03T23:00:00.000Z"}}, "endDate" : { "$lte" : { "$date" : "2009-11-03T23:00:00.000Z"}} } } } but returns no resulting documents. Does anybody know what i'm doing wrong? I don't get it... Thank you very much in advance!!

    Read the article

  • Spring - Redirect after POST (even with validation errors)

    - by Taylor L
    I'm trying to figure out how to "preserve" the BindingResult so it can be used in a subsequent GET via the Spring <form:errors> tag. The reason I want to do this is because of Google App Engine's SSL limitations. I have a form which is displayed via HTTP and the post is to an HTTPS URL. If I only forward rather than redirect then the user would see the https://whatever.appspot.com/my/form URL. I'm trying to avoid this. Any ideas how to approach this? Below is what I'd like to do, but I only see validation errors when I use return "create". @RequestMapping(value = "/submit", method = RequestMethod.POST) public final String submit( @ModelAttribute("register") @Valid final Register register, final BindingResult binding) { if (binding.hasErrors()) { return "redirect:/register/create"; } return "redirect:/register/success"; }

    Read the article

  • Why were annotations introduced in Spring and Hibernate?

    - by Chandrashekhar
    I would like to know why were annotations introduced in Spring and Hibernate? For earlier versions of both the frameworks book authors were saying that if we keep configuration in xml files then it will be easier to maintain (due to decoupling) and just by changing the xml file we can re-configure the application. If we use annotations in our project and in future we want to re-configure application then again we have to compile and build the project. So why were these annotations introduced in these frameworks? From my point of view annotations make the apps dependent on certain framework. Isn't it true?

    Read the article

  • How do you deal with the conflict between ActiveSupport::JSON and the JSON gem?

    - by Luke Francl
    I am stumped with this problem. ActiveSupport::JSON defines to_json on various core objects and so does the JSON gem. However, the implementation is not the same -- the ActiveSupport version takes arguments and the JSON gem version doesn't. I installed a gem that required the JSON gem and my app broke. The issue is that I'm using to_json in a controller that returns a list of objects, but I want to control which attributes are returned. When code anywhere in my system does require 'json' I get this error message: TypeError: wrong argument type Hash (expected Data) I tried a couple of things that I read online to fix it, but nothing worked. I ended up re-writing the gem to use ActiveSupport::JSON.decode instead of JSON.parse. This works but it's not sustainable...I can't be forking gems every time I want to use a gem that requires the JSON gem. Update: The best solution of this problem is to upgrade to Rails 2.3 or higher, which fixed it.

    Read the article

  • How to assert/unit-test servers JSON response?

    - by shazax
    My current project uses JSON as data interchange format. Both Front-end and Back-end team agree upon a JSON structure before start integrating a service. At times due to un-notified changes in JSON structure by back-end team; it breaks the front-end code. Is there any external library that we could use to compare a mock JSON (fixture) with servers JSON response. Basically it should assert the whole JSON object and should throw an error if there is any violation in servers JSON format. Additional info: App is built on JQuery consuming REST JSON services.

    Read the article

  • Consuming Third Party web services through Spring WebServiceTemplate

    I'm trying to consume a Third Party web service, through a wsdl file provided. I would load the file locally from a Spring-J2EE based project underneath WEB-INF folder. The wsdl might have more than one operation exposed. So I need a way to be able to choose the method to be called. I would also need to make use of a JaxbMarshaller. Can anyone help with a code snippet for the same? Thanks for the help.

    Read the article

  • AddAllAttributes method spring mvc

    - by Nick Robertson
    I have two lists List<User> list_of_users=new ArrayList<User>(); List<String> list_of_attributes=new ArrayList<String>(); When i try to use the following lines of code: model.addAttribute("takeattributes",list_of_users); model.addAttribute("takeattributes",list_of_attributes); I realise that it keeps only the second list (list_of_attributes) and the first deleted. I was wondering how to keep both of these two lists in the model.Is this possible to be happened?Is the AddAllAttributes method what i need?If yes can anyone explain me how the AddAllAttributes method is working.I look at the spring mvc documentation but i didn't really understand.

    Read the article

  • Spring Roo and aspect-oriented programming

    - by marcos
    Hello, i've been running some experiments of my own with Spring Roo and it seems to be pretty cool, but i noticed that this tool makes heavy use of AOP on the model layer. I'm thinking about creating a real project using Roo and what i would like to know is: Why AOP is everywhere? Is That ok? What are advantages and disadvantages of this approach? I'm quite new to aspect-oriented programming and some guidance would be greatly appreciated. Thanks in advance!

    Read the article

  • Spring MVC JSP Parameters

    - by zpinter
    I'm looking to turn off try blocks for a specific JSP page (though turning it off globally would be OK as well). From what I've gathered, it looks something like this: <jsp-param> <param-name>noTryBlocks</param-name> <param-value>true</param-value> </jsp-param> However, everywhere I see that sample it's for a weblogic.xml file. Does anybody know how I can set this JSP parameters for a Spring MVC application? web.xml? Perhaps somewhere near here?: <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/> <property name="prefix" value="/WEB-INF/jsp/"/> <property name="suffix" value=".jsp"/> </bean>

    Read the article

  • Reading multiple json values with php

    - by jason
    I am trying to read certain values from a json string in php, I am able to do a simple json string with only one value such as $json = '{"value":"somevalue"}'; Using this: <?php $json = '{"value":"somevalue"}'; $obj = json_decode(json_encode($json)); print $obj->{'value'}; ?> But when i try an get a value from the following json string it throws an error... $json = '{"field": "title","rule": {"required": "true","minlength": "4","maxlength": "150" }}'; I validated the json on JSONlint but not sure how to access the values within this with php. Thanks

    Read the article

  • Spring data mapping problem.

    - by Yashwant Chavan
    Hi, I am using spring and hibernate along with my different components There is date field in DB as contract_end_date as a Date , so my pojo also contains date getter setter for contract_end_date, but when i submit form to Multiaction controller it gives data bindding exception for contract_end_date. It trying to search string getter setter for contract_end_date. So is there is any solution to handle this kind of problem. This is my pojo. after sumitting the form getting data binding exception public class Clnt implements java.io.Serializable { private String clntId; private String clntNm; private String busUnitNm; private String statCd; private String cmntTx; private Date contractEndDt; }

    Read the article

  • How to deserialize JSON text into a date type using Windows 8 JSON.parse?

    - by canderso
    I'm building a Windows 8 Metro app (aka "Modern UI Style" or "Windows Store app") in HTML5/JavaScript consuming JSON Web Services and I'm bumping into the following issue: in which format should my JSON Web Services serialize dates for the Windows 8 Metro JSON.parse method to deserialize those in a date type? I tried: sending dates using the ISO-8601 format, (JSON.parse returns a string), sending dates such as "/Date(1198908717056)/" as explained here (same result). I'm starting to doubt that Windows 8's JSON.parse method supports dates as even when parsing the output of its own JSON.stringify method does not return a date type. Example: var d = new Date(); // => a new date var str = JSON.stringify(d); // str is a string => "\"2012-07-10T14:44:00.000Z\"" var date2 = JSON.parse(str); // date2 is a string => "2012-07-10T14:44:00.000Z"

    Read the article

  • OpenId authentication and automatic registration with Spring Security 3.0.2

    - by xlluch
    I'm implementing an app using spring security 3.0.2 with OpenId login and registration. I can login succesfully, but if the user isn't registered i want to do: 1) Get some OpenId attributes like email and name. 2) Show to the user a registration form with just these two fields and the OpenId URI filled. I've been searching a lot but i didn't find an "ellegant" way of doing this. I wonder if some of u can come out with a solution to implement this strategy in my app. Thanks in advance.

    Read the article

  • Binding a select box to a Collection (with Spring)

    - by WiPU
    i have the following problem. I have a form bean and in this bean is a list with objects. List<SomeObjectForm> toDisplay; Now i want map a html select to this list. Something like that: <form:select id="inputGroupFields" path="templateKey" multiple="true"... <form:select id="inputGroupFields" path="templateKey.id" multiple="true"... And this dosnt work of course. Now i have tryed to add different custom Converter like: myConv implements Converter<SomeObjectForm, String> myConv extends StringToObject And this also not work. I'm not sure if this is the right approach or there is a easier way to do that. Some addional Infos: --i'm using spring 3.0.5 --all this happens during a web flow regards and thanks, WiPu

    Read the article

  • Access and modify attributes/objects which are not part of the form backing bean

    - by spa
    I use Spring MVC (via Spring Roo) to build a small web application for administering persons. In the page for creating a person the bean Person is used as form backing object (key "person" in the model map). <form:form action="${form_url}" method="POST" modelAttribute="person"> I would like to add some attributes to the model map which can be altered by the user in the creation form. Basically, I try to add a Boolean, so that I can control which page is displayed next after the user presses the submit button. I try to modify the Boolean (key "myBoolean" in the model map) using a simple checkbox: <form:checkbox id="_myboolean_id" path="myBoolean"/> However, as I am new to Spring MVC I have some difficulties here. The Boolean object is not an attribute of the form backing object. So if I try to access it the following exception is thrown (of course): Invalid property 'myBoolean' of bean class [de.cm.model.Person]: Bean property 'myBoolean' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter? Is there are way to access a value of the model map directly? The only solution I can imagine right now is a kind of wrapper object around the class Person and my additional attributes which is used as a new form backing object. However, this is more work for a IMHO simple task. Do you have a better solution?

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >