use of org.springframework.security.access.annotation.Secured in project cia by Hack23.
the class PartyRoleGhantPageModContentFactoryImpl method createContent.
@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
final VerticalLayout panelContent = createPanelContent();
final String pageId = getPageId(parameters);
final DataContainer<ViewRiksdagenParty, String> dataContainer = getApplicationManager().getDataContainer(ViewRiksdagenParty.class);
final ViewRiksdagenParty viewRiksdagenParty = dataContainer.load(pageId);
if (viewRiksdagenParty != null) {
getPartyMenuItemFactory().createPartyMenuBar(menuBar, pageId);
LabelFactory.createHeader2Label(panelContent, ROLE_GHANT);
final DataContainer<ViewRiksdagenPartyRoleMember, String> partyRoleMemberDataContainer = getApplicationManager().getDataContainer(ViewRiksdagenPartyRoleMember.class);
final List<ViewRiksdagenPartyRoleMember> allMembers = partyRoleMemberDataContainer.getAllBy(ViewRiksdagenPartyRoleMember_.party, viewRiksdagenParty.getPartyId());
partyGhantChartManager.createRoleGhant(panelContent, allMembers);
pageCompleted(parameters, panel, pageId, viewRiksdagenParty);
}
return panelContent;
}
use of org.springframework.security.access.annotation.Secured in project cia by Hack23.
the class PartyVoteHistoryPageModContentFactoryImpl method createContent.
@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
final VerticalLayout panelContent = createPanelContent();
final String pageId = getPageId(parameters);
final DataContainer<ViewRiksdagenParty, String> dataContainer = getApplicationManager().getDataContainer(ViewRiksdagenParty.class);
final ViewRiksdagenParty viewRiksdagenParty = dataContainer.load(pageId);
if (viewRiksdagenParty != null) {
getPartyMenuItemFactory().createPartyMenuBar(menuBar, pageId);
LabelFactory.createHeader2Label(panelContent, VOTE_HISTORY);
getGridFactory().createBasicBeanItemNestedPropertiesGrid(panelContent, ViewRiksdagenVoteDataBallotPartySummary.class, viewRiksdagenVoteDataBallotPartySummaryChartDataManager.findByValue(pageId), BALLOTS, NESTED_PROPERTIES, COLUMN_ORDER, HIDE_COLUMNS, LISTENER, EMBEDDED_ID_BALLOT_ID, null);
pageCompleted(parameters, panel, pageId, viewRiksdagenParty);
}
return panelContent;
}
use of org.springframework.security.access.annotation.Secured in project Gemma by PavlidisLab.
the class UserManagerImpl method changePassword.
@Override
@Secured({ "GROUP_USER" })
@Transactional
public void changePassword(String oldPassword, String newPassword) throws AuthenticationException {
Authentication currentAuthentication = SecurityContextHolder.getContext().getAuthentication();
if (currentAuthentication == null) {
// This would indicate bad coding somewhere
throw new AccessDeniedException("Can't change password as no Authentication object found in context " + "for current user.");
}
String username = currentAuthentication.getName();
logger.debug("Changing password for user '" + username + "'");
User u = this.loadUser(username);
u.setPassword(newPassword);
userService.update(u);
SecurityContextHolder.getContext().setAuthentication(this.createNewAuthentication(currentAuthentication, newPassword));
userCache.removeUserFromCache(username);
}
use of org.springframework.security.access.annotation.Secured in project Gemma by PavlidisLab.
the class UserManagerImpl method createUser.
@Override
@Secured({ "IS_AUTHENTICATED_ANONYMOUSLY", "RUN_AS_ADMIN" })
@Transactional
public void createUser(UserDetails user) {
/*
* UserDetails is not an entity, so this method is not directly managed by the Audit or ACL advice. However, it
* runs in a transaction and calls two service methods which are intercepted. This means it is intercepted
* before the transaction is flushed.
*/
this.validateUserName(user.getUsername());
User u = ubic.gemma.model.common.auditAndSecurity.User.Factory.newInstance();
u.setUserName(user.getUsername());
u.setPassword(user.getPassword());
u.setEnabled(user.isEnabled());
if (user instanceof UserDetailsImpl) {
u.setSignupToken(((UserDetailsImpl) user).getSignupToken());
u.setSignupTokenDatestamp(((UserDetailsImpl) user).getSignupTokenDatestamp());
}
if (user instanceof UserDetailsImpl) {
u.setEmail(((UserDetailsImpl) user).getEmail());
}
try {
u = userService.create(u);
} catch (UserExistsException e) {
throw new RuntimeException(e);
}
// Add the user to the default user group.
UserGroup g = this.loadGroup(AuthorityConstants.USER_GROUP_NAME);
userService.addUserToGroup(g, u);
/*
* We don't log the user in automatically, because we require that new users click a confirmation link in an
* email.
*/
}
use of org.springframework.security.access.annotation.Secured in project Gemma by PavlidisLab.
the class TwitterOutboundImpl method sendManualTweet.
@Override
@Secured({ "GROUP_ADMIN" })
public void sendManualTweet(String feed) {
TwitterOutboundImpl.log.debug("Checking if Twitter is enabled");
if (!Settings.getBoolean("gemma.twitter.enabled")) {
TwitterOutboundImpl.log.info("Twitter is disabled.");
return;
}
if (StringUtils.isNotBlank(feed)) {
TwitterOutboundImpl.log.info("Sending out tweet: '" + feed + "'");
String consumerKey = Settings.getString("twitter.consumer-key");
String consumerSecret = Settings.getString("twitter.consumer-secret");
String accessToken = Settings.getString("twitter.access-token");
String accessTokenSecret = Settings.getString("twitter.access-token-secret");
Twitter twitter = new TwitterTemplate(consumerKey, consumerSecret, accessToken, accessTokenSecret);
StatusDetails metadata = new StatusDetails();
metadata.setWrapLinks(true);
try {
Tweet tweet = twitter.timelineOperations().updateStatus(feed, metadata);
TwitterOutboundImpl.log.info("tweet info:" + tweet.toString());
} catch (Exception e) {
TwitterOutboundImpl.log.info(e.toString());
e.printStackTrace();
}
}
}
Aggregations